Update dependencies and clean up project structure. Add cloud.google.com/go/compute/metadata as an indirect requirement in go.mod. Remove unused files and update package.json for Vite and React plugins. Refactor Makefile for improved build process.
This commit is contained in:
8
web/dist/assets/index-DJO8pTHt.js
vendored
Normal file
8
web/dist/assets/index-DJO8pTHt.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
web/dist/assets/index-rerlyxof.css
vendored
Normal file
1
web/dist/assets/index-rerlyxof.css
vendored
Normal file
File diff suppressed because one or more lines are too long
14
web/dist/index.html
vendored
Normal file
14
web/dist/index.html
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Fuego Render Farm</title>
|
||||
<script type="module" crossorigin src="/assets/index-DJO8pTHt.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-rerlyxof.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
1
web/node_modules/.bin/cssesc
generated
vendored
Symbolic link
1
web/node_modules/.bin/cssesc
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../cssesc/bin/cssesc
|
||||
1
web/node_modules/.bin/jiti
generated
vendored
Symbolic link
1
web/node_modules/.bin/jiti
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jiti/bin/jiti.js
|
||||
1
web/node_modules/.bin/loose-envify
generated
vendored
Symbolic link
1
web/node_modules/.bin/loose-envify
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../loose-envify/cli.js
|
||||
1
web/node_modules/.bin/resolve
generated
vendored
Symbolic link
1
web/node_modules/.bin/resolve
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../resolve/bin/resolve
|
||||
1
web/node_modules/.bin/sucrase
generated
vendored
Symbolic link
1
web/node_modules/.bin/sucrase
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../sucrase/bin/sucrase
|
||||
1
web/node_modules/.bin/sucrase-node
generated
vendored
Symbolic link
1
web/node_modules/.bin/sucrase-node
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../sucrase/bin/sucrase-node
|
||||
1
web/node_modules/.bin/tailwind
generated
vendored
Symbolic link
1
web/node_modules/.bin/tailwind
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../tailwindcss/lib/cli.js
|
||||
1
web/node_modules/.bin/tailwindcss
generated
vendored
Symbolic link
1
web/node_modules/.bin/tailwindcss
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../tailwindcss/lib/cli.js
|
||||
1024
web/node_modules/.package-lock.json
generated
vendored
1024
web/node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
128
web/node_modules/@alloc/quick-lru/index.d.ts
generated
vendored
Normal file
128
web/node_modules/@alloc/quick-lru/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
declare namespace QuickLRU {
|
||||
interface Options<KeyType, ValueType> {
|
||||
/**
|
||||
The maximum number of milliseconds an item should remain in the cache.
|
||||
|
||||
@default Infinity
|
||||
|
||||
By default, `maxAge` will be `Infinity`, which means that items will never expire.
|
||||
Lazy expiration upon the next write or read call.
|
||||
|
||||
Individual expiration of an item can be specified by the `set(key, value, maxAge)` method.
|
||||
*/
|
||||
readonly maxAge?: number;
|
||||
|
||||
/**
|
||||
The maximum number of items before evicting the least recently used items.
|
||||
*/
|
||||
readonly maxSize: number;
|
||||
|
||||
/**
|
||||
Called right before an item is evicted from the cache.
|
||||
|
||||
Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).
|
||||
*/
|
||||
onEviction?: (key: KeyType, value: ValueType) => void;
|
||||
}
|
||||
}
|
||||
|
||||
declare class QuickLRU<KeyType, ValueType>
|
||||
implements Iterable<[KeyType, ValueType]> {
|
||||
/**
|
||||
The stored item count.
|
||||
*/
|
||||
readonly size: number;
|
||||
|
||||
/**
|
||||
Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29).
|
||||
|
||||
The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
|
||||
|
||||
@example
|
||||
```
|
||||
import QuickLRU = require('quick-lru');
|
||||
|
||||
const lru = new QuickLRU({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', '🌈');
|
||||
|
||||
lru.has('🦄');
|
||||
//=> true
|
||||
|
||||
lru.get('🦄');
|
||||
//=> '🌈'
|
||||
```
|
||||
*/
|
||||
constructor(options: QuickLRU.Options<KeyType, ValueType>);
|
||||
|
||||
[Symbol.iterator](): IterableIterator<[KeyType, ValueType]>;
|
||||
|
||||
/**
|
||||
Set an item. Returns the instance.
|
||||
|
||||
Individual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified in the constructor, otherwise the item will never expire.
|
||||
|
||||
@returns The list instance.
|
||||
*/
|
||||
set(key: KeyType, value: ValueType, options?: {maxAge?: number}): this;
|
||||
|
||||
/**
|
||||
Get an item.
|
||||
|
||||
@returns The stored item or `undefined`.
|
||||
*/
|
||||
get(key: KeyType): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Check if an item exists.
|
||||
*/
|
||||
has(key: KeyType): boolean;
|
||||
|
||||
/**
|
||||
Get an item without marking it as recently used.
|
||||
|
||||
@returns The stored item or `undefined`.
|
||||
*/
|
||||
peek(key: KeyType): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Delete an item.
|
||||
|
||||
@returns `true` if the item is removed or `false` if the item doesn't exist.
|
||||
*/
|
||||
delete(key: KeyType): boolean;
|
||||
|
||||
/**
|
||||
Delete all items.
|
||||
*/
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
Update the `maxSize` in-place, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.
|
||||
|
||||
Useful for on-the-fly tuning of cache sizes in live systems.
|
||||
*/
|
||||
resize(maxSize: number): void;
|
||||
|
||||
/**
|
||||
Iterable for all the keys.
|
||||
*/
|
||||
keys(): IterableIterator<KeyType>;
|
||||
|
||||
/**
|
||||
Iterable for all the values.
|
||||
*/
|
||||
values(): IterableIterator<ValueType>;
|
||||
|
||||
/**
|
||||
Iterable for all entries, starting with the oldest (ascending in recency).
|
||||
*/
|
||||
entriesAscending(): IterableIterator<[KeyType, ValueType]>;
|
||||
|
||||
/**
|
||||
Iterable for all entries, starting with the newest (descending in recency).
|
||||
*/
|
||||
entriesDescending(): IterableIterator<[KeyType, ValueType]>;
|
||||
}
|
||||
|
||||
export = QuickLRU;
|
||||
263
web/node_modules/@alloc/quick-lru/index.js
generated
vendored
Normal file
263
web/node_modules/@alloc/quick-lru/index.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
'use strict';
|
||||
|
||||
class QuickLRU {
|
||||
constructor(options = {}) {
|
||||
if (!(options.maxSize && options.maxSize > 0)) {
|
||||
throw new TypeError('`maxSize` must be a number greater than 0');
|
||||
}
|
||||
|
||||
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
|
||||
throw new TypeError('`maxAge` must be a number greater than 0');
|
||||
}
|
||||
|
||||
this.maxSize = options.maxSize;
|
||||
this.maxAge = options.maxAge || Infinity;
|
||||
this.onEviction = options.onEviction;
|
||||
this.cache = new Map();
|
||||
this.oldCache = new Map();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
_emitEvictions(cache) {
|
||||
if (typeof this.onEviction !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const [key, item] of cache) {
|
||||
this.onEviction(key, item.value);
|
||||
}
|
||||
}
|
||||
|
||||
_deleteIfExpired(key, item) {
|
||||
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
|
||||
if (typeof this.onEviction === 'function') {
|
||||
this.onEviction(key, item.value);
|
||||
}
|
||||
|
||||
return this.delete(key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_getOrDeleteIfExpired(key, item) {
|
||||
const deleted = this._deleteIfExpired(key, item);
|
||||
if (deleted === false) {
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
|
||||
_getItemValue(key, item) {
|
||||
return item.expiry ? this._getOrDeleteIfExpired(key, item) : item.value;
|
||||
}
|
||||
|
||||
_peek(key, cache) {
|
||||
const item = cache.get(key);
|
||||
|
||||
return this._getItemValue(key, item);
|
||||
}
|
||||
|
||||
_set(key, value) {
|
||||
this.cache.set(key, value);
|
||||
this._size++;
|
||||
|
||||
if (this._size >= this.maxSize) {
|
||||
this._size = 0;
|
||||
this._emitEvictions(this.oldCache);
|
||||
this.oldCache = this.cache;
|
||||
this.cache = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
_moveToRecent(key, item) {
|
||||
this.oldCache.delete(key);
|
||||
this._set(key, item);
|
||||
}
|
||||
|
||||
* _entriesAscending() {
|
||||
for (const item of this.oldCache) {
|
||||
const [key, value] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of this.cache) {
|
||||
const [key, value] = item;
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
if (this.cache.has(key)) {
|
||||
const item = this.cache.get(key);
|
||||
|
||||
return this._getItemValue(key, item);
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
const item = this.oldCache.get(key);
|
||||
if (this._deleteIfExpired(key, item) === false) {
|
||||
this._moveToRecent(key, item);
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set(key, value, {maxAge = this.maxAge === Infinity ? undefined : Date.now() + this.maxAge} = {}) {
|
||||
if (this.cache.has(key)) {
|
||||
this.cache.set(key, {
|
||||
value,
|
||||
maxAge
|
||||
});
|
||||
} else {
|
||||
this._set(key, {value, expiry: maxAge});
|
||||
}
|
||||
}
|
||||
|
||||
has(key) {
|
||||
if (this.cache.has(key)) {
|
||||
return !this._deleteIfExpired(key, this.cache.get(key));
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
return !this._deleteIfExpired(key, this.oldCache.get(key));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
peek(key) {
|
||||
if (this.cache.has(key)) {
|
||||
return this._peek(key, this.cache);
|
||||
}
|
||||
|
||||
if (this.oldCache.has(key)) {
|
||||
return this._peek(key, this.oldCache);
|
||||
}
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
const deleted = this.cache.delete(key);
|
||||
if (deleted) {
|
||||
this._size--;
|
||||
}
|
||||
|
||||
return this.oldCache.delete(key) || deleted;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
this.oldCache.clear();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
resize(newSize) {
|
||||
if (!(newSize && newSize > 0)) {
|
||||
throw new TypeError('`maxSize` must be a number greater than 0');
|
||||
}
|
||||
|
||||
const items = [...this._entriesAscending()];
|
||||
const removeCount = items.length - newSize;
|
||||
if (removeCount < 0) {
|
||||
this.cache = new Map(items);
|
||||
this.oldCache = new Map();
|
||||
this._size = items.length;
|
||||
} else {
|
||||
if (removeCount > 0) {
|
||||
this._emitEvictions(items.slice(0, removeCount));
|
||||
}
|
||||
|
||||
this.oldCache = new Map(items.slice(removeCount));
|
||||
this.cache = new Map();
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
this.maxSize = newSize;
|
||||
}
|
||||
|
||||
* keys() {
|
||||
for (const [key] of this) {
|
||||
yield key;
|
||||
}
|
||||
}
|
||||
|
||||
* values() {
|
||||
for (const [, value] of this) {
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
for (const item of this.cache) {
|
||||
const [key, value] = item;
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of this.oldCache) {
|
||||
const [key, value] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* entriesDescending() {
|
||||
let items = [...this.cache];
|
||||
for (let i = items.length - 1; i >= 0; --i) {
|
||||
const item = items[i];
|
||||
const [key, value] = item;
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
|
||||
items = [...this.oldCache];
|
||||
for (let i = items.length - 1; i >= 0; --i) {
|
||||
const item = items[i];
|
||||
const [key, value] = item;
|
||||
if (!this.cache.has(key)) {
|
||||
const deleted = this._deleteIfExpired(key, value);
|
||||
if (deleted === false) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* entriesAscending() {
|
||||
for (const [key, value] of this._entriesAscending()) {
|
||||
yield [key, value.value];
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
if (!this._size) {
|
||||
return this.oldCache.size;
|
||||
}
|
||||
|
||||
let oldCacheSize = 0;
|
||||
for (const key of this.oldCache.keys()) {
|
||||
if (!this.cache.has(key)) {
|
||||
oldCacheSize++;
|
||||
}
|
||||
}
|
||||
|
||||
return Math.min(this._size + oldCacheSize, this.maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QuickLRU;
|
||||
9
web/node_modules/@alloc/quick-lru/license
generated
vendored
Normal file
9
web/node_modules/@alloc/quick-lru/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
||||
43
web/node_modules/@alloc/quick-lru/package.json
generated
vendored
Normal file
43
web/node_modules/@alloc/quick-lru/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@alloc/quick-lru",
|
||||
"version": "5.2.0",
|
||||
"description": "Simple “Least Recently Used” (LRU) cache",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/quick-lru",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"lru",
|
||||
"quick",
|
||||
"cache",
|
||||
"caching",
|
||||
"least",
|
||||
"recently",
|
||||
"used",
|
||||
"fast",
|
||||
"map",
|
||||
"hash",
|
||||
"buffer"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.0.0",
|
||||
"coveralls": "^3.0.3",
|
||||
"nyc": "^15.0.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.26.0"
|
||||
}
|
||||
}
|
||||
139
web/node_modules/@alloc/quick-lru/readme.md
generated
vendored
Normal file
139
web/node_modules/@alloc/quick-lru/readme.md
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
# quick-lru [](https://travis-ci.org/sindresorhus/quick-lru) [](https://coveralls.io/github/sindresorhus/quick-lru?branch=master)
|
||||
|
||||
> Simple [“Least Recently Used” (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)
|
||||
|
||||
Useful when you need to cache something and limit memory usage.
|
||||
|
||||
Inspired by the [`hashlru` algorithm](https://github.com/dominictarr/hashlru#algorithm), but instead uses [`Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) to support keys of any type, not just strings, and values can be `undefined`.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install quick-lru
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const QuickLRU = require('quick-lru');
|
||||
|
||||
const lru = new QuickLRU({maxSize: 1000});
|
||||
|
||||
lru.set('🦄', '🌈');
|
||||
|
||||
lru.has('🦄');
|
||||
//=> true
|
||||
|
||||
lru.get('🦄');
|
||||
//=> '🌈'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### new QuickLRU(options?)
|
||||
|
||||
Returns a new instance.
|
||||
|
||||
### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
#### maxSize
|
||||
|
||||
*Required*\
|
||||
Type: `number`
|
||||
|
||||
The maximum number of items before evicting the least recently used items.
|
||||
|
||||
#### maxAge
|
||||
|
||||
Type: `number`\
|
||||
Default: `Infinity`
|
||||
|
||||
The maximum number of milliseconds an item should remain in cache.
|
||||
By default maxAge will be Infinity, which means that items will never expire.
|
||||
|
||||
Lazy expiration happens upon the next `write` or `read` call.
|
||||
|
||||
Individual expiration of an item can be specified by the `set(key, value, options)` method.
|
||||
|
||||
#### onEviction
|
||||
|
||||
*Optional*\
|
||||
Type: `(key, value) => void`
|
||||
|
||||
Called right before an item is evicted from the cache.
|
||||
|
||||
Useful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).
|
||||
|
||||
### Instance
|
||||
|
||||
The instance is [`iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
|
||||
|
||||
Both `key` and `value` can be of any type.
|
||||
|
||||
#### .set(key, value, options?)
|
||||
|
||||
Set an item. Returns the instance.
|
||||
|
||||
Individual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified on the constructor, otherwise the item will never expire.
|
||||
|
||||
#### .get(key)
|
||||
|
||||
Get an item.
|
||||
|
||||
#### .has(key)
|
||||
|
||||
Check if an item exists.
|
||||
|
||||
#### .peek(key)
|
||||
|
||||
Get an item without marking it as recently used.
|
||||
|
||||
#### .delete(key)
|
||||
|
||||
Delete an item.
|
||||
|
||||
Returns `true` if the item is removed or `false` if the item doesn't exist.
|
||||
|
||||
#### .clear()
|
||||
|
||||
Delete all items.
|
||||
|
||||
#### .resize(maxSize)
|
||||
|
||||
Update the `maxSize`, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.
|
||||
|
||||
Useful for on-the-fly tuning of cache sizes in live systems.
|
||||
|
||||
#### .keys()
|
||||
|
||||
Iterable for all the keys.
|
||||
|
||||
#### .values()
|
||||
|
||||
Iterable for all the values.
|
||||
|
||||
#### .entriesAscending()
|
||||
|
||||
Iterable for all entries, starting with the oldest (ascending in recency).
|
||||
|
||||
#### .entriesDescending()
|
||||
|
||||
Iterable for all entries, starting with the newest (descending in recency).
|
||||
|
||||
#### .size
|
||||
|
||||
The stored item count.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-quick-lru?utm_source=npm-quick-lru&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
21
web/node_modules/@nodelib/fs.scandir/LICENSE
generated
vendored
Normal file
21
web/node_modules/@nodelib/fs.scandir/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Denis Malinochkin
|
||||
|
||||
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.
|
||||
171
web/node_modules/@nodelib/fs.scandir/README.md
generated
vendored
Normal file
171
web/node_modules/@nodelib/fs.scandir/README.md
generated
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
# @nodelib/fs.scandir
|
||||
|
||||
> List files and directories inside the specified directory.
|
||||
|
||||
## :bulb: Highlights
|
||||
|
||||
The package is aimed at obtaining information about entries in the directory.
|
||||
|
||||
* :moneybag: Returns useful information: `name`, `path`, `dirent` and `stats` (optional).
|
||||
* :gear: On Node.js 10.10+ uses the mechanism without additional calls to determine the entry type. See [`old` and `modern` mode](#old-and-modern-mode).
|
||||
* :link: Can safely work with broken symbolic links.
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
npm install @nodelib/fs.scandir
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import * as fsScandir from '@nodelib/fs.scandir';
|
||||
|
||||
fsScandir.scandir('path', (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .scandir(path, [optionsOrSettings], callback)
|
||||
|
||||
Returns an array of plain objects ([`Entry`](#entry)) with information about entry for provided path with standard callback-style.
|
||||
|
||||
```ts
|
||||
fsScandir.scandir('path', (error, entries) => { /* … */ });
|
||||
fsScandir.scandir('path', {}, (error, entries) => { /* … */ });
|
||||
fsScandir.scandir('path', new fsScandir.Settings(), (error, entries) => { /* … */ });
|
||||
```
|
||||
|
||||
### .scandirSync(path, [optionsOrSettings])
|
||||
|
||||
Returns an array of plain objects ([`Entry`](#entry)) with information about entry for provided path.
|
||||
|
||||
```ts
|
||||
const entries = fsScandir.scandirSync('path');
|
||||
const entries = fsScandir.scandirSync('path', {});
|
||||
const entries = fsScandir.scandirSync(('path', new fsScandir.Settings());
|
||||
```
|
||||
|
||||
#### path
|
||||
|
||||
* Required: `true`
|
||||
* Type: `string | Buffer | URL`
|
||||
|
||||
A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
|
||||
#### optionsOrSettings
|
||||
|
||||
* Required: `false`
|
||||
* Type: `Options | Settings`
|
||||
* Default: An instance of `Settings` class
|
||||
|
||||
An [`Options`](#options) object or an instance of [`Settings`](#settingsoptions) class.
|
||||
|
||||
> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class.
|
||||
|
||||
### Settings([options])
|
||||
|
||||
A class of full settings of the package.
|
||||
|
||||
```ts
|
||||
const settings = new fsScandir.Settings({ followSymbolicLinks: false });
|
||||
|
||||
const entries = fsScandir.scandirSync('path', settings);
|
||||
```
|
||||
|
||||
## Entry
|
||||
|
||||
* `name` — The name of the entry (`unknown.txt`).
|
||||
* `path` — The path of the entry relative to call directory (`root/unknown.txt`).
|
||||
* `dirent` — An instance of [`fs.Dirent`](./src/types/index.ts) class. On Node.js below 10.10 will be emulated by [`DirentFromStats`](./src/utils/fs.ts) class.
|
||||
* `stats` (optional) — An instance of `fs.Stats` class.
|
||||
|
||||
For example, the `scandir` call for `tools` directory with one directory inside:
|
||||
|
||||
```ts
|
||||
{
|
||||
dirent: Dirent { name: 'typedoc', /* … */ },
|
||||
name: 'typedoc',
|
||||
path: 'tools/typedoc'
|
||||
}
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### stats
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Adds an instance of `fs.Stats` class to the [`Entry`](#entry).
|
||||
|
||||
> :book: Always use `fs.readdir` without the `withFileTypes` option. ??TODO??
|
||||
|
||||
### followSymbolicLinks
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Follow symbolic links or not. Call `fs.stat` on symbolic link if `true`.
|
||||
|
||||
### `throwErrorOnBrokenSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Throw an error when symbolic link is broken if `true` or safely use `lstat` call if `false`.
|
||||
|
||||
### `pathSegmentSeparator`
|
||||
|
||||
* Type: `string`
|
||||
* Default: `path.sep`
|
||||
|
||||
By default, this package uses the correct path separator for your OS (`\` on Windows, `/` on Unix-like systems). But you can set this option to any separator character(s) that you want to use instead.
|
||||
|
||||
### `fs`
|
||||
|
||||
* Type: [`FileSystemAdapter`](./src/adapters/fs.ts)
|
||||
* Default: A default FS methods
|
||||
|
||||
By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own.
|
||||
|
||||
```ts
|
||||
interface FileSystemAdapter {
|
||||
lstat?: typeof fs.lstat;
|
||||
stat?: typeof fs.stat;
|
||||
lstatSync?: typeof fs.lstatSync;
|
||||
statSync?: typeof fs.statSync;
|
||||
readdir?: typeof fs.readdir;
|
||||
readdirSync?: typeof fs.readdirSync;
|
||||
}
|
||||
|
||||
const settings = new fsScandir.Settings({
|
||||
fs: { lstat: fakeLstat }
|
||||
});
|
||||
```
|
||||
|
||||
## `old` and `modern` mode
|
||||
|
||||
This package has two modes that are used depending on the environment and parameters of use.
|
||||
|
||||
### old
|
||||
|
||||
* Node.js below `10.10` or when the `stats` option is enabled
|
||||
|
||||
When working in the old mode, the directory is read first (`fs.readdir`), then the type of entries is determined (`fs.lstat` and/or `fs.stat` for symbolic links).
|
||||
|
||||
### modern
|
||||
|
||||
* Node.js 10.10+ and the `stats` option is disabled
|
||||
|
||||
In the modern mode, reading the directory (`fs.readdir` with the `withFileTypes` option) is combined with obtaining information about its entries. An additional call for symbolic links (`fs.stat`) is still present.
|
||||
|
||||
This mode makes fewer calls to the file system. It's faster.
|
||||
|
||||
## Changelog
|
||||
|
||||
See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version.
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the terms of the MIT license.
|
||||
20
web/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts
generated
vendored
Normal file
20
web/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type * as fsStat from '@nodelib/fs.stat';
|
||||
import type { Dirent, ErrnoException } from '../types';
|
||||
export interface ReaddirAsynchronousMethod {
|
||||
(filepath: string, options: {
|
||||
withFileTypes: true;
|
||||
}, callback: (error: ErrnoException | null, files: Dirent[]) => void): void;
|
||||
(filepath: string, callback: (error: ErrnoException | null, files: string[]) => void): void;
|
||||
}
|
||||
export interface ReaddirSynchronousMethod {
|
||||
(filepath: string, options: {
|
||||
withFileTypes: true;
|
||||
}): Dirent[];
|
||||
(filepath: string): string[];
|
||||
}
|
||||
export declare type FileSystemAdapter = fsStat.FileSystemAdapter & {
|
||||
readdir: ReaddirAsynchronousMethod;
|
||||
readdirSync: ReaddirSynchronousMethod;
|
||||
};
|
||||
export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
|
||||
export declare function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
|
||||
19
web/node_modules/@nodelib/fs.scandir/out/adapters/fs.js
generated
vendored
Normal file
19
web/node_modules/@nodelib/fs.scandir/out/adapters/fs.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
||||
const fs = require("fs");
|
||||
exports.FILE_SYSTEM_ADAPTER = {
|
||||
lstat: fs.lstat,
|
||||
stat: fs.stat,
|
||||
lstatSync: fs.lstatSync,
|
||||
statSync: fs.statSync,
|
||||
readdir: fs.readdir,
|
||||
readdirSync: fs.readdirSync
|
||||
};
|
||||
function createFileSystemAdapter(fsMethods) {
|
||||
if (fsMethods === undefined) {
|
||||
return exports.FILE_SYSTEM_ADAPTER;
|
||||
}
|
||||
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
||||
}
|
||||
exports.createFileSystemAdapter = createFileSystemAdapter;
|
||||
4
web/node_modules/@nodelib/fs.scandir/out/constants.d.ts
generated
vendored
Normal file
4
web/node_modules/@nodelib/fs.scandir/out/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* IS `true` for Node.js 10.10 and greater.
|
||||
*/
|
||||
export declare const IS_SUPPORT_READDIR_WITH_FILE_TYPES: boolean;
|
||||
17
web/node_modules/@nodelib/fs.scandir/out/constants.js
generated
vendored
Normal file
17
web/node_modules/@nodelib/fs.scandir/out/constants.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0;
|
||||
const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
|
||||
if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) {
|
||||
throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);
|
||||
}
|
||||
const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
|
||||
const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
|
||||
const SUPPORTED_MAJOR_VERSION = 10;
|
||||
const SUPPORTED_MINOR_VERSION = 10;
|
||||
const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
|
||||
const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
|
||||
/**
|
||||
* IS `true` for Node.js 10.10 and greater.
|
||||
*/
|
||||
exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;
|
||||
12
web/node_modules/@nodelib/fs.scandir/out/index.d.ts
generated
vendored
Normal file
12
web/node_modules/@nodelib/fs.scandir/out/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { FileSystemAdapter, ReaddirAsynchronousMethod, ReaddirSynchronousMethod } from './adapters/fs';
|
||||
import * as async from './providers/async';
|
||||
import Settings, { Options } from './settings';
|
||||
import type { Dirent, Entry } from './types';
|
||||
declare type AsyncCallback = async.AsyncCallback;
|
||||
declare function scandir(path: string, callback: AsyncCallback): void;
|
||||
declare function scandir(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
|
||||
declare namespace scandir {
|
||||
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
|
||||
}
|
||||
declare function scandirSync(path: string, optionsOrSettings?: Options | Settings): Entry[];
|
||||
export { scandir, scandirSync, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, ReaddirAsynchronousMethod, ReaddirSynchronousMethod, Options };
|
||||
26
web/node_modules/@nodelib/fs.scandir/out/index.js
generated
vendored
Normal file
26
web/node_modules/@nodelib/fs.scandir/out/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Settings = exports.scandirSync = exports.scandir = void 0;
|
||||
const async = require("./providers/async");
|
||||
const sync = require("./providers/sync");
|
||||
const settings_1 = require("./settings");
|
||||
exports.Settings = settings_1.default;
|
||||
function scandir(path, optionsOrSettingsOrCallback, callback) {
|
||||
if (typeof optionsOrSettingsOrCallback === 'function') {
|
||||
async.read(path, getSettings(), optionsOrSettingsOrCallback);
|
||||
return;
|
||||
}
|
||||
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
||||
}
|
||||
exports.scandir = scandir;
|
||||
function scandirSync(path, optionsOrSettings) {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
return sync.read(path, settings);
|
||||
}
|
||||
exports.scandirSync = scandirSync;
|
||||
function getSettings(settingsOrOptions = {}) {
|
||||
if (settingsOrOptions instanceof settings_1.default) {
|
||||
return settingsOrOptions;
|
||||
}
|
||||
return new settings_1.default(settingsOrOptions);
|
||||
}
|
||||
7
web/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts
generated
vendored
Normal file
7
web/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
import type Settings from '../settings';
|
||||
import type { Entry } from '../types';
|
||||
export declare type AsyncCallback = (error: NodeJS.ErrnoException, entries: Entry[]) => void;
|
||||
export declare function read(directory: string, settings: Settings, callback: AsyncCallback): void;
|
||||
export declare function readdirWithFileTypes(directory: string, settings: Settings, callback: AsyncCallback): void;
|
||||
export declare function readdir(directory: string, settings: Settings, callback: AsyncCallback): void;
|
||||
104
web/node_modules/@nodelib/fs.scandir/out/providers/async.js
generated
vendored
Normal file
104
web/node_modules/@nodelib/fs.scandir/out/providers/async.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
|
||||
const fsStat = require("@nodelib/fs.stat");
|
||||
const rpl = require("run-parallel");
|
||||
const constants_1 = require("../constants");
|
||||
const utils = require("../utils");
|
||||
const common = require("./common");
|
||||
function read(directory, settings, callback) {
|
||||
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
||||
readdirWithFileTypes(directory, settings, callback);
|
||||
return;
|
||||
}
|
||||
readdir(directory, settings, callback);
|
||||
}
|
||||
exports.read = read;
|
||||
function readdirWithFileTypes(directory, settings, callback) {
|
||||
settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => {
|
||||
if (readdirError !== null) {
|
||||
callFailureCallback(callback, readdirError);
|
||||
return;
|
||||
}
|
||||
const entries = dirents.map((dirent) => ({
|
||||
dirent,
|
||||
name: dirent.name,
|
||||
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
|
||||
}));
|
||||
if (!settings.followSymbolicLinks) {
|
||||
callSuccessCallback(callback, entries);
|
||||
return;
|
||||
}
|
||||
const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings));
|
||||
rpl(tasks, (rplError, rplEntries) => {
|
||||
if (rplError !== null) {
|
||||
callFailureCallback(callback, rplError);
|
||||
return;
|
||||
}
|
||||
callSuccessCallback(callback, rplEntries);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.readdirWithFileTypes = readdirWithFileTypes;
|
||||
function makeRplTaskEntry(entry, settings) {
|
||||
return (done) => {
|
||||
if (!entry.dirent.isSymbolicLink()) {
|
||||
done(null, entry);
|
||||
return;
|
||||
}
|
||||
settings.fs.stat(entry.path, (statError, stats) => {
|
||||
if (statError !== null) {
|
||||
if (settings.throwErrorOnBrokenSymbolicLink) {
|
||||
done(statError);
|
||||
return;
|
||||
}
|
||||
done(null, entry);
|
||||
return;
|
||||
}
|
||||
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
|
||||
done(null, entry);
|
||||
});
|
||||
};
|
||||
}
|
||||
function readdir(directory, settings, callback) {
|
||||
settings.fs.readdir(directory, (readdirError, names) => {
|
||||
if (readdirError !== null) {
|
||||
callFailureCallback(callback, readdirError);
|
||||
return;
|
||||
}
|
||||
const tasks = names.map((name) => {
|
||||
const path = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
||||
return (done) => {
|
||||
fsStat.stat(path, settings.fsStatSettings, (error, stats) => {
|
||||
if (error !== null) {
|
||||
done(error);
|
||||
return;
|
||||
}
|
||||
const entry = {
|
||||
name,
|
||||
path,
|
||||
dirent: utils.fs.createDirentFromStats(name, stats)
|
||||
};
|
||||
if (settings.stats) {
|
||||
entry.stats = stats;
|
||||
}
|
||||
done(null, entry);
|
||||
});
|
||||
};
|
||||
});
|
||||
rpl(tasks, (rplError, entries) => {
|
||||
if (rplError !== null) {
|
||||
callFailureCallback(callback, rplError);
|
||||
return;
|
||||
}
|
||||
callSuccessCallback(callback, entries);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.readdir = readdir;
|
||||
function callFailureCallback(callback, error) {
|
||||
callback(error);
|
||||
}
|
||||
function callSuccessCallback(callback, result) {
|
||||
callback(null, result);
|
||||
}
|
||||
1
web/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts
generated
vendored
Normal file
1
web/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function joinPathSegments(a: string, b: string, separator: string): string;
|
||||
13
web/node_modules/@nodelib/fs.scandir/out/providers/common.js
generated
vendored
Normal file
13
web/node_modules/@nodelib/fs.scandir/out/providers/common.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.joinPathSegments = void 0;
|
||||
function joinPathSegments(a, b, separator) {
|
||||
/**
|
||||
* The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
|
||||
*/
|
||||
if (a.endsWith(separator)) {
|
||||
return a + b;
|
||||
}
|
||||
return a + separator + b;
|
||||
}
|
||||
exports.joinPathSegments = joinPathSegments;
|
||||
5
web/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts
generated
vendored
Normal file
5
web/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type Settings from '../settings';
|
||||
import type { Entry } from '../types';
|
||||
export declare function read(directory: string, settings: Settings): Entry[];
|
||||
export declare function readdirWithFileTypes(directory: string, settings: Settings): Entry[];
|
||||
export declare function readdir(directory: string, settings: Settings): Entry[];
|
||||
54
web/node_modules/@nodelib/fs.scandir/out/providers/sync.js
generated
vendored
Normal file
54
web/node_modules/@nodelib/fs.scandir/out/providers/sync.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
|
||||
const fsStat = require("@nodelib/fs.stat");
|
||||
const constants_1 = require("../constants");
|
||||
const utils = require("../utils");
|
||||
const common = require("./common");
|
||||
function read(directory, settings) {
|
||||
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
|
||||
return readdirWithFileTypes(directory, settings);
|
||||
}
|
||||
return readdir(directory, settings);
|
||||
}
|
||||
exports.read = read;
|
||||
function readdirWithFileTypes(directory, settings) {
|
||||
const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
|
||||
return dirents.map((dirent) => {
|
||||
const entry = {
|
||||
dirent,
|
||||
name: dirent.name,
|
||||
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
|
||||
};
|
||||
if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
|
||||
try {
|
||||
const stats = settings.fs.statSync(entry.path);
|
||||
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
|
||||
}
|
||||
catch (error) {
|
||||
if (settings.throwErrorOnBrokenSymbolicLink) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
exports.readdirWithFileTypes = readdirWithFileTypes;
|
||||
function readdir(directory, settings) {
|
||||
const names = settings.fs.readdirSync(directory);
|
||||
return names.map((name) => {
|
||||
const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
||||
const stats = fsStat.statSync(entryPath, settings.fsStatSettings);
|
||||
const entry = {
|
||||
name,
|
||||
path: entryPath,
|
||||
dirent: utils.fs.createDirentFromStats(name, stats)
|
||||
};
|
||||
if (settings.stats) {
|
||||
entry.stats = stats;
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
exports.readdir = readdir;
|
||||
20
web/node_modules/@nodelib/fs.scandir/out/settings.d.ts
generated
vendored
Normal file
20
web/node_modules/@nodelib/fs.scandir/out/settings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as fsStat from '@nodelib/fs.stat';
|
||||
import * as fs from './adapters/fs';
|
||||
export interface Options {
|
||||
followSymbolicLinks?: boolean;
|
||||
fs?: Partial<fs.FileSystemAdapter>;
|
||||
pathSegmentSeparator?: string;
|
||||
stats?: boolean;
|
||||
throwErrorOnBrokenSymbolicLink?: boolean;
|
||||
}
|
||||
export default class Settings {
|
||||
private readonly _options;
|
||||
readonly followSymbolicLinks: boolean;
|
||||
readonly fs: fs.FileSystemAdapter;
|
||||
readonly pathSegmentSeparator: string;
|
||||
readonly stats: boolean;
|
||||
readonly throwErrorOnBrokenSymbolicLink: boolean;
|
||||
readonly fsStatSettings: fsStat.Settings;
|
||||
constructor(_options?: Options);
|
||||
private _getValue;
|
||||
}
|
||||
24
web/node_modules/@nodelib/fs.scandir/out/settings.js
generated
vendored
Normal file
24
web/node_modules/@nodelib/fs.scandir/out/settings.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path = require("path");
|
||||
const fsStat = require("@nodelib/fs.stat");
|
||||
const fs = require("./adapters/fs");
|
||||
class Settings {
|
||||
constructor(_options = {}) {
|
||||
this._options = _options;
|
||||
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
||||
this.fs = fs.createFileSystemAdapter(this._options.fs);
|
||||
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep);
|
||||
this.stats = this._getValue(this._options.stats, false);
|
||||
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
||||
this.fsStatSettings = new fsStat.Settings({
|
||||
followSymbolicLink: this.followSymbolicLinks,
|
||||
fs: this.fs,
|
||||
throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
|
||||
});
|
||||
}
|
||||
_getValue(option, value) {
|
||||
return option !== null && option !== void 0 ? option : value;
|
||||
}
|
||||
}
|
||||
exports.default = Settings;
|
||||
20
web/node_modules/@nodelib/fs.scandir/out/types/index.d.ts
generated
vendored
Normal file
20
web/node_modules/@nodelib/fs.scandir/out/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference types="node" />
|
||||
import type * as fs from 'fs';
|
||||
export interface Entry {
|
||||
dirent: Dirent;
|
||||
name: string;
|
||||
path: string;
|
||||
stats?: Stats;
|
||||
}
|
||||
export declare type Stats = fs.Stats;
|
||||
export declare type ErrnoException = NodeJS.ErrnoException;
|
||||
export interface Dirent {
|
||||
isBlockDevice: () => boolean;
|
||||
isCharacterDevice: () => boolean;
|
||||
isDirectory: () => boolean;
|
||||
isFIFO: () => boolean;
|
||||
isFile: () => boolean;
|
||||
isSocket: () => boolean;
|
||||
isSymbolicLink: () => boolean;
|
||||
name: string;
|
||||
}
|
||||
2
web/node_modules/@nodelib/fs.scandir/out/types/index.js
generated
vendored
Normal file
2
web/node_modules/@nodelib/fs.scandir/out/types/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
2
web/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts
generated
vendored
Normal file
2
web/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { Dirent, Stats } from '../types';
|
||||
export declare function createDirentFromStats(name: string, stats: Stats): Dirent;
|
||||
19
web/node_modules/@nodelib/fs.scandir/out/utils/fs.js
generated
vendored
Normal file
19
web/node_modules/@nodelib/fs.scandir/out/utils/fs.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createDirentFromStats = void 0;
|
||||
class DirentFromStats {
|
||||
constructor(name, stats) {
|
||||
this.name = name;
|
||||
this.isBlockDevice = stats.isBlockDevice.bind(stats);
|
||||
this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
|
||||
this.isDirectory = stats.isDirectory.bind(stats);
|
||||
this.isFIFO = stats.isFIFO.bind(stats);
|
||||
this.isFile = stats.isFile.bind(stats);
|
||||
this.isSocket = stats.isSocket.bind(stats);
|
||||
this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
|
||||
}
|
||||
}
|
||||
function createDirentFromStats(name, stats) {
|
||||
return new DirentFromStats(name, stats);
|
||||
}
|
||||
exports.createDirentFromStats = createDirentFromStats;
|
||||
2
web/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts
generated
vendored
Normal file
2
web/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import * as fs from './fs';
|
||||
export { fs };
|
||||
5
web/node_modules/@nodelib/fs.scandir/out/utils/index.js
generated
vendored
Normal file
5
web/node_modules/@nodelib/fs.scandir/out/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fs = void 0;
|
||||
const fs = require("./fs");
|
||||
exports.fs = fs;
|
||||
44
web/node_modules/@nodelib/fs.scandir/package.json
generated
vendored
Normal file
44
web/node_modules/@nodelib/fs.scandir/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@nodelib/fs.scandir",
|
||||
"version": "2.1.5",
|
||||
"description": "List files and directories inside the specified directory",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir",
|
||||
"keywords": [
|
||||
"NodeLib",
|
||||
"fs",
|
||||
"FileSystem",
|
||||
"file system",
|
||||
"scandir",
|
||||
"readdir",
|
||||
"dirent"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
},
|
||||
"files": [
|
||||
"out/**",
|
||||
"!out/**/*.map",
|
||||
"!out/**/*.spec.*"
|
||||
],
|
||||
"main": "out/index.js",
|
||||
"typings": "out/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rimraf {tsconfig.tsbuildinfo,out}",
|
||||
"lint": "eslint \"src/**/*.ts\" --cache",
|
||||
"compile": "tsc -b .",
|
||||
"compile:watch": "tsc -p . --watch --sourceMap",
|
||||
"test": "mocha \"out/**/*.spec.js\" -s 0",
|
||||
"build": "npm run clean && npm run compile && npm run lint && npm test",
|
||||
"watch": "npm run clean && npm run compile:watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nodelib/fs.stat": "2.0.5",
|
||||
"run-parallel": "^1.1.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nodelib/fs.macchiato": "1.0.4",
|
||||
"@types/run-parallel": "^1.1.0"
|
||||
},
|
||||
"gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562"
|
||||
}
|
||||
21
web/node_modules/@nodelib/fs.stat/LICENSE
generated
vendored
Normal file
21
web/node_modules/@nodelib/fs.stat/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Denis Malinochkin
|
||||
|
||||
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.
|
||||
126
web/node_modules/@nodelib/fs.stat/README.md
generated
vendored
Normal file
126
web/node_modules/@nodelib/fs.stat/README.md
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
# @nodelib/fs.stat
|
||||
|
||||
> Get the status of a file with some features.
|
||||
|
||||
## :bulb: Highlights
|
||||
|
||||
Wrapper around standard method `fs.lstat` and `fs.stat` with some features.
|
||||
|
||||
* :beginner: Normally follows symbolic link.
|
||||
* :gear: Can safely work with broken symbolic link.
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
npm install @nodelib/fs.stat
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import * as fsStat from '@nodelib/fs.stat';
|
||||
|
||||
fsStat.stat('path', (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .stat(path, [optionsOrSettings], callback)
|
||||
|
||||
Returns an instance of `fs.Stats` class for provided path with standard callback-style.
|
||||
|
||||
```ts
|
||||
fsStat.stat('path', (error, stats) => { /* … */ });
|
||||
fsStat.stat('path', {}, (error, stats) => { /* … */ });
|
||||
fsStat.stat('path', new fsStat.Settings(), (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
### .statSync(path, [optionsOrSettings])
|
||||
|
||||
Returns an instance of `fs.Stats` class for provided path.
|
||||
|
||||
```ts
|
||||
const stats = fsStat.stat('path');
|
||||
const stats = fsStat.stat('path', {});
|
||||
const stats = fsStat.stat('path', new fsStat.Settings());
|
||||
```
|
||||
|
||||
#### path
|
||||
|
||||
* Required: `true`
|
||||
* Type: `string | Buffer | URL`
|
||||
|
||||
A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
|
||||
#### optionsOrSettings
|
||||
|
||||
* Required: `false`
|
||||
* Type: `Options | Settings`
|
||||
* Default: An instance of `Settings` class
|
||||
|
||||
An [`Options`](#options) object or an instance of [`Settings`](#settings) class.
|
||||
|
||||
> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class.
|
||||
|
||||
### Settings([options])
|
||||
|
||||
A class of full settings of the package.
|
||||
|
||||
```ts
|
||||
const settings = new fsStat.Settings({ followSymbolicLink: false });
|
||||
|
||||
const stats = fsStat.stat('path', settings);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### `followSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Follow symbolic link or not. Call `fs.stat` on symbolic link if `true`.
|
||||
|
||||
### `markSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Mark symbolic link by setting the return value of `isSymbolicLink` function to always `true` (even after `fs.stat`).
|
||||
|
||||
> :book: Can be used if you want to know what is hidden behind a symbolic link, but still continue to know that it is a symbolic link.
|
||||
|
||||
### `throwErrorOnBrokenSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`.
|
||||
|
||||
### `fs`
|
||||
|
||||
* Type: [`FileSystemAdapter`](./src/adapters/fs.ts)
|
||||
* Default: A default FS methods
|
||||
|
||||
By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own.
|
||||
|
||||
```ts
|
||||
interface FileSystemAdapter {
|
||||
lstat?: typeof fs.lstat;
|
||||
stat?: typeof fs.stat;
|
||||
lstatSync?: typeof fs.lstatSync;
|
||||
statSync?: typeof fs.statSync;
|
||||
}
|
||||
|
||||
const settings = new fsStat.Settings({
|
||||
fs: { lstat: fakeLstat }
|
||||
});
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version.
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the terms of the MIT license.
|
||||
13
web/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts
generated
vendored
Normal file
13
web/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
import type { ErrnoException } from '../types';
|
||||
export declare type StatAsynchronousMethod = (path: string, callback: (error: ErrnoException | null, stats: fs.Stats) => void) => void;
|
||||
export declare type StatSynchronousMethod = (path: string) => fs.Stats;
|
||||
export interface FileSystemAdapter {
|
||||
lstat: StatAsynchronousMethod;
|
||||
stat: StatAsynchronousMethod;
|
||||
lstatSync: StatSynchronousMethod;
|
||||
statSync: StatSynchronousMethod;
|
||||
}
|
||||
export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
|
||||
export declare function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
|
||||
17
web/node_modules/@nodelib/fs.stat/out/adapters/fs.js
generated
vendored
Normal file
17
web/node_modules/@nodelib/fs.stat/out/adapters/fs.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
||||
const fs = require("fs");
|
||||
exports.FILE_SYSTEM_ADAPTER = {
|
||||
lstat: fs.lstat,
|
||||
stat: fs.stat,
|
||||
lstatSync: fs.lstatSync,
|
||||
statSync: fs.statSync
|
||||
};
|
||||
function createFileSystemAdapter(fsMethods) {
|
||||
if (fsMethods === undefined) {
|
||||
return exports.FILE_SYSTEM_ADAPTER;
|
||||
}
|
||||
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
||||
}
|
||||
exports.createFileSystemAdapter = createFileSystemAdapter;
|
||||
12
web/node_modules/@nodelib/fs.stat/out/index.d.ts
generated
vendored
Normal file
12
web/node_modules/@nodelib/fs.stat/out/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod } from './adapters/fs';
|
||||
import * as async from './providers/async';
|
||||
import Settings, { Options } from './settings';
|
||||
import type { Stats } from './types';
|
||||
declare type AsyncCallback = async.AsyncCallback;
|
||||
declare function stat(path: string, callback: AsyncCallback): void;
|
||||
declare function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
|
||||
declare namespace stat {
|
||||
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Stats>;
|
||||
}
|
||||
declare function statSync(path: string, optionsOrSettings?: Options | Settings): Stats;
|
||||
export { Settings, stat, statSync, AsyncCallback, FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod, Options, Stats };
|
||||
26
web/node_modules/@nodelib/fs.stat/out/index.js
generated
vendored
Normal file
26
web/node_modules/@nodelib/fs.stat/out/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.statSync = exports.stat = exports.Settings = void 0;
|
||||
const async = require("./providers/async");
|
||||
const sync = require("./providers/sync");
|
||||
const settings_1 = require("./settings");
|
||||
exports.Settings = settings_1.default;
|
||||
function stat(path, optionsOrSettingsOrCallback, callback) {
|
||||
if (typeof optionsOrSettingsOrCallback === 'function') {
|
||||
async.read(path, getSettings(), optionsOrSettingsOrCallback);
|
||||
return;
|
||||
}
|
||||
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
||||
}
|
||||
exports.stat = stat;
|
||||
function statSync(path, optionsOrSettings) {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
return sync.read(path, settings);
|
||||
}
|
||||
exports.statSync = statSync;
|
||||
function getSettings(settingsOrOptions = {}) {
|
||||
if (settingsOrOptions instanceof settings_1.default) {
|
||||
return settingsOrOptions;
|
||||
}
|
||||
return new settings_1.default(settingsOrOptions);
|
||||
}
|
||||
4
web/node_modules/@nodelib/fs.stat/out/providers/async.d.ts
generated
vendored
Normal file
4
web/node_modules/@nodelib/fs.stat/out/providers/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type Settings from '../settings';
|
||||
import type { ErrnoException, Stats } from '../types';
|
||||
export declare type AsyncCallback = (error: ErrnoException, stats: Stats) => void;
|
||||
export declare function read(path: string, settings: Settings, callback: AsyncCallback): void;
|
||||
36
web/node_modules/@nodelib/fs.stat/out/providers/async.js
generated
vendored
Normal file
36
web/node_modules/@nodelib/fs.stat/out/providers/async.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.read = void 0;
|
||||
function read(path, settings, callback) {
|
||||
settings.fs.lstat(path, (lstatError, lstat) => {
|
||||
if (lstatError !== null) {
|
||||
callFailureCallback(callback, lstatError);
|
||||
return;
|
||||
}
|
||||
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
||||
callSuccessCallback(callback, lstat);
|
||||
return;
|
||||
}
|
||||
settings.fs.stat(path, (statError, stat) => {
|
||||
if (statError !== null) {
|
||||
if (settings.throwErrorOnBrokenSymbolicLink) {
|
||||
callFailureCallback(callback, statError);
|
||||
return;
|
||||
}
|
||||
callSuccessCallback(callback, lstat);
|
||||
return;
|
||||
}
|
||||
if (settings.markSymbolicLink) {
|
||||
stat.isSymbolicLink = () => true;
|
||||
}
|
||||
callSuccessCallback(callback, stat);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.read = read;
|
||||
function callFailureCallback(callback, error) {
|
||||
callback(error);
|
||||
}
|
||||
function callSuccessCallback(callback, result) {
|
||||
callback(null, result);
|
||||
}
|
||||
3
web/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts
generated
vendored
Normal file
3
web/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type Settings from '../settings';
|
||||
import type { Stats } from '../types';
|
||||
export declare function read(path: string, settings: Settings): Stats;
|
||||
23
web/node_modules/@nodelib/fs.stat/out/providers/sync.js
generated
vendored
Normal file
23
web/node_modules/@nodelib/fs.stat/out/providers/sync.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.read = void 0;
|
||||
function read(path, settings) {
|
||||
const lstat = settings.fs.lstatSync(path);
|
||||
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
||||
return lstat;
|
||||
}
|
||||
try {
|
||||
const stat = settings.fs.statSync(path);
|
||||
if (settings.markSymbolicLink) {
|
||||
stat.isSymbolicLink = () => true;
|
||||
}
|
||||
return stat;
|
||||
}
|
||||
catch (error) {
|
||||
if (!settings.throwErrorOnBrokenSymbolicLink) {
|
||||
return lstat;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
exports.read = read;
|
||||
16
web/node_modules/@nodelib/fs.stat/out/settings.d.ts
generated
vendored
Normal file
16
web/node_modules/@nodelib/fs.stat/out/settings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as fs from './adapters/fs';
|
||||
export interface Options {
|
||||
followSymbolicLink?: boolean;
|
||||
fs?: Partial<fs.FileSystemAdapter>;
|
||||
markSymbolicLink?: boolean;
|
||||
throwErrorOnBrokenSymbolicLink?: boolean;
|
||||
}
|
||||
export default class Settings {
|
||||
private readonly _options;
|
||||
readonly followSymbolicLink: boolean;
|
||||
readonly fs: fs.FileSystemAdapter;
|
||||
readonly markSymbolicLink: boolean;
|
||||
readonly throwErrorOnBrokenSymbolicLink: boolean;
|
||||
constructor(_options?: Options);
|
||||
private _getValue;
|
||||
}
|
||||
16
web/node_modules/@nodelib/fs.stat/out/settings.js
generated
vendored
Normal file
16
web/node_modules/@nodelib/fs.stat/out/settings.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("./adapters/fs");
|
||||
class Settings {
|
||||
constructor(_options = {}) {
|
||||
this._options = _options;
|
||||
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
||||
this.fs = fs.createFileSystemAdapter(this._options.fs);
|
||||
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
||||
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
||||
}
|
||||
_getValue(option, value) {
|
||||
return option !== null && option !== void 0 ? option : value;
|
||||
}
|
||||
}
|
||||
exports.default = Settings;
|
||||
4
web/node_modules/@nodelib/fs.stat/out/types/index.d.ts
generated
vendored
Normal file
4
web/node_modules/@nodelib/fs.stat/out/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/// <reference types="node" />
|
||||
import type * as fs from 'fs';
|
||||
export declare type Stats = fs.Stats;
|
||||
export declare type ErrnoException = NodeJS.ErrnoException;
|
||||
2
web/node_modules/@nodelib/fs.stat/out/types/index.js
generated
vendored
Normal file
2
web/node_modules/@nodelib/fs.stat/out/types/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
37
web/node_modules/@nodelib/fs.stat/package.json
generated
vendored
Normal file
37
web/node_modules/@nodelib/fs.stat/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@nodelib/fs.stat",
|
||||
"version": "2.0.5",
|
||||
"description": "Get the status of a file with some features",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat",
|
||||
"keywords": [
|
||||
"NodeLib",
|
||||
"fs",
|
||||
"FileSystem",
|
||||
"file system",
|
||||
"stat"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
},
|
||||
"files": [
|
||||
"out/**",
|
||||
"!out/**/*.map",
|
||||
"!out/**/*.spec.*"
|
||||
],
|
||||
"main": "out/index.js",
|
||||
"typings": "out/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rimraf {tsconfig.tsbuildinfo,out}",
|
||||
"lint": "eslint \"src/**/*.ts\" --cache",
|
||||
"compile": "tsc -b .",
|
||||
"compile:watch": "tsc -p . --watch --sourceMap",
|
||||
"test": "mocha \"out/**/*.spec.js\" -s 0",
|
||||
"build": "npm run clean && npm run compile && npm run lint && npm test",
|
||||
"watch": "npm run clean && npm run compile:watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nodelib/fs.macchiato": "1.0.4"
|
||||
},
|
||||
"gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562"
|
||||
}
|
||||
21
web/node_modules/@nodelib/fs.walk/LICENSE
generated
vendored
Normal file
21
web/node_modules/@nodelib/fs.walk/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Denis Malinochkin
|
||||
|
||||
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.
|
||||
215
web/node_modules/@nodelib/fs.walk/README.md
generated
vendored
Normal file
215
web/node_modules/@nodelib/fs.walk/README.md
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
# @nodelib/fs.walk
|
||||
|
||||
> A library for efficiently walking a directory recursively.
|
||||
|
||||
## :bulb: Highlights
|
||||
|
||||
* :moneybag: Returns useful information: `name`, `path`, `dirent` and `stats` (optional).
|
||||
* :rocket: On Node.js 10.10+ uses the mechanism without additional calls to determine the entry type for performance reasons. See [`old` and `modern` mode](https://github.com/nodelib/nodelib/blob/master/packages/fs/fs.scandir/README.md#old-and-modern-mode).
|
||||
* :gear: Built-in directories/files and error filtering system.
|
||||
* :link: Can safely work with broken symbolic links.
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
npm install @nodelib/fs.walk
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import * as fsWalk from '@nodelib/fs.walk';
|
||||
|
||||
fsWalk.walk('path', (error, entries) => { /* … */ });
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .walk(path, [optionsOrSettings], callback)
|
||||
|
||||
Reads the directory recursively and asynchronously. Requires a callback function.
|
||||
|
||||
> :book: If you want to use the Promise API, use `util.promisify`.
|
||||
|
||||
```ts
|
||||
fsWalk.walk('path', (error, entries) => { /* … */ });
|
||||
fsWalk.walk('path', {}, (error, entries) => { /* … */ });
|
||||
fsWalk.walk('path', new fsWalk.Settings(), (error, entries) => { /* … */ });
|
||||
```
|
||||
|
||||
### .walkStream(path, [optionsOrSettings])
|
||||
|
||||
Reads the directory recursively and asynchronously. [Readable Stream](https://nodejs.org/dist/latest-v12.x/docs/api/stream.html#stream_readable_streams) is used as a provider.
|
||||
|
||||
```ts
|
||||
const stream = fsWalk.walkStream('path');
|
||||
const stream = fsWalk.walkStream('path', {});
|
||||
const stream = fsWalk.walkStream('path', new fsWalk.Settings());
|
||||
```
|
||||
|
||||
### .walkSync(path, [optionsOrSettings])
|
||||
|
||||
Reads the directory recursively and synchronously. Returns an array of entries.
|
||||
|
||||
```ts
|
||||
const entries = fsWalk.walkSync('path');
|
||||
const entries = fsWalk.walkSync('path', {});
|
||||
const entries = fsWalk.walkSync('path', new fsWalk.Settings());
|
||||
```
|
||||
|
||||
#### path
|
||||
|
||||
* Required: `true`
|
||||
* Type: `string | Buffer | URL`
|
||||
|
||||
A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
|
||||
#### optionsOrSettings
|
||||
|
||||
* Required: `false`
|
||||
* Type: `Options | Settings`
|
||||
* Default: An instance of `Settings` class
|
||||
|
||||
An [`Options`](#options) object or an instance of [`Settings`](#settings) class.
|
||||
|
||||
> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class.
|
||||
|
||||
### Settings([options])
|
||||
|
||||
A class of full settings of the package.
|
||||
|
||||
```ts
|
||||
const settings = new fsWalk.Settings({ followSymbolicLinks: true });
|
||||
|
||||
const entries = fsWalk.walkSync('path', settings);
|
||||
```
|
||||
|
||||
## Entry
|
||||
|
||||
* `name` — The name of the entry (`unknown.txt`).
|
||||
* `path` — The path of the entry relative to call directory (`root/unknown.txt`).
|
||||
* `dirent` — An instance of [`fs.Dirent`](./src/types/index.ts) class.
|
||||
* [`stats`] — An instance of `fs.Stats` class.
|
||||
|
||||
## Options
|
||||
|
||||
### basePath
|
||||
|
||||
* Type: `string`
|
||||
* Default: `undefined`
|
||||
|
||||
By default, all paths are built relative to the root path. You can use this option to set custom root path.
|
||||
|
||||
In the example below we read the files from the `root` directory, but in the results the root path will be `custom`.
|
||||
|
||||
```ts
|
||||
fsWalk.walkSync('root'); // → ['root/file.txt']
|
||||
fsWalk.walkSync('root', { basePath: 'custom' }); // → ['custom/file.txt']
|
||||
```
|
||||
|
||||
### concurrency
|
||||
|
||||
* Type: `number`
|
||||
* Default: `Infinity`
|
||||
|
||||
The maximum number of concurrent calls to `fs.readdir`.
|
||||
|
||||
> :book: The higher the number, the higher performance and the load on the File System. If you want to read in quiet mode, set the value to `4 * os.cpus().length` (4 is default size of [thread pool work scheduling](http://docs.libuv.org/en/v1.x/threadpool.html#thread-pool-work-scheduling)).
|
||||
|
||||
### deepFilter
|
||||
|
||||
* Type: [`DeepFilterFunction`](./src/settings.ts)
|
||||
* Default: `undefined`
|
||||
|
||||
A function that indicates whether the directory will be read deep or not.
|
||||
|
||||
```ts
|
||||
// Skip all directories that starts with `node_modules`
|
||||
const filter: DeepFilterFunction = (entry) => !entry.path.startsWith('node_modules');
|
||||
```
|
||||
|
||||
### entryFilter
|
||||
|
||||
* Type: [`EntryFilterFunction`](./src/settings.ts)
|
||||
* Default: `undefined`
|
||||
|
||||
A function that indicates whether the entry will be included to results or not.
|
||||
|
||||
```ts
|
||||
// Exclude all `.js` files from results
|
||||
const filter: EntryFilterFunction = (entry) => !entry.name.endsWith('.js');
|
||||
```
|
||||
|
||||
### errorFilter
|
||||
|
||||
* Type: [`ErrorFilterFunction`](./src/settings.ts)
|
||||
* Default: `undefined`
|
||||
|
||||
A function that allows you to skip errors that occur when reading directories.
|
||||
|
||||
For example, you can skip `ENOENT` errors if required:
|
||||
|
||||
```ts
|
||||
// Skip all ENOENT errors
|
||||
const filter: ErrorFilterFunction = (error) => error.code == 'ENOENT';
|
||||
```
|
||||
|
||||
### stats
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Adds an instance of `fs.Stats` class to the [`Entry`](#entry).
|
||||
|
||||
> :book: Always use `fs.readdir` with additional `fs.lstat/fs.stat` calls to determine the entry type.
|
||||
|
||||
### followSymbolicLinks
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Follow symbolic links or not. Call `fs.stat` on symbolic link if `true`.
|
||||
|
||||
### `throwErrorOnBrokenSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`.
|
||||
|
||||
### `pathSegmentSeparator`
|
||||
|
||||
* Type: `string`
|
||||
* Default: `path.sep`
|
||||
|
||||
By default, this package uses the correct path separator for your OS (`\` on Windows, `/` on Unix-like systems). But you can set this option to any separator character(s) that you want to use instead.
|
||||
|
||||
### `fs`
|
||||
|
||||
* Type: `FileSystemAdapter`
|
||||
* Default: A default FS methods
|
||||
|
||||
By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own.
|
||||
|
||||
```ts
|
||||
interface FileSystemAdapter {
|
||||
lstat: typeof fs.lstat;
|
||||
stat: typeof fs.stat;
|
||||
lstatSync: typeof fs.lstatSync;
|
||||
statSync: typeof fs.statSync;
|
||||
readdir: typeof fs.readdir;
|
||||
readdirSync: typeof fs.readdirSync;
|
||||
}
|
||||
|
||||
const settings = new fsWalk.Settings({
|
||||
fs: { lstat: fakeLstat }
|
||||
});
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version.
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the terms of the MIT license.
|
||||
14
web/node_modules/@nodelib/fs.walk/out/index.d.ts
generated
vendored
Normal file
14
web/node_modules/@nodelib/fs.walk/out/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/// <reference types="node" />
|
||||
import type { Readable } from 'stream';
|
||||
import type { Dirent, FileSystemAdapter } from '@nodelib/fs.scandir';
|
||||
import { AsyncCallback } from './providers/async';
|
||||
import Settings, { DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction, Options } from './settings';
|
||||
import type { Entry } from './types';
|
||||
declare function walk(directory: string, callback: AsyncCallback): void;
|
||||
declare function walk(directory: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
|
||||
declare namespace walk {
|
||||
function __promisify__(directory: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
|
||||
}
|
||||
declare function walkSync(directory: string, optionsOrSettings?: Options | Settings): Entry[];
|
||||
declare function walkStream(directory: string, optionsOrSettings?: Options | Settings): Readable;
|
||||
export { walk, walkSync, walkStream, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, Options, DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction };
|
||||
34
web/node_modules/@nodelib/fs.walk/out/index.js
generated
vendored
Normal file
34
web/node_modules/@nodelib/fs.walk/out/index.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0;
|
||||
const async_1 = require("./providers/async");
|
||||
const stream_1 = require("./providers/stream");
|
||||
const sync_1 = require("./providers/sync");
|
||||
const settings_1 = require("./settings");
|
||||
exports.Settings = settings_1.default;
|
||||
function walk(directory, optionsOrSettingsOrCallback, callback) {
|
||||
if (typeof optionsOrSettingsOrCallback === 'function') {
|
||||
new async_1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
|
||||
return;
|
||||
}
|
||||
new async_1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
|
||||
}
|
||||
exports.walk = walk;
|
||||
function walkSync(directory, optionsOrSettings) {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
const provider = new sync_1.default(directory, settings);
|
||||
return provider.read();
|
||||
}
|
||||
exports.walkSync = walkSync;
|
||||
function walkStream(directory, optionsOrSettings) {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
const provider = new stream_1.default(directory, settings);
|
||||
return provider.read();
|
||||
}
|
||||
exports.walkStream = walkStream;
|
||||
function getSettings(settingsOrOptions = {}) {
|
||||
if (settingsOrOptions instanceof settings_1.default) {
|
||||
return settingsOrOptions;
|
||||
}
|
||||
return new settings_1.default(settingsOrOptions);
|
||||
}
|
||||
12
web/node_modules/@nodelib/fs.walk/out/providers/async.d.ts
generated
vendored
Normal file
12
web/node_modules/@nodelib/fs.walk/out/providers/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import AsyncReader from '../readers/async';
|
||||
import type Settings from '../settings';
|
||||
import type { Entry, Errno } from '../types';
|
||||
export declare type AsyncCallback = (error: Errno, entries: Entry[]) => void;
|
||||
export default class AsyncProvider {
|
||||
private readonly _root;
|
||||
private readonly _settings;
|
||||
protected readonly _reader: AsyncReader;
|
||||
private readonly _storage;
|
||||
constructor(_root: string, _settings: Settings);
|
||||
read(callback: AsyncCallback): void;
|
||||
}
|
||||
30
web/node_modules/@nodelib/fs.walk/out/providers/async.js
generated
vendored
Normal file
30
web/node_modules/@nodelib/fs.walk/out/providers/async.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const async_1 = require("../readers/async");
|
||||
class AsyncProvider {
|
||||
constructor(_root, _settings) {
|
||||
this._root = _root;
|
||||
this._settings = _settings;
|
||||
this._reader = new async_1.default(this._root, this._settings);
|
||||
this._storage = [];
|
||||
}
|
||||
read(callback) {
|
||||
this._reader.onError((error) => {
|
||||
callFailureCallback(callback, error);
|
||||
});
|
||||
this._reader.onEntry((entry) => {
|
||||
this._storage.push(entry);
|
||||
});
|
||||
this._reader.onEnd(() => {
|
||||
callSuccessCallback(callback, this._storage);
|
||||
});
|
||||
this._reader.read();
|
||||
}
|
||||
}
|
||||
exports.default = AsyncProvider;
|
||||
function callFailureCallback(callback, error) {
|
||||
callback(error);
|
||||
}
|
||||
function callSuccessCallback(callback, entries) {
|
||||
callback(null, entries);
|
||||
}
|
||||
4
web/node_modules/@nodelib/fs.walk/out/providers/index.d.ts
generated
vendored
Normal file
4
web/node_modules/@nodelib/fs.walk/out/providers/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import AsyncProvider from './async';
|
||||
import StreamProvider from './stream';
|
||||
import SyncProvider from './sync';
|
||||
export { AsyncProvider, StreamProvider, SyncProvider };
|
||||
9
web/node_modules/@nodelib/fs.walk/out/providers/index.js
generated
vendored
Normal file
9
web/node_modules/@nodelib/fs.walk/out/providers/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SyncProvider = exports.StreamProvider = exports.AsyncProvider = void 0;
|
||||
const async_1 = require("./async");
|
||||
exports.AsyncProvider = async_1.default;
|
||||
const stream_1 = require("./stream");
|
||||
exports.StreamProvider = stream_1.default;
|
||||
const sync_1 = require("./sync");
|
||||
exports.SyncProvider = sync_1.default;
|
||||
12
web/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts
generated
vendored
Normal file
12
web/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference types="node" />
|
||||
import { Readable } from 'stream';
|
||||
import AsyncReader from '../readers/async';
|
||||
import type Settings from '../settings';
|
||||
export default class StreamProvider {
|
||||
private readonly _root;
|
||||
private readonly _settings;
|
||||
protected readonly _reader: AsyncReader;
|
||||
protected readonly _stream: Readable;
|
||||
constructor(_root: string, _settings: Settings);
|
||||
read(): Readable;
|
||||
}
|
||||
34
web/node_modules/@nodelib/fs.walk/out/providers/stream.js
generated
vendored
Normal file
34
web/node_modules/@nodelib/fs.walk/out/providers/stream.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const stream_1 = require("stream");
|
||||
const async_1 = require("../readers/async");
|
||||
class StreamProvider {
|
||||
constructor(_root, _settings) {
|
||||
this._root = _root;
|
||||
this._settings = _settings;
|
||||
this._reader = new async_1.default(this._root, this._settings);
|
||||
this._stream = new stream_1.Readable({
|
||||
objectMode: true,
|
||||
read: () => { },
|
||||
destroy: () => {
|
||||
if (!this._reader.isDestroyed) {
|
||||
this._reader.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
read() {
|
||||
this._reader.onError((error) => {
|
||||
this._stream.emit('error', error);
|
||||
});
|
||||
this._reader.onEntry((entry) => {
|
||||
this._stream.push(entry);
|
||||
});
|
||||
this._reader.onEnd(() => {
|
||||
this._stream.push(null);
|
||||
});
|
||||
this._reader.read();
|
||||
return this._stream;
|
||||
}
|
||||
}
|
||||
exports.default = StreamProvider;
|
||||
10
web/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts
generated
vendored
Normal file
10
web/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import SyncReader from '../readers/sync';
|
||||
import type Settings from '../settings';
|
||||
import type { Entry } from '../types';
|
||||
export default class SyncProvider {
|
||||
private readonly _root;
|
||||
private readonly _settings;
|
||||
protected readonly _reader: SyncReader;
|
||||
constructor(_root: string, _settings: Settings);
|
||||
read(): Entry[];
|
||||
}
|
||||
14
web/node_modules/@nodelib/fs.walk/out/providers/sync.js
generated
vendored
Normal file
14
web/node_modules/@nodelib/fs.walk/out/providers/sync.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const sync_1 = require("../readers/sync");
|
||||
class SyncProvider {
|
||||
constructor(_root, _settings) {
|
||||
this._root = _root;
|
||||
this._settings = _settings;
|
||||
this._reader = new sync_1.default(this._root, this._settings);
|
||||
}
|
||||
read() {
|
||||
return this._reader.read();
|
||||
}
|
||||
}
|
||||
exports.default = SyncProvider;
|
||||
30
web/node_modules/@nodelib/fs.walk/out/readers/async.d.ts
generated
vendored
Normal file
30
web/node_modules/@nodelib/fs.walk/out/readers/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import * as fsScandir from '@nodelib/fs.scandir';
|
||||
import type Settings from '../settings';
|
||||
import type { Entry, Errno } from '../types';
|
||||
import Reader from './reader';
|
||||
declare type EntryEventCallback = (entry: Entry) => void;
|
||||
declare type ErrorEventCallback = (error: Errno) => void;
|
||||
declare type EndEventCallback = () => void;
|
||||
export default class AsyncReader extends Reader {
|
||||
protected readonly _settings: Settings;
|
||||
protected readonly _scandir: typeof fsScandir.scandir;
|
||||
protected readonly _emitter: EventEmitter;
|
||||
private readonly _queue;
|
||||
private _isFatalError;
|
||||
private _isDestroyed;
|
||||
constructor(_root: string, _settings: Settings);
|
||||
read(): EventEmitter;
|
||||
get isDestroyed(): boolean;
|
||||
destroy(): void;
|
||||
onEntry(callback: EntryEventCallback): void;
|
||||
onError(callback: ErrorEventCallback): void;
|
||||
onEnd(callback: EndEventCallback): void;
|
||||
private _pushToQueue;
|
||||
private _worker;
|
||||
private _handleError;
|
||||
private _handleEntry;
|
||||
private _emitEntry;
|
||||
}
|
||||
export {};
|
||||
97
web/node_modules/@nodelib/fs.walk/out/readers/async.js
generated
vendored
Normal file
97
web/node_modules/@nodelib/fs.walk/out/readers/async.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const events_1 = require("events");
|
||||
const fsScandir = require("@nodelib/fs.scandir");
|
||||
const fastq = require("fastq");
|
||||
const common = require("./common");
|
||||
const reader_1 = require("./reader");
|
||||
class AsyncReader extends reader_1.default {
|
||||
constructor(_root, _settings) {
|
||||
super(_root, _settings);
|
||||
this._settings = _settings;
|
||||
this._scandir = fsScandir.scandir;
|
||||
this._emitter = new events_1.EventEmitter();
|
||||
this._queue = fastq(this._worker.bind(this), this._settings.concurrency);
|
||||
this._isFatalError = false;
|
||||
this._isDestroyed = false;
|
||||
this._queue.drain = () => {
|
||||
if (!this._isFatalError) {
|
||||
this._emitter.emit('end');
|
||||
}
|
||||
};
|
||||
}
|
||||
read() {
|
||||
this._isFatalError = false;
|
||||
this._isDestroyed = false;
|
||||
setImmediate(() => {
|
||||
this._pushToQueue(this._root, this._settings.basePath);
|
||||
});
|
||||
return this._emitter;
|
||||
}
|
||||
get isDestroyed() {
|
||||
return this._isDestroyed;
|
||||
}
|
||||
destroy() {
|
||||
if (this._isDestroyed) {
|
||||
throw new Error('The reader is already destroyed');
|
||||
}
|
||||
this._isDestroyed = true;
|
||||
this._queue.killAndDrain();
|
||||
}
|
||||
onEntry(callback) {
|
||||
this._emitter.on('entry', callback);
|
||||
}
|
||||
onError(callback) {
|
||||
this._emitter.once('error', callback);
|
||||
}
|
||||
onEnd(callback) {
|
||||
this._emitter.once('end', callback);
|
||||
}
|
||||
_pushToQueue(directory, base) {
|
||||
const queueItem = { directory, base };
|
||||
this._queue.push(queueItem, (error) => {
|
||||
if (error !== null) {
|
||||
this._handleError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
_worker(item, done) {
|
||||
this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
|
||||
if (error !== null) {
|
||||
done(error, undefined);
|
||||
return;
|
||||
}
|
||||
for (const entry of entries) {
|
||||
this._handleEntry(entry, item.base);
|
||||
}
|
||||
done(null, undefined);
|
||||
});
|
||||
}
|
||||
_handleError(error) {
|
||||
if (this._isDestroyed || !common.isFatalError(this._settings, error)) {
|
||||
return;
|
||||
}
|
||||
this._isFatalError = true;
|
||||
this._isDestroyed = true;
|
||||
this._emitter.emit('error', error);
|
||||
}
|
||||
_handleEntry(entry, base) {
|
||||
if (this._isDestroyed || this._isFatalError) {
|
||||
return;
|
||||
}
|
||||
const fullpath = entry.path;
|
||||
if (base !== undefined) {
|
||||
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
|
||||
}
|
||||
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
|
||||
this._emitEntry(entry);
|
||||
}
|
||||
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
|
||||
this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
|
||||
}
|
||||
}
|
||||
_emitEntry(entry) {
|
||||
this._emitter.emit('entry', entry);
|
||||
}
|
||||
}
|
||||
exports.default = AsyncReader;
|
||||
7
web/node_modules/@nodelib/fs.walk/out/readers/common.d.ts
generated
vendored
Normal file
7
web/node_modules/@nodelib/fs.walk/out/readers/common.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { FilterFunction } from '../settings';
|
||||
import type Settings from '../settings';
|
||||
import type { Errno } from '../types';
|
||||
export declare function isFatalError(settings: Settings, error: Errno): boolean;
|
||||
export declare function isAppliedFilter<T>(filter: FilterFunction<T> | null, value: T): boolean;
|
||||
export declare function replacePathSegmentSeparator(filepath: string, separator: string): string;
|
||||
export declare function joinPathSegments(a: string, b: string, separator: string): string;
|
||||
31
web/node_modules/@nodelib/fs.walk/out/readers/common.js
generated
vendored
Normal file
31
web/node_modules/@nodelib/fs.walk/out/readers/common.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0;
|
||||
function isFatalError(settings, error) {
|
||||
if (settings.errorFilter === null) {
|
||||
return true;
|
||||
}
|
||||
return !settings.errorFilter(error);
|
||||
}
|
||||
exports.isFatalError = isFatalError;
|
||||
function isAppliedFilter(filter, value) {
|
||||
return filter === null || filter(value);
|
||||
}
|
||||
exports.isAppliedFilter = isAppliedFilter;
|
||||
function replacePathSegmentSeparator(filepath, separator) {
|
||||
return filepath.split(/[/\\]/).join(separator);
|
||||
}
|
||||
exports.replacePathSegmentSeparator = replacePathSegmentSeparator;
|
||||
function joinPathSegments(a, b, separator) {
|
||||
if (a === '') {
|
||||
return b;
|
||||
}
|
||||
/**
|
||||
* The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
|
||||
*/
|
||||
if (a.endsWith(separator)) {
|
||||
return a + b;
|
||||
}
|
||||
return a + separator + b;
|
||||
}
|
||||
exports.joinPathSegments = joinPathSegments;
|
||||
6
web/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts
generated
vendored
Normal file
6
web/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type Settings from '../settings';
|
||||
export default class Reader {
|
||||
protected readonly _root: string;
|
||||
protected readonly _settings: Settings;
|
||||
constructor(_root: string, _settings: Settings);
|
||||
}
|
||||
11
web/node_modules/@nodelib/fs.walk/out/readers/reader.js
generated
vendored
Normal file
11
web/node_modules/@nodelib/fs.walk/out/readers/reader.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common = require("./common");
|
||||
class Reader {
|
||||
constructor(_root, _settings) {
|
||||
this._root = _root;
|
||||
this._settings = _settings;
|
||||
this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
|
||||
}
|
||||
}
|
||||
exports.default = Reader;
|
||||
15
web/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts
generated
vendored
Normal file
15
web/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as fsScandir from '@nodelib/fs.scandir';
|
||||
import type { Entry } from '../types';
|
||||
import Reader from './reader';
|
||||
export default class SyncReader extends Reader {
|
||||
protected readonly _scandir: typeof fsScandir.scandirSync;
|
||||
private readonly _storage;
|
||||
private readonly _queue;
|
||||
read(): Entry[];
|
||||
private _pushToQueue;
|
||||
private _handleQueue;
|
||||
private _handleDirectory;
|
||||
private _handleError;
|
||||
private _handleEntry;
|
||||
private _pushToStorage;
|
||||
}
|
||||
59
web/node_modules/@nodelib/fs.walk/out/readers/sync.js
generated
vendored
Normal file
59
web/node_modules/@nodelib/fs.walk/out/readers/sync.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fsScandir = require("@nodelib/fs.scandir");
|
||||
const common = require("./common");
|
||||
const reader_1 = require("./reader");
|
||||
class SyncReader extends reader_1.default {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._scandir = fsScandir.scandirSync;
|
||||
this._storage = [];
|
||||
this._queue = new Set();
|
||||
}
|
||||
read() {
|
||||
this._pushToQueue(this._root, this._settings.basePath);
|
||||
this._handleQueue();
|
||||
return this._storage;
|
||||
}
|
||||
_pushToQueue(directory, base) {
|
||||
this._queue.add({ directory, base });
|
||||
}
|
||||
_handleQueue() {
|
||||
for (const item of this._queue.values()) {
|
||||
this._handleDirectory(item.directory, item.base);
|
||||
}
|
||||
}
|
||||
_handleDirectory(directory, base) {
|
||||
try {
|
||||
const entries = this._scandir(directory, this._settings.fsScandirSettings);
|
||||
for (const entry of entries) {
|
||||
this._handleEntry(entry, base);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this._handleError(error);
|
||||
}
|
||||
}
|
||||
_handleError(error) {
|
||||
if (!common.isFatalError(this._settings, error)) {
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
_handleEntry(entry, base) {
|
||||
const fullpath = entry.path;
|
||||
if (base !== undefined) {
|
||||
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
|
||||
}
|
||||
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
|
||||
this._pushToStorage(entry);
|
||||
}
|
||||
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
|
||||
this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
|
||||
}
|
||||
}
|
||||
_pushToStorage(entry) {
|
||||
this._storage.push(entry);
|
||||
}
|
||||
}
|
||||
exports.default = SyncReader;
|
||||
30
web/node_modules/@nodelib/fs.walk/out/settings.d.ts
generated
vendored
Normal file
30
web/node_modules/@nodelib/fs.walk/out/settings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import * as fsScandir from '@nodelib/fs.scandir';
|
||||
import type { Entry, Errno } from './types';
|
||||
export declare type FilterFunction<T> = (value: T) => boolean;
|
||||
export declare type DeepFilterFunction = FilterFunction<Entry>;
|
||||
export declare type EntryFilterFunction = FilterFunction<Entry>;
|
||||
export declare type ErrorFilterFunction = FilterFunction<Errno>;
|
||||
export interface Options {
|
||||
basePath?: string;
|
||||
concurrency?: number;
|
||||
deepFilter?: DeepFilterFunction;
|
||||
entryFilter?: EntryFilterFunction;
|
||||
errorFilter?: ErrorFilterFunction;
|
||||
followSymbolicLinks?: boolean;
|
||||
fs?: Partial<fsScandir.FileSystemAdapter>;
|
||||
pathSegmentSeparator?: string;
|
||||
stats?: boolean;
|
||||
throwErrorOnBrokenSymbolicLink?: boolean;
|
||||
}
|
||||
export default class Settings {
|
||||
private readonly _options;
|
||||
readonly basePath?: string;
|
||||
readonly concurrency: number;
|
||||
readonly deepFilter: DeepFilterFunction | null;
|
||||
readonly entryFilter: EntryFilterFunction | null;
|
||||
readonly errorFilter: ErrorFilterFunction | null;
|
||||
readonly pathSegmentSeparator: string;
|
||||
readonly fsScandirSettings: fsScandir.Settings;
|
||||
constructor(_options?: Options);
|
||||
private _getValue;
|
||||
}
|
||||
26
web/node_modules/@nodelib/fs.walk/out/settings.js
generated
vendored
Normal file
26
web/node_modules/@nodelib/fs.walk/out/settings.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path = require("path");
|
||||
const fsScandir = require("@nodelib/fs.scandir");
|
||||
class Settings {
|
||||
constructor(_options = {}) {
|
||||
this._options = _options;
|
||||
this.basePath = this._getValue(this._options.basePath, undefined);
|
||||
this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY);
|
||||
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
||||
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
||||
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
||||
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep);
|
||||
this.fsScandirSettings = new fsScandir.Settings({
|
||||
followSymbolicLinks: this._options.followSymbolicLinks,
|
||||
fs: this._options.fs,
|
||||
pathSegmentSeparator: this._options.pathSegmentSeparator,
|
||||
stats: this._options.stats,
|
||||
throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
|
||||
});
|
||||
}
|
||||
_getValue(option, value) {
|
||||
return option !== null && option !== void 0 ? option : value;
|
||||
}
|
||||
}
|
||||
exports.default = Settings;
|
||||
8
web/node_modules/@nodelib/fs.walk/out/types/index.d.ts
generated
vendored
Normal file
8
web/node_modules/@nodelib/fs.walk/out/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
import type * as scandir from '@nodelib/fs.scandir';
|
||||
export declare type Entry = scandir.Entry;
|
||||
export declare type Errno = NodeJS.ErrnoException;
|
||||
export interface QueueItem {
|
||||
directory: string;
|
||||
base?: string;
|
||||
}
|
||||
2
web/node_modules/@nodelib/fs.walk/out/types/index.js
generated
vendored
Normal file
2
web/node_modules/@nodelib/fs.walk/out/types/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
44
web/node_modules/@nodelib/fs.walk/package.json
generated
vendored
Normal file
44
web/node_modules/@nodelib/fs.walk/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@nodelib/fs.walk",
|
||||
"version": "1.2.8",
|
||||
"description": "A library for efficiently walking a directory recursively",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk",
|
||||
"keywords": [
|
||||
"NodeLib",
|
||||
"fs",
|
||||
"FileSystem",
|
||||
"file system",
|
||||
"walk",
|
||||
"scanner",
|
||||
"crawler"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
},
|
||||
"files": [
|
||||
"out/**",
|
||||
"!out/**/*.map",
|
||||
"!out/**/*.spec.*",
|
||||
"!out/**/tests/**"
|
||||
],
|
||||
"main": "out/index.js",
|
||||
"typings": "out/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rimraf {tsconfig.tsbuildinfo,out}",
|
||||
"lint": "eslint \"src/**/*.ts\" --cache",
|
||||
"compile": "tsc -b .",
|
||||
"compile:watch": "tsc -p . --watch --sourceMap",
|
||||
"test": "mocha \"out/**/*.spec.js\" -s 0",
|
||||
"build": "npm run clean && npm run compile && npm run lint && npm test",
|
||||
"watch": "npm run clean && npm run compile:watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nodelib/fs.scandir": "2.1.5",
|
||||
"fastq": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nodelib/fs.macchiato": "1.0.4"
|
||||
},
|
||||
"gitHead": "1e5bad48565da2b06b8600e744324ea240bf49d8"
|
||||
}
|
||||
85
web/node_modules/@rolldown/pluginutils/README.md
generated
vendored
85
web/node_modules/@rolldown/pluginutils/README.md
generated
vendored
@@ -1,85 +0,0 @@
|
||||
# @rolldown/pluginutils
|
||||
|
||||
A utility library for building flexible, composable filter expressions that can be used in plugin hook filters of Rolldown/Vite/Rollup/Unplugin plugins.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
pnpm add @rolldown/pluginutils
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Simple Filters
|
||||
|
||||
```ts
|
||||
import {
|
||||
exactRegex,
|
||||
makeIdFiltersToMatchWithQuery,
|
||||
prefixRegex,
|
||||
} from '@rolldown/pluginutils';
|
||||
|
||||
// Match exactly 'foo.js'
|
||||
const filter = exactRegex('foo.js');
|
||||
|
||||
// Match any id starting with 'lib/'
|
||||
const prefix = prefixRegex('lib/');
|
||||
|
||||
// Match ids with query params (e.g. 'foo.js?bar')
|
||||
const idFilters = makeIdFiltersToMatchWithQuery(['**/*.js', /\.ts$/]);
|
||||
|
||||
// Usage in a plugin to define a hook filter
|
||||
const myPlugin = {
|
||||
resolveId: {
|
||||
filter: {
|
||||
id: [exactRegex('MY_ID_TO_CHECK'), /some-other-regex/],
|
||||
},
|
||||
handler(id) {
|
||||
// Your code here
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Composable Filters
|
||||
|
||||
> [!WARNING] Composable filters are not yet supported in Vite, Rolldown-Vite or unplugin. They can be used in Rolldown plugins only.
|
||||
|
||||
```ts
|
||||
import { and, id, include, moduleType, query } from '@rolldown/pluginutils';
|
||||
|
||||
// Build a filter expression
|
||||
const filterExpr = and(
|
||||
id(/\.ts$/),
|
||||
moduleType('ts'),
|
||||
query('foo', true),
|
||||
);
|
||||
|
||||
// Usage in a plugin to define a hook filter
|
||||
const myPlugin = {
|
||||
transform: {
|
||||
filter: [include(filterExpr)],
|
||||
handler(code, id, options) {
|
||||
// Your code here
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
### Simple Filters
|
||||
|
||||
- `exactRegex(str: string, flags?: string): RegExp` — Matches the exact string.
|
||||
- `prefixRegex(str: string, flags?: string): RegExp` — Matches values with the given prefix.
|
||||
- `makeIdFiltersToMatchWithQuery(input: string | RegExp | (string | RegExp)[]): string | RegExp | (string | RegExp)[]` — Adapts filters to match ids with query params.
|
||||
|
||||
### Composable Filters
|
||||
|
||||
- `and(...exprs)` / `or(...exprs)` / `not(expr)` — Logical composition of filter expressions.
|
||||
- `id(pattern, params?)` — Filter by id (string or RegExp).
|
||||
- `moduleType(type)` — Filter by module type (e.g. 'js', 'tsx', or 'json').
|
||||
- `code(pattern)` — Filter by code content.
|
||||
- `query(key, pattern)` — Filter by query parameter.
|
||||
- `include(expr)` / `exclude(expr)` — Top-level include/exclude wrappers.
|
||||
- `queries(obj)` — Compose multiple query filters.
|
||||
83
web/node_modules/@rolldown/pluginutils/dist/composable-filters.d.ts
generated
vendored
83
web/node_modules/@rolldown/pluginutils/dist/composable-filters.d.ts
generated
vendored
@@ -1,83 +0,0 @@
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
|
||||
export type FilterExpressionKind = FilterExpression['kind'];
|
||||
export type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query;
|
||||
export type TopLevelFilterExpression = Include | Exclude;
|
||||
declare class And {
|
||||
kind: 'and';
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Or {
|
||||
kind: 'or';
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Not {
|
||||
kind: 'not';
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
export interface QueryFilterObject {
|
||||
[key: string]: StringOrRegExp | boolean;
|
||||
}
|
||||
interface IdParams {
|
||||
cleanUrl?: boolean;
|
||||
}
|
||||
declare class Id {
|
||||
kind: 'id';
|
||||
pattern: StringOrRegExp;
|
||||
params: IdParams;
|
||||
constructor(pattern: StringOrRegExp, params?: IdParams);
|
||||
}
|
||||
declare class ModuleType {
|
||||
kind: 'moduleType';
|
||||
pattern: PluginModuleType;
|
||||
constructor(pattern: PluginModuleType);
|
||||
}
|
||||
declare class Code {
|
||||
kind: 'code';
|
||||
pattern: StringOrRegExp;
|
||||
constructor(expr: StringOrRegExp);
|
||||
}
|
||||
declare class Query {
|
||||
kind: 'query';
|
||||
key: string;
|
||||
pattern: StringOrRegExp | boolean;
|
||||
constructor(key: string, pattern: StringOrRegExp | boolean);
|
||||
}
|
||||
declare class Include {
|
||||
kind: 'include';
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare class Exclude {
|
||||
kind: 'exclude';
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
export declare function and(...args: FilterExpression[]): And;
|
||||
export declare function or(...args: FilterExpression[]): Or;
|
||||
export declare function not(expr: FilterExpression): Not;
|
||||
export declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
|
||||
export declare function moduleType(pattern: PluginModuleType): ModuleType;
|
||||
export declare function code(pattern: StringOrRegExp): Code;
|
||||
export declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
|
||||
export declare function include(expr: FilterExpression): Include;
|
||||
export declare function exclude(expr: FilterExpression): Exclude;
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
export declare function queries(queryFilter: QueryFilterObject): And;
|
||||
export declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean;
|
||||
interface InterpreterCtx {
|
||||
urlSearchParamsCache?: URLSearchParams;
|
||||
}
|
||||
export declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
|
||||
export declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
|
||||
export {};
|
||||
228
web/node_modules/@rolldown/pluginutils/dist/composable-filters.js
generated
vendored
228
web/node_modules/@rolldown/pluginutils/dist/composable-filters.js
generated
vendored
@@ -1,228 +0,0 @@
|
||||
import { cleanUrl, extractQueryWithoutFragment } from './utils.js';
|
||||
class And {
|
||||
kind;
|
||||
args;
|
||||
constructor(...args) {
|
||||
if (args.length === 0) {
|
||||
throw new Error('`And` expects at least one operand');
|
||||
}
|
||||
this.args = args;
|
||||
this.kind = 'and';
|
||||
}
|
||||
}
|
||||
class Or {
|
||||
kind;
|
||||
args;
|
||||
constructor(...args) {
|
||||
if (args.length === 0) {
|
||||
throw new Error('`Or` expects at least one operand');
|
||||
}
|
||||
this.args = args;
|
||||
this.kind = 'or';
|
||||
}
|
||||
}
|
||||
class Not {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = 'not';
|
||||
}
|
||||
}
|
||||
class Id {
|
||||
kind;
|
||||
pattern;
|
||||
params;
|
||||
constructor(pattern, params) {
|
||||
this.pattern = pattern;
|
||||
this.kind = 'id';
|
||||
this.params = params ?? {
|
||||
cleanUrl: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
class ModuleType {
|
||||
kind;
|
||||
pattern;
|
||||
constructor(pattern) {
|
||||
this.pattern = pattern;
|
||||
this.kind = 'moduleType';
|
||||
}
|
||||
}
|
||||
class Code {
|
||||
kind;
|
||||
pattern;
|
||||
constructor(expr) {
|
||||
this.pattern = expr;
|
||||
this.kind = 'code';
|
||||
}
|
||||
}
|
||||
class Query {
|
||||
kind;
|
||||
key;
|
||||
pattern;
|
||||
constructor(key, pattern) {
|
||||
this.pattern = pattern;
|
||||
this.key = key;
|
||||
this.kind = 'query';
|
||||
}
|
||||
}
|
||||
class Include {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = 'include';
|
||||
}
|
||||
}
|
||||
class Exclude {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = 'exclude';
|
||||
}
|
||||
}
|
||||
export function and(...args) {
|
||||
return new And(...args);
|
||||
}
|
||||
export function or(...args) {
|
||||
return new Or(...args);
|
||||
}
|
||||
export function not(expr) {
|
||||
return new Not(expr);
|
||||
}
|
||||
export function id(pattern, params) {
|
||||
return new Id(pattern, params);
|
||||
}
|
||||
export function moduleType(pattern) {
|
||||
return new ModuleType(pattern);
|
||||
}
|
||||
export function code(pattern) {
|
||||
return new Code(pattern);
|
||||
}
|
||||
/*
|
||||
* There are three kinds of conditions are supported:
|
||||
* 1. `boolean`: if the value is `true`, the key must exist and be truthy. if the value is `false`, the key must not exist or be falsy.
|
||||
* 2. `string`: the key must exist and be equal to the value.
|
||||
* 3. `RegExp`: the key must exist and match the value.
|
||||
*/
|
||||
export function query(key, pattern) {
|
||||
return new Query(key, pattern);
|
||||
}
|
||||
export function include(expr) {
|
||||
return new Include(expr);
|
||||
}
|
||||
export function exclude(expr) {
|
||||
return new Exclude(expr);
|
||||
}
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
export function queries(queryFilter) {
|
||||
let arr = Object.entries(queryFilter).map(([key, value]) => {
|
||||
return new Query(key, value);
|
||||
});
|
||||
return and(...arr);
|
||||
}
|
||||
export function interpreter(exprs, code, id, moduleType) {
|
||||
let arr = [];
|
||||
if (Array.isArray(exprs)) {
|
||||
arr = exprs;
|
||||
}
|
||||
else {
|
||||
arr = [exprs];
|
||||
}
|
||||
return interpreterImpl(arr, code, id, moduleType);
|
||||
}
|
||||
export function interpreterImpl(expr, code, id, moduleType, ctx = {}) {
|
||||
let hasInclude = false;
|
||||
for (const e of expr) {
|
||||
switch (e.kind) {
|
||||
case 'include': {
|
||||
hasInclude = true;
|
||||
if (exprInterpreter(e.expr, code, id, moduleType, ctx)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'exclude': {
|
||||
if (exprInterpreter(e.expr, code, id, moduleType)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !hasInclude;
|
||||
}
|
||||
export function exprInterpreter(expr, code, id, moduleType, ctx = {}) {
|
||||
switch (expr.kind) {
|
||||
case 'and': {
|
||||
return expr.args.every((e) => exprInterpreter(e, code, id, moduleType, ctx));
|
||||
}
|
||||
case 'or': {
|
||||
return expr.args.some((e) => exprInterpreter(e, code, id, moduleType, ctx));
|
||||
}
|
||||
case 'not': {
|
||||
return !exprInterpreter(expr.expr, code, id, moduleType, ctx);
|
||||
}
|
||||
case 'id': {
|
||||
if (id === undefined) {
|
||||
throw new Error('`id` is required for `id` expression');
|
||||
}
|
||||
if (expr.params.cleanUrl) {
|
||||
id = cleanUrl(id);
|
||||
}
|
||||
return typeof expr.pattern === 'string'
|
||||
? id === expr.pattern
|
||||
: expr.pattern.test(id);
|
||||
}
|
||||
case 'moduleType': {
|
||||
if (moduleType === undefined) {
|
||||
throw new Error('`moduleType` is required for `moduleType` expression');
|
||||
}
|
||||
return moduleType === expr.pattern;
|
||||
}
|
||||
case 'code': {
|
||||
if (code === undefined) {
|
||||
throw new Error('`code` is required for `code` expression');
|
||||
}
|
||||
return typeof expr.pattern === 'string'
|
||||
? code.includes(expr.pattern)
|
||||
: expr.pattern.test(code);
|
||||
}
|
||||
case 'query': {
|
||||
if (id === undefined) {
|
||||
throw new Error('`id` is required for `Query` expression');
|
||||
}
|
||||
if (!ctx.urlSearchParamsCache) {
|
||||
let queryString = extractQueryWithoutFragment(id);
|
||||
ctx.urlSearchParamsCache = new URLSearchParams(queryString);
|
||||
}
|
||||
let urlParams = ctx.urlSearchParamsCache;
|
||||
if (typeof expr.pattern === 'boolean') {
|
||||
if (expr.pattern) {
|
||||
return urlParams.has(expr.key);
|
||||
}
|
||||
else {
|
||||
return !urlParams.has(expr.key);
|
||||
}
|
||||
}
|
||||
else if (typeof expr.pattern === 'string') {
|
||||
return urlParams.get(expr.key) === expr.pattern;
|
||||
}
|
||||
else {
|
||||
return expr.pattern.test(urlParams.get(expr.key) ?? '');
|
||||
}
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
web/node_modules/@rolldown/pluginutils/dist/filter-vite-plugins.d.ts
generated
vendored
28
web/node_modules/@rolldown/pluginutils/dist/filter-vite-plugins.d.ts
generated
vendored
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Filters out Vite plugins that have `apply: 'serve'` set.
|
||||
*
|
||||
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
||||
* are intended only for Vite's dev server and should be excluded from the build process.
|
||||
*
|
||||
* @param plugins - Array of plugins (can include nested arrays)
|
||||
* @returns Filtered array with serve-only plugins removed
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { defineConfig } from 'rolldown';
|
||||
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
||||
* import viteReact from '@vitejs/plugin-react';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* plugins: filterVitePlugins([
|
||||
* viteReact(),
|
||||
* {
|
||||
* name: 'dev-only',
|
||||
* apply: 'serve', // This will be filtered out
|
||||
* // ...
|
||||
* }
|
||||
* ])
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
|
||||
75
web/node_modules/@rolldown/pluginutils/dist/filter-vite-plugins.js
generated
vendored
75
web/node_modules/@rolldown/pluginutils/dist/filter-vite-plugins.js
generated
vendored
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Filters out Vite plugins that have `apply: 'serve'` set.
|
||||
*
|
||||
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
||||
* are intended only for Vite's dev server and should be excluded from the build process.
|
||||
*
|
||||
* @param plugins - Array of plugins (can include nested arrays)
|
||||
* @returns Filtered array with serve-only plugins removed
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { defineConfig } from 'rolldown';
|
||||
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
||||
* import viteReact from '@vitejs/plugin-react';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* plugins: filterVitePlugins([
|
||||
* viteReact(),
|
||||
* {
|
||||
* name: 'dev-only',
|
||||
* apply: 'serve', // This will be filtered out
|
||||
* // ...
|
||||
* }
|
||||
* ])
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function filterVitePlugins(plugins) {
|
||||
if (!plugins) {
|
||||
return [];
|
||||
}
|
||||
const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
|
||||
const result = [];
|
||||
for (const plugin of pluginArray) {
|
||||
// Skip falsy values
|
||||
if (!plugin) {
|
||||
continue;
|
||||
}
|
||||
// Handle nested arrays recursively
|
||||
if (Array.isArray(plugin)) {
|
||||
result.push(...filterVitePlugins(plugin));
|
||||
continue;
|
||||
}
|
||||
// Check if plugin has apply property
|
||||
const pluginWithApply = plugin;
|
||||
if ('apply' in pluginWithApply) {
|
||||
const applyValue = pluginWithApply.apply;
|
||||
// If apply is a function, call it with build mode
|
||||
if (typeof applyValue === 'function') {
|
||||
try {
|
||||
const shouldApply = applyValue({}, // config object
|
||||
{ command: 'build', mode: 'production' });
|
||||
if (shouldApply) {
|
||||
result.push(plugin);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// If function throws, include the plugin to be safe
|
||||
result.push(plugin);
|
||||
}
|
||||
} // If apply is 'serve', skip this plugin
|
||||
else if (applyValue === 'serve') {
|
||||
continue;
|
||||
} // If apply is 'build' or anything else, include it
|
||||
else {
|
||||
result.push(plugin);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No apply property, include the plugin
|
||||
result.push(plugin);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
271
web/node_modules/@rolldown/pluginutils/dist/index.cjs
generated
vendored
Normal file
271
web/node_modules/@rolldown/pluginutils/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
|
||||
//#region src/utils.ts
|
||||
const postfixRE = /[?#].*$/;
|
||||
function cleanUrl(url) {
|
||||
return url.replace(postfixRE, "");
|
||||
}
|
||||
function extractQueryWithoutFragment(url) {
|
||||
const questionMarkIndex = url.indexOf("?");
|
||||
if (questionMarkIndex === -1) return "";
|
||||
const fragmentIndex = url.indexOf("#", questionMarkIndex);
|
||||
if (fragmentIndex === -1) return url.substring(questionMarkIndex);
|
||||
else return url.substring(questionMarkIndex, fragmentIndex);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/composable-filters.ts
|
||||
var And = class {
|
||||
kind;
|
||||
args;
|
||||
constructor(...args) {
|
||||
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
||||
this.args = args;
|
||||
this.kind = "and";
|
||||
}
|
||||
};
|
||||
var Or = class {
|
||||
kind;
|
||||
args;
|
||||
constructor(...args) {
|
||||
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
||||
this.args = args;
|
||||
this.kind = "or";
|
||||
}
|
||||
};
|
||||
var Not = class {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = "not";
|
||||
}
|
||||
};
|
||||
var Id = class {
|
||||
kind;
|
||||
pattern;
|
||||
params;
|
||||
constructor(pattern, params) {
|
||||
this.pattern = pattern;
|
||||
this.kind = "id";
|
||||
this.params = params ?? { cleanUrl: false };
|
||||
}
|
||||
};
|
||||
var ModuleType = class {
|
||||
kind;
|
||||
pattern;
|
||||
constructor(pattern) {
|
||||
this.pattern = pattern;
|
||||
this.kind = "moduleType";
|
||||
}
|
||||
};
|
||||
var Code = class {
|
||||
kind;
|
||||
pattern;
|
||||
constructor(expr) {
|
||||
this.pattern = expr;
|
||||
this.kind = "code";
|
||||
}
|
||||
};
|
||||
var Query = class {
|
||||
kind;
|
||||
key;
|
||||
pattern;
|
||||
constructor(key, pattern) {
|
||||
this.pattern = pattern;
|
||||
this.key = key;
|
||||
this.kind = "query";
|
||||
}
|
||||
};
|
||||
var Include = class {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = "include";
|
||||
}
|
||||
};
|
||||
var Exclude = class {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = "exclude";
|
||||
}
|
||||
};
|
||||
function and(...args) {
|
||||
return new And(...args);
|
||||
}
|
||||
function or(...args) {
|
||||
return new Or(...args);
|
||||
}
|
||||
function not(expr) {
|
||||
return new Not(expr);
|
||||
}
|
||||
function id(pattern, params) {
|
||||
return new Id(pattern, params);
|
||||
}
|
||||
function moduleType(pattern) {
|
||||
return new ModuleType(pattern);
|
||||
}
|
||||
function code(pattern) {
|
||||
return new Code(pattern);
|
||||
}
|
||||
function query(key, pattern) {
|
||||
return new Query(key, pattern);
|
||||
}
|
||||
function include(expr) {
|
||||
return new Include(expr);
|
||||
}
|
||||
function exclude(expr) {
|
||||
return new Exclude(expr);
|
||||
}
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
function queries(queryFilter) {
|
||||
let arr = Object.entries(queryFilter).map(([key, value]) => {
|
||||
return new Query(key, value);
|
||||
});
|
||||
return and(...arr);
|
||||
}
|
||||
function interpreter(exprs, code$1, id$1, moduleType$1) {
|
||||
let arr = [];
|
||||
if (Array.isArray(exprs)) arr = exprs;
|
||||
else arr = [exprs];
|
||||
return interpreterImpl(arr, code$1, id$1, moduleType$1);
|
||||
}
|
||||
function interpreterImpl(expr, code$1, id$1, moduleType$1, ctx = {}) {
|
||||
let hasInclude = false;
|
||||
for (const e of expr) switch (e.kind) {
|
||||
case "include": {
|
||||
hasInclude = true;
|
||||
if (exprInterpreter(e.expr, code$1, id$1, moduleType$1, ctx)) return true;
|
||||
break;
|
||||
}
|
||||
case "exclude": {
|
||||
if (exprInterpreter(e.expr, code$1, id$1, moduleType$1)) return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return !hasInclude;
|
||||
}
|
||||
function exprInterpreter(expr, code$1, id$1, moduleType$1, ctx = {}) {
|
||||
switch (expr.kind) {
|
||||
case "and": return expr.args.every((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
|
||||
case "or": return expr.args.some((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
|
||||
case "not": return !exprInterpreter(expr.expr, code$1, id$1, moduleType$1, ctx);
|
||||
case "id": {
|
||||
if (id$1 === void 0) throw new Error("`id` is required for `id` expression");
|
||||
if (expr.params.cleanUrl) id$1 = cleanUrl(id$1);
|
||||
return typeof expr.pattern === "string" ? id$1 === expr.pattern : expr.pattern.test(id$1);
|
||||
}
|
||||
case "moduleType": {
|
||||
if (moduleType$1 === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
|
||||
return moduleType$1 === expr.pattern;
|
||||
}
|
||||
case "code": {
|
||||
if (code$1 === void 0) throw new Error("`code` is required for `code` expression");
|
||||
return typeof expr.pattern === "string" ? code$1.includes(expr.pattern) : expr.pattern.test(code$1);
|
||||
}
|
||||
case "query": {
|
||||
if (id$1 === void 0) throw new Error("`id` is required for `Query` expression");
|
||||
if (!ctx.urlSearchParamsCache) {
|
||||
let queryString = extractQueryWithoutFragment(id$1);
|
||||
ctx.urlSearchParamsCache = new URLSearchParams(queryString);
|
||||
}
|
||||
let urlParams = ctx.urlSearchParamsCache;
|
||||
if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
|
||||
else return !urlParams.has(expr.key);
|
||||
else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
|
||||
else return expr.pattern.test(urlParams.get(expr.key) ?? "");
|
||||
}
|
||||
default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/simple-filters.ts
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function exactRegex(str, flags) {
|
||||
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
||||
}
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function prefixRegex(str, flags) {
|
||||
return new RegExp(`^${escapeRegex(str)}`, flags);
|
||||
}
|
||||
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
||||
function escapeRegex(str) {
|
||||
return str.replace(escapeRegexRE, "\\$&");
|
||||
}
|
||||
function makeIdFiltersToMatchWithQuery(input) {
|
||||
if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
|
||||
return input.map((i) => makeIdFilterToMatchWithQuery(i));
|
||||
}
|
||||
function makeIdFilterToMatchWithQuery(input) {
|
||||
if (typeof input === "string") return `${input}{?*,}`;
|
||||
return makeRegexIdFilterToMatchWithQuery(input);
|
||||
}
|
||||
function makeRegexIdFilterToMatchWithQuery(input) {
|
||||
return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.and = and;
|
||||
exports.code = code;
|
||||
exports.exactRegex = exactRegex;
|
||||
exports.exclude = exclude;
|
||||
exports.exprInterpreter = exprInterpreter;
|
||||
exports.id = id;
|
||||
exports.include = include;
|
||||
exports.interpreter = interpreter;
|
||||
exports.interpreterImpl = interpreterImpl;
|
||||
exports.makeIdFiltersToMatchWithQuery = makeIdFiltersToMatchWithQuery;
|
||||
exports.moduleType = moduleType;
|
||||
exports.not = not;
|
||||
exports.or = or;
|
||||
exports.prefixRegex = prefixRegex;
|
||||
exports.queries = queries;
|
||||
exports.query = query;
|
||||
157
web/node_modules/@rolldown/pluginutils/dist/index.d.cts
generated
vendored
Normal file
157
web/node_modules/@rolldown/pluginutils/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
//#region src/composable-filters.d.ts
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type PluginModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
|
||||
type FilterExpressionKind = FilterExpression["kind"];
|
||||
type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query;
|
||||
type TopLevelFilterExpression = Include | Exclude;
|
||||
declare class And {
|
||||
kind: "and";
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Or {
|
||||
kind: "or";
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Not {
|
||||
kind: "not";
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
interface QueryFilterObject {
|
||||
[key: string]: StringOrRegExp | boolean;
|
||||
}
|
||||
interface IdParams {
|
||||
cleanUrl?: boolean;
|
||||
}
|
||||
declare class Id {
|
||||
kind: "id";
|
||||
pattern: StringOrRegExp;
|
||||
params: IdParams;
|
||||
constructor(pattern: StringOrRegExp, params?: IdParams);
|
||||
}
|
||||
declare class ModuleType {
|
||||
kind: "moduleType";
|
||||
pattern: PluginModuleType;
|
||||
constructor(pattern: PluginModuleType);
|
||||
}
|
||||
declare class Code {
|
||||
kind: "code";
|
||||
pattern: StringOrRegExp;
|
||||
constructor(expr: StringOrRegExp);
|
||||
}
|
||||
declare class Query {
|
||||
kind: "query";
|
||||
key: string;
|
||||
pattern: StringOrRegExp | boolean;
|
||||
constructor(key: string, pattern: StringOrRegExp | boolean);
|
||||
}
|
||||
declare class Include {
|
||||
kind: "include";
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare class Exclude {
|
||||
kind: "exclude";
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare function and(...args: FilterExpression[]): And;
|
||||
declare function or(...args: FilterExpression[]): Or;
|
||||
declare function not(expr: FilterExpression): Not;
|
||||
declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
|
||||
declare function moduleType(pattern: PluginModuleType): ModuleType;
|
||||
declare function code(pattern: StringOrRegExp): Code;
|
||||
declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
|
||||
declare function include(expr: FilterExpression): Include;
|
||||
declare function exclude(expr: FilterExpression): Exclude;
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
declare function queries(queryFilter: QueryFilterObject): And;
|
||||
declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean;
|
||||
interface InterpreterCtx {
|
||||
urlSearchParamsCache?: URLSearchParams;
|
||||
}
|
||||
declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
|
||||
declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
|
||||
//#endregion
|
||||
//#region src/simple-filters.d.ts
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function exactRegex(str: string, flags?: string): RegExp;
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function prefixRegex(str: string, flags?: string): RegExp;
|
||||
type WidenString<T> = T extends string ? string : T;
|
||||
/**
|
||||
* Converts a id filter to match with an id with a query.
|
||||
*
|
||||
* @param input the id filters to convert.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* transform: {
|
||||
* filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
|
||||
* // The handler will be called for IDs like:
|
||||
* // - foo.js
|
||||
* // - foo.js?foo
|
||||
* // - foo.txt?foo.js
|
||||
* // - foo.ts
|
||||
* // - foo.ts?foo
|
||||
* // - foo.txt?foo.ts
|
||||
* handler(code, id) {}
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
|
||||
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
|
||||
declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
|
||||
//#endregion
|
||||
export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
|
||||
160
web/node_modules/@rolldown/pluginutils/dist/index.d.ts
generated
vendored
160
web/node_modules/@rolldown/pluginutils/dist/index.d.ts
generated
vendored
@@ -1,3 +1,157 @@
|
||||
export * from './composable-filters.js';
|
||||
export * from './filter-vite-plugins.js';
|
||||
export * from './simple-filters.js';
|
||||
//#region src/composable-filters.d.ts
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type PluginModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
|
||||
type FilterExpressionKind = FilterExpression["kind"];
|
||||
type FilterExpression = And | Or | Not | Id | ModuleType | Code | Query;
|
||||
type TopLevelFilterExpression = Include | Exclude;
|
||||
declare class And {
|
||||
kind: "and";
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Or {
|
||||
kind: "or";
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Not {
|
||||
kind: "not";
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
interface QueryFilterObject {
|
||||
[key: string]: StringOrRegExp | boolean;
|
||||
}
|
||||
interface IdParams {
|
||||
cleanUrl?: boolean;
|
||||
}
|
||||
declare class Id {
|
||||
kind: "id";
|
||||
pattern: StringOrRegExp;
|
||||
params: IdParams;
|
||||
constructor(pattern: StringOrRegExp, params?: IdParams);
|
||||
}
|
||||
declare class ModuleType {
|
||||
kind: "moduleType";
|
||||
pattern: PluginModuleType;
|
||||
constructor(pattern: PluginModuleType);
|
||||
}
|
||||
declare class Code {
|
||||
kind: "code";
|
||||
pattern: StringOrRegExp;
|
||||
constructor(expr: StringOrRegExp);
|
||||
}
|
||||
declare class Query {
|
||||
kind: "query";
|
||||
key: string;
|
||||
pattern: StringOrRegExp | boolean;
|
||||
constructor(key: string, pattern: StringOrRegExp | boolean);
|
||||
}
|
||||
declare class Include {
|
||||
kind: "include";
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare class Exclude {
|
||||
kind: "exclude";
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare function and(...args: FilterExpression[]): And;
|
||||
declare function or(...args: FilterExpression[]): Or;
|
||||
declare function not(expr: FilterExpression): Not;
|
||||
declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
|
||||
declare function moduleType(pattern: PluginModuleType): ModuleType;
|
||||
declare function code(pattern: StringOrRegExp): Code;
|
||||
declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
|
||||
declare function include(expr: FilterExpression): Include;
|
||||
declare function exclude(expr: FilterExpression): Exclude;
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
declare function queries(queryFilter: QueryFilterObject): And;
|
||||
declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType): boolean;
|
||||
interface InterpreterCtx {
|
||||
urlSearchParamsCache?: URLSearchParams;
|
||||
}
|
||||
declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
|
||||
declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, ctx?: InterpreterCtx): boolean;
|
||||
//#endregion
|
||||
//#region src/simple-filters.d.ts
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function exactRegex(str: string, flags?: string): RegExp;
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function prefixRegex(str: string, flags?: string): RegExp;
|
||||
type WidenString<T> = T extends string ? string : T;
|
||||
/**
|
||||
* Converts a id filter to match with an id with a query.
|
||||
*
|
||||
* @param input the id filters to convert.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* transform: {
|
||||
* filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
|
||||
* // The handler will be called for IDs like:
|
||||
* // - foo.js
|
||||
* // - foo.js?foo
|
||||
* // - foo.txt?foo.js
|
||||
* // - foo.ts
|
||||
* // - foo.ts?foo
|
||||
* // - foo.txt?foo.ts
|
||||
* handler(code, id) {}
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
|
||||
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
|
||||
declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
|
||||
//#endregion
|
||||
export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
|
||||
258
web/node_modules/@rolldown/pluginutils/dist/index.js
generated
vendored
258
web/node_modules/@rolldown/pluginutils/dist/index.js
generated
vendored
@@ -1,3 +1,255 @@
|
||||
export * from './composable-filters.js';
|
||||
export * from './filter-vite-plugins.js';
|
||||
export * from './simple-filters.js';
|
||||
//#region src/utils.ts
|
||||
const postfixRE = /[?#].*$/;
|
||||
function cleanUrl(url) {
|
||||
return url.replace(postfixRE, "");
|
||||
}
|
||||
function extractQueryWithoutFragment(url) {
|
||||
const questionMarkIndex = url.indexOf("?");
|
||||
if (questionMarkIndex === -1) return "";
|
||||
const fragmentIndex = url.indexOf("#", questionMarkIndex);
|
||||
if (fragmentIndex === -1) return url.substring(questionMarkIndex);
|
||||
else return url.substring(questionMarkIndex, fragmentIndex);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/composable-filters.ts
|
||||
var And = class {
|
||||
kind;
|
||||
args;
|
||||
constructor(...args) {
|
||||
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
||||
this.args = args;
|
||||
this.kind = "and";
|
||||
}
|
||||
};
|
||||
var Or = class {
|
||||
kind;
|
||||
args;
|
||||
constructor(...args) {
|
||||
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
||||
this.args = args;
|
||||
this.kind = "or";
|
||||
}
|
||||
};
|
||||
var Not = class {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = "not";
|
||||
}
|
||||
};
|
||||
var Id = class {
|
||||
kind;
|
||||
pattern;
|
||||
params;
|
||||
constructor(pattern, params) {
|
||||
this.pattern = pattern;
|
||||
this.kind = "id";
|
||||
this.params = params ?? { cleanUrl: false };
|
||||
}
|
||||
};
|
||||
var ModuleType = class {
|
||||
kind;
|
||||
pattern;
|
||||
constructor(pattern) {
|
||||
this.pattern = pattern;
|
||||
this.kind = "moduleType";
|
||||
}
|
||||
};
|
||||
var Code = class {
|
||||
kind;
|
||||
pattern;
|
||||
constructor(expr) {
|
||||
this.pattern = expr;
|
||||
this.kind = "code";
|
||||
}
|
||||
};
|
||||
var Query = class {
|
||||
kind;
|
||||
key;
|
||||
pattern;
|
||||
constructor(key, pattern) {
|
||||
this.pattern = pattern;
|
||||
this.key = key;
|
||||
this.kind = "query";
|
||||
}
|
||||
};
|
||||
var Include = class {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = "include";
|
||||
}
|
||||
};
|
||||
var Exclude = class {
|
||||
kind;
|
||||
expr;
|
||||
constructor(expr) {
|
||||
this.expr = expr;
|
||||
this.kind = "exclude";
|
||||
}
|
||||
};
|
||||
function and(...args) {
|
||||
return new And(...args);
|
||||
}
|
||||
function or(...args) {
|
||||
return new Or(...args);
|
||||
}
|
||||
function not(expr) {
|
||||
return new Not(expr);
|
||||
}
|
||||
function id(pattern, params) {
|
||||
return new Id(pattern, params);
|
||||
}
|
||||
function moduleType(pattern) {
|
||||
return new ModuleType(pattern);
|
||||
}
|
||||
function code(pattern) {
|
||||
return new Code(pattern);
|
||||
}
|
||||
function query(key, pattern) {
|
||||
return new Query(key, pattern);
|
||||
}
|
||||
function include(expr) {
|
||||
return new Include(expr);
|
||||
}
|
||||
function exclude(expr) {
|
||||
return new Exclude(expr);
|
||||
}
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
function queries(queryFilter) {
|
||||
let arr = Object.entries(queryFilter).map(([key, value]) => {
|
||||
return new Query(key, value);
|
||||
});
|
||||
return and(...arr);
|
||||
}
|
||||
function interpreter(exprs, code$1, id$1, moduleType$1) {
|
||||
let arr = [];
|
||||
if (Array.isArray(exprs)) arr = exprs;
|
||||
else arr = [exprs];
|
||||
return interpreterImpl(arr, code$1, id$1, moduleType$1);
|
||||
}
|
||||
function interpreterImpl(expr, code$1, id$1, moduleType$1, ctx = {}) {
|
||||
let hasInclude = false;
|
||||
for (const e of expr) switch (e.kind) {
|
||||
case "include": {
|
||||
hasInclude = true;
|
||||
if (exprInterpreter(e.expr, code$1, id$1, moduleType$1, ctx)) return true;
|
||||
break;
|
||||
}
|
||||
case "exclude": {
|
||||
if (exprInterpreter(e.expr, code$1, id$1, moduleType$1)) return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return !hasInclude;
|
||||
}
|
||||
function exprInterpreter(expr, code$1, id$1, moduleType$1, ctx = {}) {
|
||||
switch (expr.kind) {
|
||||
case "and": return expr.args.every((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
|
||||
case "or": return expr.args.some((e) => exprInterpreter(e, code$1, id$1, moduleType$1, ctx));
|
||||
case "not": return !exprInterpreter(expr.expr, code$1, id$1, moduleType$1, ctx);
|
||||
case "id": {
|
||||
if (id$1 === void 0) throw new Error("`id` is required for `id` expression");
|
||||
if (expr.params.cleanUrl) id$1 = cleanUrl(id$1);
|
||||
return typeof expr.pattern === "string" ? id$1 === expr.pattern : expr.pattern.test(id$1);
|
||||
}
|
||||
case "moduleType": {
|
||||
if (moduleType$1 === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
|
||||
return moduleType$1 === expr.pattern;
|
||||
}
|
||||
case "code": {
|
||||
if (code$1 === void 0) throw new Error("`code` is required for `code` expression");
|
||||
return typeof expr.pattern === "string" ? code$1.includes(expr.pattern) : expr.pattern.test(code$1);
|
||||
}
|
||||
case "query": {
|
||||
if (id$1 === void 0) throw new Error("`id` is required for `Query` expression");
|
||||
if (!ctx.urlSearchParamsCache) {
|
||||
let queryString = extractQueryWithoutFragment(id$1);
|
||||
ctx.urlSearchParamsCache = new URLSearchParams(queryString);
|
||||
}
|
||||
let urlParams = ctx.urlSearchParamsCache;
|
||||
if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
|
||||
else return !urlParams.has(expr.key);
|
||||
else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
|
||||
else return expr.pattern.test(urlParams.get(expr.key) ?? "");
|
||||
}
|
||||
default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/simple-filters.ts
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function exactRegex(str, flags) {
|
||||
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
||||
}
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
function prefixRegex(str, flags) {
|
||||
return new RegExp(`^${escapeRegex(str)}`, flags);
|
||||
}
|
||||
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
||||
function escapeRegex(str) {
|
||||
return str.replace(escapeRegexRE, "\\$&");
|
||||
}
|
||||
function makeIdFiltersToMatchWithQuery(input) {
|
||||
if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
|
||||
return input.map((i) => makeIdFilterToMatchWithQuery(i));
|
||||
}
|
||||
function makeIdFilterToMatchWithQuery(input) {
|
||||
if (typeof input === "string") return `${input}{?*,}`;
|
||||
return makeRegexIdFilterToMatchWithQuery(input);
|
||||
}
|
||||
function makeRegexIdFilterToMatchWithQuery(input) {
|
||||
return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { and, code, exactRegex, exclude, exprInterpreter, id, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
|
||||
71
web/node_modules/@rolldown/pluginutils/dist/simple-filters.d.ts
generated
vendored
71
web/node_modules/@rolldown/pluginutils/dist/simple-filters.d.ts
generated
vendored
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function exactRegex(str: string, flags?: string): RegExp;
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function prefixRegex(str: string, flags?: string): RegExp;
|
||||
type WidenString<T> = T extends string ? string : T;
|
||||
/**
|
||||
* Converts a id filter to match with an id with a query.
|
||||
*
|
||||
* @param input the id filters to convert.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* transform: {
|
||||
* filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
|
||||
* // The handler will be called for IDs like:
|
||||
* // - foo.js
|
||||
* // - foo.js?foo
|
||||
* // - foo.txt?foo.js
|
||||
* // - foo.ts
|
||||
* // - foo.ts?foo
|
||||
* // - foo.txt?foo.ts
|
||||
* handler(code, id) {}
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
|
||||
export declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
|
||||
export declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
|
||||
export {};
|
||||
70
web/node_modules/@rolldown/pluginutils/dist/simple-filters.js
generated
vendored
70
web/node_modules/@rolldown/pluginutils/dist/simple-filters.js
generated
vendored
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function exactRegex(str, flags) {
|
||||
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
||||
}
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function prefixRegex(str, flags) {
|
||||
return new RegExp(`^${escapeRegex(str)}`, flags);
|
||||
}
|
||||
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
||||
function escapeRegex(str) {
|
||||
return str.replace(escapeRegexRE, '\\$&');
|
||||
}
|
||||
export function makeIdFiltersToMatchWithQuery(input) {
|
||||
if (!Array.isArray(input)) {
|
||||
return makeIdFilterToMatchWithQuery(
|
||||
// Array.isArray cannot narrow the type
|
||||
// https://github.com/microsoft/TypeScript/issues/17002
|
||||
input);
|
||||
}
|
||||
return input.map((i) => makeIdFilterToMatchWithQuery(i));
|
||||
}
|
||||
function makeIdFilterToMatchWithQuery(input) {
|
||||
if (typeof input === 'string') {
|
||||
return `${input}{?*,}`;
|
||||
}
|
||||
return makeRegexIdFilterToMatchWithQuery(input);
|
||||
}
|
||||
function makeRegexIdFilterToMatchWithQuery(input) {
|
||||
return new RegExp(
|
||||
// replace `$` with `(?:\?.*)?$` (ignore `\$`)
|
||||
input.source.replace(/(?<!\\)\$/g, '(?:\\?.*)?$'), input.flags);
|
||||
}
|
||||
2
web/node_modules/@rolldown/pluginutils/dist/utils.d.ts
generated
vendored
2
web/node_modules/@rolldown/pluginutils/dist/utils.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
export declare function cleanUrl(url: string): string;
|
||||
export declare function extractQueryWithoutFragment(url: string): string;
|
||||
17
web/node_modules/@rolldown/pluginutils/dist/utils.js
generated
vendored
17
web/node_modules/@rolldown/pluginutils/dist/utils.js
generated
vendored
@@ -1,17 +0,0 @@
|
||||
const postfixRE = /[?#].*$/;
|
||||
export function cleanUrl(url) {
|
||||
return url.replace(postfixRE, '');
|
||||
}
|
||||
export function extractQueryWithoutFragment(url) {
|
||||
const questionMarkIndex = url.indexOf('?');
|
||||
if (questionMarkIndex === -1) {
|
||||
return '';
|
||||
}
|
||||
const fragmentIndex = url.indexOf('#', questionMarkIndex); // Search for # after ?
|
||||
if (fragmentIndex === -1) {
|
||||
return url.substring(questionMarkIndex);
|
||||
}
|
||||
else {
|
||||
return url.substring(questionMarkIndex, fragmentIndex);
|
||||
}
|
||||
}
|
||||
16
web/node_modules/@rolldown/pluginutils/package.json
generated
vendored
16
web/node_modules/@rolldown/pluginutils/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rolldown/pluginutils",
|
||||
"version": "1.0.0-beta.47",
|
||||
"version": "1.0.0-beta.27",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
@@ -11,12 +11,14 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./package.json": "./package.json"
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
@@ -24,11 +26,11 @@
|
||||
"devDependencies": {
|
||||
"@types/picomatch": "^4.0.0",
|
||||
"picomatch": "^4.0.2",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^4.0.1"
|
||||
"tsdown": "0.12.9",
|
||||
"vitest": "^3.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "tsdown",
|
||||
"test": "vitest --typecheck"
|
||||
}
|
||||
}
|
||||
23
web/node_modules/@vitejs/plugin-react/README.md
generated
vendored
23
web/node_modules/@vitejs/plugin-react/README.md
generated
vendored
@@ -21,7 +21,7 @@ export default defineConfig({
|
||||
|
||||
### include/exclude
|
||||
|
||||
Includes `.js`, `.jsx`, `.ts` & `.tsx` and excludes `/node_modules/` by default. This option can be used to add fast refresh to `.mdx` files:
|
||||
Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'vite'
|
||||
@@ -36,9 +36,11 @@ export default defineConfig({
|
||||
})
|
||||
```
|
||||
|
||||
> `node_modules` are never processed by this plugin (but esbuild will)
|
||||
|
||||
### jsxImportSource
|
||||
|
||||
Control where the JSX factory is imported from. By default, this is inferred from `jsxImportSource` from corresponding a tsconfig file for a transformed file.
|
||||
Control where the JSX factory is imported from. Default to `'react'`
|
||||
|
||||
```js
|
||||
react({ jsxImportSource: '@emotion/react' })
|
||||
@@ -102,16 +104,9 @@ react({ reactRefreshHost: 'http://localhost:3000' })
|
||||
|
||||
Under the hood, this simply updates the React Fash Refresh runtime URL from `/@react-refresh` to `http://localhost:3000/@react-refresh` to ensure there is only one Refresh runtime across the whole application. Note that if you define `base` option in the host application, you need to include it in the option, like: `http://localhost:3000/{base}`.
|
||||
|
||||
## `@vitejs/plugin-react/preamble`
|
||||
## Middleware mode
|
||||
|
||||
The package provides `@vitejs/plugin-react/preamble` to initialize HMR runtime from client entrypoint for SSR applications which don't use [`transformIndexHtml` API](https://vite.dev/guide/api-javascript.html#vitedevserver). For example:
|
||||
|
||||
```js
|
||||
// [entry.client.js]
|
||||
import '@vitejs/plugin-react/preamble'
|
||||
```
|
||||
|
||||
Alternatively, you can manually call `transformIndexHtml` during SSR, which sets up equivalent initialization code. Here's an example for an Express server:
|
||||
In [middleware mode](https://vite.dev/config/server-options.html#server-middlewaremode), you should make sure your entry `index.html` file is transformed by Vite. Here's an example for an Express server:
|
||||
|
||||
```js
|
||||
app.get('/', async (req, res, next) => {
|
||||
@@ -128,12 +123,16 @@ app.get('/', async (req, res, next) => {
|
||||
})
|
||||
```
|
||||
|
||||
Otherwise, you'll get the following error:
|
||||
Otherwise, you'll probably get this error:
|
||||
|
||||
```
|
||||
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
|
||||
```
|
||||
|
||||
### disableOxcRecommendation
|
||||
|
||||
If set, disables the recommendation to use `@vitejs/plugin-react-oxc` (which is shown when `rolldown-vite` is detected and `babel` is not configured).
|
||||
|
||||
## Consistent components exports
|
||||
|
||||
For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
|
||||
|
||||
343
web/node_modules/@vitejs/plugin-react/dist/index.cjs
generated
vendored
Normal file
343
web/node_modules/@vitejs/plugin-react/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
//#region rolldown:runtime
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
||||
key = keys[i];
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
||||
get: ((k) => from[k]).bind(null, key),
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
||||
});
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
||||
value: mod,
|
||||
enumerable: true
|
||||
}) : target, mod));
|
||||
|
||||
//#endregion
|
||||
const node_path = __toESM(require("node:path"));
|
||||
const node_url = __toESM(require("node:url"));
|
||||
const node_fs = __toESM(require("node:fs"));
|
||||
const vite = __toESM(require("vite"));
|
||||
const __rolldown_pluginutils = __toESM(require("@rolldown/pluginutils"));
|
||||
|
||||
//#region ../common/refresh-utils.ts
|
||||
const runtimePublicPath = "/@react-refresh";
|
||||
const reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
|
||||
const refreshContentRE = /\$RefreshReg\$\(/;
|
||||
const preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice(1)}";
|
||||
injectIntoGlobalHook(window);
|
||||
window.$RefreshReg$ = () => {};
|
||||
window.$RefreshSig$ = () => (type) => type;`;
|
||||
const getPreambleCode = (base) => preambleCode.replace("__BASE__", base);
|
||||
const avoidSourceMapOption = Symbol();
|
||||
function addRefreshWrapper(code, map, pluginName, id, reactRefreshHost = "") {
|
||||
const hasRefresh = refreshContentRE.test(code);
|
||||
const onlyReactComp = !hasRefresh && reactCompRE.test(code);
|
||||
const normalizedMap = map === avoidSourceMapOption ? null : map;
|
||||
if (!hasRefresh && !onlyReactComp) return {
|
||||
code,
|
||||
map: normalizedMap
|
||||
};
|
||||
const avoidSourceMap = map === avoidSourceMapOption;
|
||||
const newMap = typeof normalizedMap === "string" ? JSON.parse(normalizedMap) : normalizedMap;
|
||||
let newCode = code;
|
||||
if (hasRefresh) {
|
||||
const refreshHead = removeLineBreaksIfNeeded(`let prevRefreshReg;
|
||||
let prevRefreshSig;
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
if (!window.$RefreshReg$) {
|
||||
throw new Error(
|
||||
"${pluginName} can't detect preamble. Something is wrong."
|
||||
);
|
||||
}
|
||||
|
||||
prevRefreshReg = window.$RefreshReg$;
|
||||
prevRefreshSig = window.$RefreshSig$;
|
||||
window.$RefreshReg$ = RefreshRuntime.getRefreshReg(${JSON.stringify(id)});
|
||||
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
||||
}
|
||||
|
||||
`, avoidSourceMap);
|
||||
newCode = `${refreshHead}${newCode}
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
window.$RefreshReg$ = prevRefreshReg;
|
||||
window.$RefreshSig$ = prevRefreshSig;
|
||||
}
|
||||
`;
|
||||
if (newMap) newMap.mappings = ";".repeat(16) + newMap.mappings;
|
||||
}
|
||||
const sharedHead = removeLineBreaksIfNeeded(`import * as RefreshRuntime from "${reactRefreshHost}${runtimePublicPath}";
|
||||
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
||||
|
||||
`, avoidSourceMap);
|
||||
newCode = `${sharedHead}${newCode}
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
||||
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(id)}, currentExports);
|
||||
import.meta.hot.accept((nextExports) => {
|
||||
if (!nextExports) return;
|
||||
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(id)}, currentExports, nextExports);
|
||||
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
||||
});
|
||||
});
|
||||
}
|
||||
`;
|
||||
if (newMap) newMap.mappings = ";;;" + newMap.mappings;
|
||||
return {
|
||||
code: newCode,
|
||||
map: newMap
|
||||
};
|
||||
}
|
||||
function removeLineBreaksIfNeeded(code, enabled) {
|
||||
return enabled ? code.replace(/\n/g, "") : code;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region ../common/warning.ts
|
||||
const silenceUseClientWarning = (userConfig) => ({ rollupOptions: { onwarn(warning, defaultHandler) {
|
||||
var _userConfig$build;
|
||||
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) return;
|
||||
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) return;
|
||||
if ((_userConfig$build = userConfig.build) === null || _userConfig$build === void 0 || (_userConfig$build = _userConfig$build.rollupOptions) === null || _userConfig$build === void 0 ? void 0 : _userConfig$build.onwarn) userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
||||
else defaultHandler(warning);
|
||||
} } });
|
||||
|
||||
//#endregion
|
||||
//#region src/index.ts
|
||||
const _dirname = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
||||
const refreshRuntimePath = (0, node_path.join)(_dirname, "refresh-runtime.js");
|
||||
let babel;
|
||||
async function loadBabel() {
|
||||
if (!babel) babel = await import("@babel/core");
|
||||
return babel;
|
||||
}
|
||||
const defaultIncludeRE = /\.[tj]sx?$/;
|
||||
const tsRE = /\.tsx?$/;
|
||||
function viteReact(opts = {}) {
|
||||
var _opts$babel;
|
||||
const include = opts.include ?? defaultIncludeRE;
|
||||
const exclude = opts.exclude;
|
||||
const filter = (0, vite.createFilter)(include, exclude);
|
||||
const jsxImportSource = opts.jsxImportSource ?? "react";
|
||||
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
|
||||
const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
|
||||
let runningInVite = false;
|
||||
let isProduction = true;
|
||||
let projectRoot = process.cwd();
|
||||
let skipFastRefresh = true;
|
||||
let runPluginOverrides;
|
||||
let staticBabelOptions;
|
||||
const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
|
||||
const viteBabel = {
|
||||
name: "vite:react-babel",
|
||||
enforce: "pre",
|
||||
config() {
|
||||
if (opts.jsxRuntime === "classic") if ("rolldownVersion" in vite) return { oxc: { jsx: {
|
||||
runtime: "classic",
|
||||
development: false
|
||||
} } };
|
||||
else return { esbuild: { jsx: "transform" } };
|
||||
else return {
|
||||
esbuild: {
|
||||
jsx: "automatic",
|
||||
jsxImportSource: opts.jsxImportSource
|
||||
},
|
||||
optimizeDeps: "rolldownVersion" in vite ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
|
||||
};
|
||||
},
|
||||
configResolved(config) {
|
||||
runningInVite = true;
|
||||
projectRoot = config.root;
|
||||
isProduction = config.isProduction;
|
||||
skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
|
||||
if ("jsxPure" in opts) config.logger.warnOnce("[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.");
|
||||
const hooks = config.plugins.map((plugin) => {
|
||||
var _plugin$api;
|
||||
return (_plugin$api = plugin.api) === null || _plugin$api === void 0 ? void 0 : _plugin$api.reactBabel;
|
||||
}).filter(defined);
|
||||
if ("rolldownVersion" in vite && !opts.babel && !hooks.length && !opts.disableOxcRecommendation) config.logger.warn("[vite:react-babel] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown");
|
||||
if (hooks.length > 0) runPluginOverrides = (babelOptions, context) => {
|
||||
hooks.forEach((hook) => hook(babelOptions, context, config));
|
||||
};
|
||||
else if (typeof opts.babel !== "function") {
|
||||
staticBabelOptions = createBabelOptions(opts.babel);
|
||||
if (canSkipBabel(staticBabelOptions.plugins, staticBabelOptions) && skipFastRefresh && (opts.jsxRuntime === "classic" ? isProduction : true)) delete viteBabel.transform;
|
||||
}
|
||||
},
|
||||
options(options) {
|
||||
if (!runningInVite) {
|
||||
options.jsx = {
|
||||
mode: opts.jsxRuntime,
|
||||
importSource: opts.jsxImportSource
|
||||
};
|
||||
return options;
|
||||
}
|
||||
},
|
||||
transform: {
|
||||
filter: { id: {
|
||||
include: (0, __rolldown_pluginutils.makeIdFiltersToMatchWithQuery)(include),
|
||||
exclude: [...exclude ? (0, __rolldown_pluginutils.makeIdFiltersToMatchWithQuery)(ensureArray(exclude)) : [], /\/node_modules\//]
|
||||
} },
|
||||
async handler(code, id, options) {
|
||||
if (id.includes("/node_modules/")) return;
|
||||
const [filepath] = id.split("?");
|
||||
if (!filter(filepath)) return;
|
||||
const ssr = (options === null || options === void 0 ? void 0 : options.ssr) === true;
|
||||
const babelOptions = (() => {
|
||||
if (staticBabelOptions) return staticBabelOptions;
|
||||
const newBabelOptions = createBabelOptions(typeof opts.babel === "function" ? opts.babel(id, { ssr }) : opts.babel);
|
||||
runPluginOverrides === null || runPluginOverrides === void 0 || runPluginOverrides(newBabelOptions, {
|
||||
id,
|
||||
ssr
|
||||
});
|
||||
return newBabelOptions;
|
||||
})();
|
||||
const plugins = [...babelOptions.plugins];
|
||||
const isJSX = filepath.endsWith("x");
|
||||
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
|
||||
if (useFastRefresh) plugins.push([await loadPlugin("react-refresh/babel"), { skipEnvCheck: true }]);
|
||||
if (opts.jsxRuntime === "classic" && isJSX) {
|
||||
if (!isProduction) plugins.push(await loadPlugin("@babel/plugin-transform-react-jsx-self"), await loadPlugin("@babel/plugin-transform-react-jsx-source"));
|
||||
}
|
||||
if (canSkipBabel(plugins, babelOptions)) return;
|
||||
const parserPlugins = [...babelOptions.parserOpts.plugins];
|
||||
if (!filepath.endsWith(".ts")) parserPlugins.push("jsx");
|
||||
if (tsRE.test(filepath)) parserPlugins.push("typescript");
|
||||
const babel$1 = await loadBabel();
|
||||
const result = await babel$1.transformAsync(code, {
|
||||
...babelOptions,
|
||||
root: projectRoot,
|
||||
filename: id,
|
||||
sourceFileName: filepath,
|
||||
retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
|
||||
parserOpts: {
|
||||
...babelOptions.parserOpts,
|
||||
sourceType: "module",
|
||||
allowAwaitOutsideFunction: true,
|
||||
plugins: parserPlugins
|
||||
},
|
||||
generatorOpts: {
|
||||
...babelOptions.generatorOpts,
|
||||
importAttributesKeyword: "with",
|
||||
decoratorsBeforeExport: true
|
||||
},
|
||||
plugins,
|
||||
sourceMaps: true
|
||||
});
|
||||
if (result) {
|
||||
if (!useFastRefresh) return {
|
||||
code: result.code,
|
||||
map: result.map
|
||||
};
|
||||
return addRefreshWrapper(result.code, result.map, "@vitejs/plugin-react", id, opts.reactRefreshHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const dependencies = [
|
||||
"react",
|
||||
"react-dom",
|
||||
jsxImportDevRuntime,
|
||||
jsxImportRuntime
|
||||
];
|
||||
const staticBabelPlugins = typeof opts.babel === "object" ? ((_opts$babel = opts.babel) === null || _opts$babel === void 0 ? void 0 : _opts$babel.plugins) ?? [] : [];
|
||||
const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
|
||||
if (reactCompilerPlugin != null) {
|
||||
const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
|
||||
dependencies.push(reactCompilerRuntimeModule);
|
||||
}
|
||||
const viteReactRefresh = {
|
||||
name: "vite:react-refresh",
|
||||
enforce: "pre",
|
||||
config: (userConfig) => ({
|
||||
build: silenceUseClientWarning(userConfig),
|
||||
optimizeDeps: { include: dependencies },
|
||||
resolve: { dedupe: ["react", "react-dom"] }
|
||||
}),
|
||||
resolveId: {
|
||||
filter: { id: (0, __rolldown_pluginutils.exactRegex)(runtimePublicPath) },
|
||||
handler(id) {
|
||||
if (id === runtimePublicPath) return id;
|
||||
}
|
||||
},
|
||||
load: {
|
||||
filter: { id: (0, __rolldown_pluginutils.exactRegex)(runtimePublicPath) },
|
||||
handler(id) {
|
||||
if (id === runtimePublicPath) return (0, node_fs.readFileSync)(refreshRuntimePath, "utf-8").replace(/__README_URL__/g, "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react");
|
||||
}
|
||||
},
|
||||
transformIndexHtml(_, config) {
|
||||
if (!skipFastRefresh) return [{
|
||||
tag: "script",
|
||||
attrs: { type: "module" },
|
||||
children: getPreambleCode(config.server.config.base)
|
||||
}];
|
||||
}
|
||||
};
|
||||
return [viteBabel, viteReactRefresh];
|
||||
}
|
||||
viteReact.preambleCode = preambleCode;
|
||||
function canSkipBabel(plugins, babelOptions) {
|
||||
return !(plugins.length || babelOptions.presets.length || babelOptions.configFile || babelOptions.babelrc);
|
||||
}
|
||||
const loadedPlugin = /* @__PURE__ */ new Map();
|
||||
function loadPlugin(path) {
|
||||
const cached = loadedPlugin.get(path);
|
||||
if (cached) return cached;
|
||||
const promise = import(path).then((module$1) => {
|
||||
const value = module$1.default || module$1;
|
||||
loadedPlugin.set(path, value);
|
||||
return value;
|
||||
});
|
||||
loadedPlugin.set(path, promise);
|
||||
return promise;
|
||||
}
|
||||
function createBabelOptions(rawOptions) {
|
||||
var _babelOptions$parserO;
|
||||
const babelOptions = {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
...rawOptions
|
||||
};
|
||||
babelOptions.plugins || (babelOptions.plugins = []);
|
||||
babelOptions.presets || (babelOptions.presets = []);
|
||||
babelOptions.overrides || (babelOptions.overrides = []);
|
||||
babelOptions.parserOpts || (babelOptions.parserOpts = {});
|
||||
(_babelOptions$parserO = babelOptions.parserOpts).plugins || (_babelOptions$parserO.plugins = []);
|
||||
return babelOptions;
|
||||
}
|
||||
function defined(value) {
|
||||
return value !== void 0;
|
||||
}
|
||||
function getReactCompilerPlugin(plugins) {
|
||||
return plugins.find((p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler");
|
||||
}
|
||||
function getReactCompilerRuntimeModule(plugin) {
|
||||
let moduleName = "react/compiler-runtime";
|
||||
if (Array.isArray(plugin)) {
|
||||
var _plugin$, _plugin$2, _plugin$3;
|
||||
if (((_plugin$ = plugin[1]) === null || _plugin$ === void 0 ? void 0 : _plugin$.target) === "17" || ((_plugin$2 = plugin[1]) === null || _plugin$2 === void 0 ? void 0 : _plugin$2.target) === "18") moduleName = "react-compiler-runtime";
|
||||
else if (typeof ((_plugin$3 = plugin[1]) === null || _plugin$3 === void 0 ? void 0 : _plugin$3.runtimeModule) === "string") {
|
||||
var _plugin$4;
|
||||
moduleName = (_plugin$4 = plugin[1]) === null || _plugin$4 === void 0 ? void 0 : _plugin$4.runtimeModule;
|
||||
}
|
||||
}
|
||||
return moduleName;
|
||||
}
|
||||
function ensureArray(value) {
|
||||
return Array.isArray(value) ? value : [value];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
module.exports = viteReact;
|
||||
module.exports.default = module.exports
|
||||
67
web/node_modules/@vitejs/plugin-react/dist/index.d.cts
generated
vendored
Normal file
67
web/node_modules/@vitejs/plugin-react/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { ParserOptions, TransformOptions } from "@babel/core";
|
||||
import { Plugin, ResolvedConfig } from "vite";
|
||||
|
||||
//#region src/index.d.ts
|
||||
interface Options {
|
||||
include?: string | RegExp | Array<string | RegExp>;
|
||||
exclude?: string | RegExp | Array<string | RegExp>;
|
||||
/**
|
||||
* Control where the JSX factory is imported from.
|
||||
* https://esbuild.github.io/api/#jsx-import-source
|
||||
* @default 'react'
|
||||
*/
|
||||
jsxImportSource?: string;
|
||||
/**
|
||||
* Note: Skipping React import with classic runtime is not supported from v4
|
||||
* @default "automatic"
|
||||
*/
|
||||
jsxRuntime?: 'classic' | 'automatic';
|
||||
/**
|
||||
* Babel configuration applied in both dev and prod.
|
||||
*/
|
||||
babel?: BabelOptions | ((id: string, options: {
|
||||
ssr?: boolean;
|
||||
}) => BabelOptions);
|
||||
/**
|
||||
* React Fast Refresh runtime URL prefix.
|
||||
* Useful in a module federation context to enable HMR by specifying
|
||||
* the host application URL in the Vite config of a remote application.
|
||||
* @example
|
||||
* reactRefreshHost: 'http://localhost:3000'
|
||||
*/
|
||||
reactRefreshHost?: string;
|
||||
/**
|
||||
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
|
||||
*/
|
||||
disableOxcRecommendation?: boolean;
|
||||
}
|
||||
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
||||
/**
|
||||
* The object type used by the `options` passed to plugins with
|
||||
* an `api.reactBabel` method.
|
||||
*/
|
||||
interface ReactBabelOptions extends BabelOptions {
|
||||
plugins: Extract<BabelOptions['plugins'], any[]>;
|
||||
presets: Extract<BabelOptions['presets'], any[]>;
|
||||
overrides: Extract<BabelOptions['overrides'], any[]>;
|
||||
parserOpts: ParserOptions & {
|
||||
plugins: Extract<ParserOptions['plugins'], any[]>;
|
||||
};
|
||||
}
|
||||
type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
|
||||
type ReactBabelHookContext = {
|
||||
ssr: boolean;
|
||||
id: string;
|
||||
};
|
||||
type ViteReactPluginApi = {
|
||||
/**
|
||||
* Manipulate the Babel options of `@vitejs/plugin-react`
|
||||
*/
|
||||
reactBabel?: ReactBabelHook;
|
||||
};
|
||||
declare function viteReact(opts?: Options): Plugin[];
|
||||
declare namespace viteReact {
|
||||
var preambleCode: string;
|
||||
}
|
||||
//#endregion
|
||||
export { BabelOptions, Options, ReactBabelOptions, ViteReactPluginApi, viteReact as default };
|
||||
7
web/node_modules/@vitejs/plugin-react/dist/index.d.ts
generated
vendored
7
web/node_modules/@vitejs/plugin-react/dist/index.d.ts
generated
vendored
@@ -30,6 +30,10 @@ interface Options {
|
||||
* reactRefreshHost: 'http://localhost:3000'
|
||||
*/
|
||||
reactRefreshHost?: string;
|
||||
/**
|
||||
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
|
||||
*/
|
||||
disableOxcRecommendation?: boolean;
|
||||
}
|
||||
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
||||
/**
|
||||
@@ -59,6 +63,5 @@ declare function viteReact(opts?: Options): Plugin[];
|
||||
declare namespace viteReact {
|
||||
var preambleCode: string;
|
||||
}
|
||||
declare function viteReactForCjs(this: unknown, options: Options): Plugin[];
|
||||
//#endregion
|
||||
export { BabelOptions, Options, ReactBabelOptions, ViteReactPluginApi, viteReact as default, viteReactForCjs as "module.exports" };
|
||||
export { BabelOptions, Options, ReactBabelOptions, ViteReactPluginApi, viteReact as default };
|
||||
273
web/node_modules/@vitejs/plugin-react/dist/index.js
generated
vendored
273
web/node_modules/@vitejs/plugin-react/dist/index.js
generated
vendored
@@ -14,15 +14,22 @@ injectIntoGlobalHook(window);
|
||||
window.$RefreshReg$ = () => {};
|
||||
window.$RefreshSig$ = () => (type) => type;`;
|
||||
const getPreambleCode = (base) => preambleCode.replace("__BASE__", base);
|
||||
function addRefreshWrapper(code, pluginName, id, reactRefreshHost = "") {
|
||||
const avoidSourceMapOption = Symbol();
|
||||
function addRefreshWrapper(code, map, pluginName, id, reactRefreshHost = "") {
|
||||
const hasRefresh = refreshContentRE.test(code);
|
||||
const onlyReactComp = !hasRefresh && reactCompRE.test(code);
|
||||
if (!hasRefresh && !onlyReactComp) return void 0;
|
||||
const normalizedMap = map === avoidSourceMapOption ? null : map;
|
||||
if (!hasRefresh && !onlyReactComp) return {
|
||||
code,
|
||||
map: normalizedMap
|
||||
};
|
||||
const avoidSourceMap = map === avoidSourceMapOption;
|
||||
const newMap = typeof normalizedMap === "string" ? JSON.parse(normalizedMap) : normalizedMap;
|
||||
let newCode = code;
|
||||
newCode += `
|
||||
if (hasRefresh) {
|
||||
const refreshHead = removeLineBreaksIfNeeded(`let prevRefreshReg;
|
||||
let prevRefreshSig;
|
||||
|
||||
import * as RefreshRuntime from "${reactRefreshHost}${runtimePublicPath}";
|
||||
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
if (!window.$RefreshReg$) {
|
||||
throw new Error(
|
||||
@@ -30,6 +37,29 @@ if (import.meta.hot && !inWebWorker) {
|
||||
);
|
||||
}
|
||||
|
||||
prevRefreshReg = window.$RefreshReg$;
|
||||
prevRefreshSig = window.$RefreshSig$;
|
||||
window.$RefreshReg$ = RefreshRuntime.getRefreshReg(${JSON.stringify(id)});
|
||||
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
||||
}
|
||||
|
||||
`, avoidSourceMap);
|
||||
newCode = `${refreshHead}${newCode}
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
window.$RefreshReg$ = prevRefreshReg;
|
||||
window.$RefreshSig$ = prevRefreshSig;
|
||||
}
|
||||
`;
|
||||
if (newMap) newMap.mappings = ";".repeat(16) + newMap.mappings;
|
||||
}
|
||||
const sharedHead = removeLineBreaksIfNeeded(`import * as RefreshRuntime from "${reactRefreshHost}${runtimePublicPath}";
|
||||
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
||||
|
||||
`, avoidSourceMap);
|
||||
newCode = `${sharedHead}${newCode}
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
||||
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(id)}, currentExports);
|
||||
import.meta.hot.accept((nextExports) => {
|
||||
@@ -40,126 +70,92 @@ if (import.meta.hot && !inWebWorker) {
|
||||
});
|
||||
}
|
||||
`;
|
||||
if (hasRefresh) newCode += `function $RefreshReg$(type, id) { return RefreshRuntime.register(type, ${JSON.stringify(id)} + ' ' + id) }
|
||||
function $RefreshSig$() { return RefreshRuntime.createSignatureFunctionForTransform(); }
|
||||
`;
|
||||
return newCode;
|
||||
}
|
||||
function virtualPreamblePlugin({ name, isEnabled }) {
|
||||
if (newMap) newMap.mappings = ";;;" + newMap.mappings;
|
||||
return {
|
||||
name: "vite:react-virtual-preamble",
|
||||
resolveId: {
|
||||
order: "pre",
|
||||
filter: { id: exactRegex(name) },
|
||||
handler(source) {
|
||||
if (source === name) return "\0" + source;
|
||||
}
|
||||
},
|
||||
load: {
|
||||
filter: { id: exactRegex("\0" + name) },
|
||||
handler(id) {
|
||||
if (id === "\0" + name) {
|
||||
if (isEnabled()) return preambleCode.replace("__BASE__", "/");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
code: newCode,
|
||||
map: newMap
|
||||
};
|
||||
}
|
||||
function removeLineBreaksIfNeeded(code, enabled) {
|
||||
return enabled ? code.replace(/\n/g, "") : code;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region ../common/warning.ts
|
||||
const silenceUseClientWarning = (userConfig) => ({ rollupOptions: { onwarn(warning, defaultHandler) {
|
||||
var _userConfig$build;
|
||||
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) return;
|
||||
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) return;
|
||||
if (userConfig.build?.rollupOptions?.onwarn) userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
||||
if ((_userConfig$build = userConfig.build) === null || _userConfig$build === void 0 || (_userConfig$build = _userConfig$build.rollupOptions) === null || _userConfig$build === void 0 ? void 0 : _userConfig$build.onwarn) userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
||||
else defaultHandler(warning);
|
||||
} } });
|
||||
|
||||
//#endregion
|
||||
//#region src/index.ts
|
||||
const refreshRuntimePath = join(dirname(fileURLToPath(import.meta.url)), "refresh-runtime.js");
|
||||
const _dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const refreshRuntimePath = join(_dirname, "refresh-runtime.js");
|
||||
let babel;
|
||||
async function loadBabel() {
|
||||
if (!babel) babel = await import("@babel/core");
|
||||
return babel;
|
||||
}
|
||||
const defaultIncludeRE = /\.[tj]sx?$/;
|
||||
const defaultExcludeRE = /\/node_modules\//;
|
||||
const tsRE = /\.tsx?$/;
|
||||
const compilerAnnotationRE = /['"]use memo['"]/;
|
||||
function viteReact(opts = {}) {
|
||||
var _opts$babel;
|
||||
const include = opts.include ?? defaultIncludeRE;
|
||||
const exclude = opts.exclude ?? defaultExcludeRE;
|
||||
const exclude = opts.exclude;
|
||||
const filter = createFilter(include, exclude);
|
||||
const jsxImportSource = opts.jsxImportSource ?? "react";
|
||||
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
|
||||
const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
|
||||
const isRolldownVite = "rolldownVersion" in vite;
|
||||
let runningInVite = false;
|
||||
let isProduction = true;
|
||||
let projectRoot = process.cwd();
|
||||
let skipFastRefresh = true;
|
||||
let base;
|
||||
let isFullBundle = false;
|
||||
let runPluginOverrides;
|
||||
let staticBabelOptions;
|
||||
const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
|
||||
const viteBabel = {
|
||||
name: "vite:react-babel",
|
||||
enforce: "pre",
|
||||
config(_userConfig, { command }) {
|
||||
if ("rolldownVersion" in vite) if (opts.jsxRuntime === "classic") return { oxc: {
|
||||
jsx: {
|
||||
runtime: "classic",
|
||||
refresh: command === "serve",
|
||||
development: false
|
||||
},
|
||||
jsxRefreshInclude: makeIdFiltersToMatchWithQuery(include),
|
||||
jsxRefreshExclude: makeIdFiltersToMatchWithQuery(exclude)
|
||||
} };
|
||||
else return {
|
||||
oxc: {
|
||||
jsx: {
|
||||
runtime: "automatic",
|
||||
importSource: opts.jsxImportSource,
|
||||
refresh: command === "serve"
|
||||
},
|
||||
jsxRefreshInclude: makeIdFiltersToMatchWithQuery(include),
|
||||
jsxRefreshExclude: makeIdFiltersToMatchWithQuery(exclude)
|
||||
},
|
||||
optimizeDeps: { rolldownOptions: { transform: { jsx: { runtime: "automatic" } } } }
|
||||
};
|
||||
if (opts.jsxRuntime === "classic") return { esbuild: { jsx: "transform" } };
|
||||
config() {
|
||||
if (opts.jsxRuntime === "classic") if ("rolldownVersion" in vite) return { oxc: { jsx: {
|
||||
runtime: "classic",
|
||||
development: false
|
||||
} } };
|
||||
else return { esbuild: { jsx: "transform" } };
|
||||
else return {
|
||||
esbuild: {
|
||||
jsx: "automatic",
|
||||
jsxImportSource: opts.jsxImportSource
|
||||
},
|
||||
optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
|
||||
optimizeDeps: "rolldownVersion" in vite ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
|
||||
};
|
||||
},
|
||||
configResolved(config) {
|
||||
runningInVite = true;
|
||||
base = config.base;
|
||||
if (config.experimental.fullBundleMode) isFullBundle = true;
|
||||
projectRoot = config.root;
|
||||
isProduction = config.isProduction;
|
||||
skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
|
||||
const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(defined);
|
||||
if ("jsxPure" in opts) config.logger.warnOnce("[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.");
|
||||
const hooks = config.plugins.map((plugin) => {
|
||||
var _plugin$api;
|
||||
return (_plugin$api = plugin.api) === null || _plugin$api === void 0 ? void 0 : _plugin$api.reactBabel;
|
||||
}).filter(defined);
|
||||
if ("rolldownVersion" in vite && !opts.babel && !hooks.length && !opts.disableOxcRecommendation) config.logger.warn("[vite:react-babel] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance. More information at https://vite.dev/rolldown");
|
||||
if (hooks.length > 0) runPluginOverrides = (babelOptions, context) => {
|
||||
hooks.forEach((hook) => hook(babelOptions, context, config));
|
||||
};
|
||||
else if (typeof opts.babel !== "function") {
|
||||
staticBabelOptions = createBabelOptions(opts.babel);
|
||||
if ((isRolldownVite || skipFastRefresh) && canSkipBabel(staticBabelOptions.plugins, staticBabelOptions) && (opts.jsxRuntime === "classic" ? isProduction : true)) delete viteBabel.transform;
|
||||
if (canSkipBabel(staticBabelOptions.plugins, staticBabelOptions) && skipFastRefresh && (opts.jsxRuntime === "classic" ? isProduction : true)) delete viteBabel.transform;
|
||||
}
|
||||
},
|
||||
options(options) {
|
||||
if (!runningInVite) {
|
||||
options.transform ??= {};
|
||||
options.transform.jsx = {
|
||||
runtime: opts.jsxRuntime,
|
||||
options.jsx = {
|
||||
mode: opts.jsxRuntime,
|
||||
importSource: opts.jsxImportSource
|
||||
};
|
||||
return options;
|
||||
@@ -168,33 +164,25 @@ function viteReact(opts = {}) {
|
||||
transform: {
|
||||
filter: { id: {
|
||||
include: makeIdFiltersToMatchWithQuery(include),
|
||||
exclude: makeIdFiltersToMatchWithQuery(exclude)
|
||||
exclude: [...exclude ? makeIdFiltersToMatchWithQuery(ensureArray(exclude)) : [], /\/node_modules\//]
|
||||
} },
|
||||
async handler(code, id, options) {
|
||||
if (id.includes("/node_modules/")) return;
|
||||
const [filepath] = id.split("?");
|
||||
if (!filter(filepath)) return;
|
||||
const ssr = options?.ssr === true;
|
||||
const ssr = (options === null || options === void 0 ? void 0 : options.ssr) === true;
|
||||
const babelOptions = (() => {
|
||||
if (staticBabelOptions) return staticBabelOptions;
|
||||
const newBabelOptions = createBabelOptions(typeof opts.babel === "function" ? opts.babel(id, { ssr }) : opts.babel);
|
||||
runPluginOverrides?.(newBabelOptions, {
|
||||
runPluginOverrides === null || runPluginOverrides === void 0 || runPluginOverrides(newBabelOptions, {
|
||||
id,
|
||||
ssr
|
||||
});
|
||||
return newBabelOptions;
|
||||
})();
|
||||
const plugins = [...babelOptions.plugins];
|
||||
let reactCompilerPlugin$1 = getReactCompilerPlugin(plugins);
|
||||
if (reactCompilerPlugin$1 && ssr) {
|
||||
plugins.splice(plugins.indexOf(reactCompilerPlugin$1), 1);
|
||||
reactCompilerPlugin$1 = void 0;
|
||||
}
|
||||
if (Array.isArray(reactCompilerPlugin$1) && reactCompilerPlugin$1[1]?.compilationMode === "annotation" && !compilerAnnotationRE.test(code)) {
|
||||
plugins.splice(plugins.indexOf(reactCompilerPlugin$1), 1);
|
||||
reactCompilerPlugin$1 = void 0;
|
||||
}
|
||||
const isJSX = filepath.endsWith("x");
|
||||
const useFastRefresh = !(isRolldownVite || skipFastRefresh) && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
|
||||
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
|
||||
if (useFastRefresh) plugins.push([await loadPlugin("react-refresh/babel"), { skipEnvCheck: true }]);
|
||||
if (opts.jsxRuntime === "classic" && isJSX) {
|
||||
if (!isProduction) plugins.push(await loadPlugin("@babel/plugin-transform-react-jsx-self"), await loadPlugin("@babel/plugin-transform-react-jsx-source"));
|
||||
@@ -203,12 +191,13 @@ function viteReact(opts = {}) {
|
||||
const parserPlugins = [...babelOptions.parserOpts.plugins];
|
||||
if (!filepath.endsWith(".ts")) parserPlugins.push("jsx");
|
||||
if (tsRE.test(filepath)) parserPlugins.push("typescript");
|
||||
const result = await (await loadBabel()).transformAsync(code, {
|
||||
const babel$1 = await loadBabel();
|
||||
const result = await babel$1.transformAsync(code, {
|
||||
...babelOptions,
|
||||
root: projectRoot,
|
||||
filename: id,
|
||||
sourceFileName: filepath,
|
||||
retainLines: reactCompilerPlugin$1 ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
|
||||
retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
|
||||
parserOpts: {
|
||||
...babelOptions.parserOpts,
|
||||
sourceType: "module",
|
||||
@@ -228,83 +217,19 @@ function viteReact(opts = {}) {
|
||||
code: result.code,
|
||||
map: result.map
|
||||
};
|
||||
return {
|
||||
code: addRefreshWrapper(result.code, "@vitejs/plugin-react", id, opts.reactRefreshHost) ?? result.code,
|
||||
map: result.map
|
||||
};
|
||||
return addRefreshWrapper(result.code, result.map, "@vitejs/plugin-react", id, opts.reactRefreshHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const viteRefreshWrapper = {
|
||||
name: "vite:react:refresh-wrapper",
|
||||
apply: "serve",
|
||||
async applyToEnvironment(env) {
|
||||
if (env.config.consumer !== "client" || skipFastRefresh) return false;
|
||||
let nativePlugin;
|
||||
try {
|
||||
nativePlugin = (await import("vite/internal")).reactRefreshWrapperPlugin;
|
||||
} catch {}
|
||||
if (!nativePlugin || [
|
||||
"7.1.10",
|
||||
"7.1.11",
|
||||
"7.1.12"
|
||||
].includes(vite.version)) return true;
|
||||
delete viteRefreshWrapper.transform;
|
||||
return nativePlugin({
|
||||
cwd: process.cwd(),
|
||||
include: makeIdFiltersToMatchWithQuery(include),
|
||||
exclude: makeIdFiltersToMatchWithQuery(exclude),
|
||||
jsxImportSource,
|
||||
reactRefreshHost: opts.reactRefreshHost ?? ""
|
||||
});
|
||||
},
|
||||
transform: {
|
||||
filter: { id: {
|
||||
include: makeIdFiltersToMatchWithQuery(include),
|
||||
exclude: makeIdFiltersToMatchWithQuery(exclude)
|
||||
} },
|
||||
handler(code, id, options) {
|
||||
const ssr = options?.ssr === true;
|
||||
const [filepath] = id.split("?");
|
||||
const isJSX = filepath.endsWith("x");
|
||||
if (!(!skipFastRefresh && !ssr && (isJSX || code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)))) return;
|
||||
const newCode = addRefreshWrapper(code, "@vitejs/plugin-react", id, opts.reactRefreshHost);
|
||||
return newCode ? {
|
||||
code: newCode,
|
||||
map: null
|
||||
} : void 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
const viteConfigPost = {
|
||||
name: "vite:react:config-post",
|
||||
enforce: "post",
|
||||
config(userConfig) {
|
||||
if (userConfig.server?.hmr === false) return { oxc: { jsx: { refresh: false } } };
|
||||
}
|
||||
};
|
||||
const viteReactRefreshFullBundleMode = {
|
||||
name: "vite:react-refresh-fbm",
|
||||
enforce: "pre",
|
||||
transformIndexHtml: {
|
||||
handler() {
|
||||
if (!skipFastRefresh && isFullBundle) return [{
|
||||
tag: "script",
|
||||
attrs: { type: "module" },
|
||||
children: getPreambleCode(base)
|
||||
}];
|
||||
},
|
||||
order: "pre"
|
||||
}
|
||||
};
|
||||
const dependencies = [
|
||||
"react",
|
||||
"react-dom",
|
||||
jsxImportDevRuntime,
|
||||
jsxImportRuntime
|
||||
];
|
||||
const reactCompilerPlugin = getReactCompilerPlugin(typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : []);
|
||||
const staticBabelPlugins = typeof opts.babel === "object" ? ((_opts$babel = opts.babel) === null || _opts$babel === void 0 ? void 0 : _opts$babel.plugins) ?? [] : [];
|
||||
const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
|
||||
if (reactCompilerPlugin != null) {
|
||||
const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
|
||||
dependencies.push(reactCompilerRuntimeModule);
|
||||
@@ -314,7 +239,8 @@ function viteReact(opts = {}) {
|
||||
enforce: "pre",
|
||||
config: (userConfig) => ({
|
||||
build: silenceUseClientWarning(userConfig),
|
||||
optimizeDeps: { include: dependencies }
|
||||
optimizeDeps: { include: dependencies },
|
||||
resolve: { dedupe: ["react", "react-dom"] }
|
||||
}),
|
||||
resolveId: {
|
||||
filter: { id: exactRegex(runtimePublicPath) },
|
||||
@@ -328,33 +254,17 @@ function viteReact(opts = {}) {
|
||||
if (id === runtimePublicPath) return readFileSync(refreshRuntimePath, "utf-8").replace(/__README_URL__/g, "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react");
|
||||
}
|
||||
},
|
||||
transformIndexHtml() {
|
||||
if (!skipFastRefresh && !isFullBundle) return [{
|
||||
transformIndexHtml(_, config) {
|
||||
if (!skipFastRefresh) return [{
|
||||
tag: "script",
|
||||
attrs: { type: "module" },
|
||||
children: getPreambleCode(base)
|
||||
children: getPreambleCode(config.server.config.base)
|
||||
}];
|
||||
}
|
||||
};
|
||||
return [
|
||||
viteBabel,
|
||||
...isRolldownVite ? [
|
||||
viteRefreshWrapper,
|
||||
viteConfigPost,
|
||||
viteReactRefreshFullBundleMode
|
||||
] : [],
|
||||
viteReactRefresh,
|
||||
virtualPreamblePlugin({
|
||||
name: "@vitejs/plugin-react/preamble",
|
||||
isEnabled: () => !skipFastRefresh && !isFullBundle
|
||||
})
|
||||
];
|
||||
return [viteBabel, viteReactRefresh];
|
||||
}
|
||||
viteReact.preambleCode = preambleCode;
|
||||
function viteReactForCjs(options) {
|
||||
return viteReact.call(this, options);
|
||||
}
|
||||
Object.assign(viteReactForCjs, { default: viteReactForCjs });
|
||||
function canSkipBabel(plugins, babelOptions) {
|
||||
return !(plugins.length || babelOptions.presets.length || babelOptions.configFile || babelOptions.babelrc);
|
||||
}
|
||||
@@ -371,16 +281,17 @@ function loadPlugin(path) {
|
||||
return promise;
|
||||
}
|
||||
function createBabelOptions(rawOptions) {
|
||||
var _babelOptions$parserO;
|
||||
const babelOptions = {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
...rawOptions
|
||||
};
|
||||
babelOptions.plugins ||= [];
|
||||
babelOptions.presets ||= [];
|
||||
babelOptions.overrides ||= [];
|
||||
babelOptions.parserOpts ||= {};
|
||||
babelOptions.parserOpts.plugins ||= [];
|
||||
babelOptions.plugins || (babelOptions.plugins = []);
|
||||
babelOptions.presets || (babelOptions.presets = []);
|
||||
babelOptions.overrides || (babelOptions.overrides = []);
|
||||
babelOptions.parserOpts || (babelOptions.parserOpts = {});
|
||||
(_babelOptions$parserO = babelOptions.parserOpts).plugins || (_babelOptions$parserO.plugins = []);
|
||||
return babelOptions;
|
||||
}
|
||||
function defined(value) {
|
||||
@@ -392,10 +303,18 @@ function getReactCompilerPlugin(plugins) {
|
||||
function getReactCompilerRuntimeModule(plugin) {
|
||||
let moduleName = "react/compiler-runtime";
|
||||
if (Array.isArray(plugin)) {
|
||||
if (plugin[1]?.target === "17" || plugin[1]?.target === "18") moduleName = "react-compiler-runtime";
|
||||
var _plugin$, _plugin$2, _plugin$3;
|
||||
if (((_plugin$ = plugin[1]) === null || _plugin$ === void 0 ? void 0 : _plugin$.target) === "17" || ((_plugin$2 = plugin[1]) === null || _plugin$2 === void 0 ? void 0 : _plugin$2.target) === "18") moduleName = "react-compiler-runtime";
|
||||
else if (typeof ((_plugin$3 = plugin[1]) === null || _plugin$3 === void 0 ? void 0 : _plugin$3.runtimeModule) === "string") {
|
||||
var _plugin$4;
|
||||
moduleName = (_plugin$4 = plugin[1]) === null || _plugin$4 === void 0 ? void 0 : _plugin$4.runtimeModule;
|
||||
}
|
||||
}
|
||||
return moduleName;
|
||||
}
|
||||
function ensureArray(value) {
|
||||
return Array.isArray(value) ? value : [value];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { viteReact as default, viteReactForCjs as "module.exports" };
|
||||
export { viteReact as default };
|
||||
9
web/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js
generated
vendored
9
web/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js
generated
vendored
@@ -243,7 +243,7 @@ function performReactRefresh() {
|
||||
}
|
||||
}
|
||||
|
||||
export function register(type, id) {
|
||||
function register(type, id) {
|
||||
if (type === null) {
|
||||
return
|
||||
}
|
||||
@@ -564,6 +564,10 @@ function isPlainObject(obj) {
|
||||
* Plugin utils
|
||||
*/
|
||||
|
||||
export function getRefreshReg(filename) {
|
||||
return (type, id) => register(type, filename + ' ' + id)
|
||||
}
|
||||
|
||||
// Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141
|
||||
// This allows to resister components not detected by SWC like styled component
|
||||
export function registerExportsForReactRefresh(filename, moduleExports) {
|
||||
@@ -649,7 +653,10 @@ export function validateRefreshBoundaryAndEnqueueUpdate(
|
||||
|
||||
function predicateOnExport(ignoredExports, moduleExports, predicate) {
|
||||
for (const key in moduleExports) {
|
||||
if (key === '__esModule') continue
|
||||
if (ignoredExports.includes(key)) continue
|
||||
const desc = Object.getOwnPropertyDescriptor(moduleExports, key)
|
||||
if (desc && desc.get) return key
|
||||
if (!predicate(key, moduleExports[key])) return key
|
||||
}
|
||||
return true
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user