mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 19:02:29 +00:00
chore: update frontend build for v1.1.81 [skip ci]
This commit is contained in:
21
web/admin-spa/node_modules/local-pkg/LICENSE
generated
vendored
Normal file
21
web/admin-spa/node_modules/local-pkg/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
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.
|
||||
55
web/admin-spa/node_modules/local-pkg/README.md
generated
vendored
Normal file
55
web/admin-spa/node_modules/local-pkg/README.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# local-pkg
|
||||
|
||||
[](https://www.npmjs.com/package/local-pkg)
|
||||
|
||||
Get information on local packages. Works on both CJS and ESM.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i local-pkg
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import {
|
||||
getPackageInfo,
|
||||
importModule,
|
||||
isPackageExists,
|
||||
resolveModule,
|
||||
} from 'local-pkg'
|
||||
|
||||
isPackageExists('local-pkg') // true
|
||||
isPackageExists('foo') // false
|
||||
|
||||
await getPackageInfo('local-pkg')
|
||||
/* {
|
||||
* name: "local-pkg",
|
||||
* version: "0.1.0",
|
||||
* rootPath: "/path/to/node_modules/local-pkg",
|
||||
* packageJson: {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
// similar to `require.resolve` but works also in ESM
|
||||
resolveModule('local-pkg')
|
||||
// '/path/to/node_modules/local-pkg/dist/index.cjs'
|
||||
|
||||
// similar to `await import()` but works also in CJS
|
||||
const { importModule } = await importModule('local-pkg')
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)
|
||||
409
web/admin-spa/node_modules/local-pkg/dist/index.cjs
generated
vendored
Normal file
409
web/admin-spa/node_modules/local-pkg/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,409 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('node:fs');
|
||||
const fsp = require('node:fs/promises');
|
||||
const node_module = require('node:module');
|
||||
const path = require('node:path');
|
||||
const process = require('node:process');
|
||||
const node_url = require('node:url');
|
||||
const mlly = require('mlly');
|
||||
|
||||
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
||||
|
||||
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
||||
const fsp__default = /*#__PURE__*/_interopDefaultCompat(fsp);
|
||||
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
||||
const process__default = /*#__PURE__*/_interopDefaultCompat(process);
|
||||
|
||||
/*
|
||||
How it works:
|
||||
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
||||
*/
|
||||
|
||||
class Node {
|
||||
value;
|
||||
next;
|
||||
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class Queue {
|
||||
#head;
|
||||
#tail;
|
||||
#size;
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
enqueue(value) {
|
||||
const node = new Node(value);
|
||||
|
||||
if (this.#head) {
|
||||
this.#tail.next = node;
|
||||
this.#tail = node;
|
||||
} else {
|
||||
this.#head = node;
|
||||
this.#tail = node;
|
||||
}
|
||||
|
||||
this.#size++;
|
||||
}
|
||||
|
||||
dequeue() {
|
||||
const current = this.#head;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#head = this.#head.next;
|
||||
this.#size--;
|
||||
return current.value;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#head = undefined;
|
||||
this.#tail = undefined;
|
||||
this.#size = 0;
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.#size;
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.#head;
|
||||
|
||||
while (current) {
|
||||
yield current.value;
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pLimit(concurrency) {
|
||||
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
||||
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
||||
}
|
||||
|
||||
const queue = new Queue();
|
||||
let activeCount = 0;
|
||||
|
||||
const next = () => {
|
||||
activeCount--;
|
||||
|
||||
if (queue.size > 0) {
|
||||
queue.dequeue()();
|
||||
}
|
||||
};
|
||||
|
||||
const run = async (fn, resolve, args) => {
|
||||
activeCount++;
|
||||
|
||||
const result = (async () => fn(...args))();
|
||||
|
||||
resolve(result);
|
||||
|
||||
try {
|
||||
await result;
|
||||
} catch {}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
const enqueue = (fn, resolve, args) => {
|
||||
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
||||
|
||||
(async () => {
|
||||
// This function needs to wait until the next microtask before comparing
|
||||
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
||||
// when the run function is dequeued and called. The comparison in the if-statement
|
||||
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
||||
await Promise.resolve();
|
||||
|
||||
if (activeCount < concurrency && queue.size > 0) {
|
||||
queue.dequeue()();
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
const generator = (fn, ...args) => new Promise(resolve => {
|
||||
enqueue(fn, resolve, args);
|
||||
});
|
||||
|
||||
Object.defineProperties(generator, {
|
||||
activeCount: {
|
||||
get: () => activeCount,
|
||||
},
|
||||
pendingCount: {
|
||||
get: () => queue.size,
|
||||
},
|
||||
clearQueue: {
|
||||
value: () => {
|
||||
queue.clear();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return generator;
|
||||
}
|
||||
|
||||
class EndError extends Error {
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
// The input can also be a promise, so we await it.
|
||||
const testElement = async (element, tester) => tester(await element);
|
||||
|
||||
// The input can also be a promise, so we `Promise.all()` them both.
|
||||
const finder = async element => {
|
||||
const values = await Promise.all(element);
|
||||
if (values[1] === true) {
|
||||
throw new EndError(values[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
async function pLocate(
|
||||
iterable,
|
||||
tester,
|
||||
{
|
||||
concurrency = Number.POSITIVE_INFINITY,
|
||||
preserveOrder = true,
|
||||
} = {},
|
||||
) {
|
||||
const limit = pLimit(concurrency);
|
||||
|
||||
// Start all the promises concurrently with optional limit.
|
||||
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
||||
|
||||
// Check the promises either serially or concurrently.
|
||||
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
||||
|
||||
try {
|
||||
await Promise.all(items.map(element => checkLimit(finder, element)));
|
||||
} catch (error) {
|
||||
if (error instanceof EndError) {
|
||||
return error.value;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const typeMappings = {
|
||||
directory: 'isDirectory',
|
||||
file: 'isFile',
|
||||
};
|
||||
|
||||
function checkType(type) {
|
||||
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Invalid type specified: ${type}`);
|
||||
}
|
||||
|
||||
const matchType = (type, stat) => stat[typeMappings[type]]();
|
||||
|
||||
const toPath$1 = urlOrPath => urlOrPath instanceof URL ? node_url.fileURLToPath(urlOrPath) : urlOrPath;
|
||||
|
||||
async function locatePath(
|
||||
paths,
|
||||
{
|
||||
cwd = process__default.cwd(),
|
||||
type = 'file',
|
||||
allowSymlinks = true,
|
||||
concurrency,
|
||||
preserveOrder,
|
||||
} = {},
|
||||
) {
|
||||
checkType(type);
|
||||
cwd = toPath$1(cwd);
|
||||
|
||||
const statFunction = allowSymlinks ? fs.promises.stat : fs.promises.lstat;
|
||||
|
||||
return pLocate(paths, async path_ => {
|
||||
try {
|
||||
const stat = await statFunction(path__default.resolve(cwd, path_));
|
||||
return matchType(type, stat);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, {concurrency, preserveOrder});
|
||||
}
|
||||
|
||||
const toPath = urlOrPath => urlOrPath instanceof URL ? node_url.fileURLToPath(urlOrPath) : urlOrPath;
|
||||
|
||||
const findUpStop = Symbol('findUpStop');
|
||||
|
||||
async function findUpMultiple(name, options = {}) {
|
||||
let directory = path__default.resolve(toPath(options.cwd) || '');
|
||||
const {root} = path__default.parse(directory);
|
||||
const stopAt = path__default.resolve(directory, options.stopAt || root);
|
||||
const limit = options.limit || Number.POSITIVE_INFINITY;
|
||||
const paths = [name].flat();
|
||||
|
||||
const runMatcher = async locateOptions => {
|
||||
if (typeof name !== 'function') {
|
||||
return locatePath(paths, locateOptions);
|
||||
}
|
||||
|
||||
const foundPath = await name(locateOptions.cwd);
|
||||
if (typeof foundPath === 'string') {
|
||||
return locatePath([foundPath], locateOptions);
|
||||
}
|
||||
|
||||
return foundPath;
|
||||
};
|
||||
|
||||
const matches = [];
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const foundPath = await runMatcher({...options, cwd: directory});
|
||||
|
||||
if (foundPath === findUpStop) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (foundPath) {
|
||||
matches.push(path__default.resolve(directory, foundPath));
|
||||
}
|
||||
|
||||
if (directory === stopAt || matches.length >= limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path__default.dirname(directory);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
async function findUp(name, options = {}) {
|
||||
const matches = await findUpMultiple(name, {...options, limit: 1});
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
function _resolve(path$1, options = {}) {
|
||||
if (options.platform === "auto" || !options.platform)
|
||||
options.platform = process__default.platform === "win32" ? "win32" : "posix";
|
||||
if (process__default.versions.pnp) {
|
||||
const paths = options.paths || [];
|
||||
if (paths.length === 0)
|
||||
paths.push(process__default.cwd());
|
||||
const targetRequire = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
||||
try {
|
||||
return targetRequire.resolve(path$1, { paths });
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
const modulePath = mlly.resolvePathSync(path$1, {
|
||||
url: options.paths
|
||||
});
|
||||
if (options.platform === "win32")
|
||||
return path.win32.normalize(modulePath);
|
||||
return modulePath;
|
||||
}
|
||||
function resolveModule(name, options = {}) {
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
async function importModule(path) {
|
||||
const i = await import(path);
|
||||
if (i)
|
||||
return mlly.interopDefault(i);
|
||||
return i;
|
||||
}
|
||||
function isPackageExists(name, options = {}) {
|
||||
return !!resolvePackage(name, options);
|
||||
}
|
||||
function getPackageJsonPath(name, options = {}) {
|
||||
const entry = resolvePackage(name, options);
|
||||
if (!entry)
|
||||
return;
|
||||
return searchPackageJSON(entry);
|
||||
}
|
||||
async function getPackageInfo(name, options = {}) {
|
||||
const packageJsonPath = getPackageJsonPath(name, options);
|
||||
if (!packageJsonPath)
|
||||
return;
|
||||
const packageJson = JSON.parse(await fs__default.promises.readFile(packageJsonPath, "utf8"));
|
||||
return {
|
||||
name,
|
||||
version: packageJson.version,
|
||||
rootPath: path.dirname(packageJsonPath),
|
||||
packageJsonPath,
|
||||
packageJson
|
||||
};
|
||||
}
|
||||
function getPackageInfoSync(name, options = {}) {
|
||||
const packageJsonPath = getPackageJsonPath(name, options);
|
||||
if (!packageJsonPath)
|
||||
return;
|
||||
const packageJson = JSON.parse(fs__default.readFileSync(packageJsonPath, "utf8"));
|
||||
return {
|
||||
name,
|
||||
version: packageJson.version,
|
||||
rootPath: path.dirname(packageJsonPath),
|
||||
packageJsonPath,
|
||||
packageJson
|
||||
};
|
||||
}
|
||||
function resolvePackage(name, options = {}) {
|
||||
try {
|
||||
return _resolve(`${name}/package.json`, options);
|
||||
} catch {
|
||||
}
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch (e) {
|
||||
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND")
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function searchPackageJSON(dir) {
|
||||
let packageJsonPath;
|
||||
while (true) {
|
||||
if (!dir)
|
||||
return;
|
||||
const newDir = path.dirname(dir);
|
||||
if (newDir === dir)
|
||||
return;
|
||||
dir = newDir;
|
||||
packageJsonPath = path.join(dir, "package.json");
|
||||
if (fs__default.existsSync(packageJsonPath))
|
||||
break;
|
||||
}
|
||||
return packageJsonPath;
|
||||
}
|
||||
async function loadPackageJSON(cwd = process__default.cwd()) {
|
||||
const path = await findUp("package.json", { cwd });
|
||||
if (!path || !fs__default.existsSync(path))
|
||||
return null;
|
||||
return JSON.parse(await fsp__default.readFile(path, "utf-8"));
|
||||
}
|
||||
async function isPackageListed(name, cwd) {
|
||||
const pkg = await loadPackageJSON(cwd) || {};
|
||||
return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
|
||||
}
|
||||
|
||||
exports.getPackageInfo = getPackageInfo;
|
||||
exports.getPackageInfoSync = getPackageInfoSync;
|
||||
exports.importModule = importModule;
|
||||
exports.isPackageExists = isPackageExists;
|
||||
exports.isPackageListed = isPackageListed;
|
||||
exports.loadPackageJSON = loadPackageJSON;
|
||||
exports.resolveModule = resolveModule;
|
||||
38
web/admin-spa/node_modules/local-pkg/dist/index.d.cts
generated
vendored
Normal file
38
web/admin-spa/node_modules/local-pkg/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { PackageJson } from 'pkg-types';
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
version: string;
|
||||
packageJson: PackageJson;
|
||||
}
|
||||
interface PackageResolvingOptions {
|
||||
paths?: string[];
|
||||
/**
|
||||
* @default 'auto'
|
||||
* Resolve path as posix or win32
|
||||
*/
|
||||
platform?: 'posix' | 'win32' | 'auto';
|
||||
}
|
||||
declare function resolveModule(name: string, options?: PackageResolvingOptions): string | undefined;
|
||||
declare function importModule<T = any>(path: string): Promise<T>;
|
||||
declare function isPackageExists(name: string, options?: PackageResolvingOptions): boolean;
|
||||
declare function getPackageInfo(name: string, options?: PackageResolvingOptions): Promise<{
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined>;
|
||||
declare function getPackageInfoSync(name: string, options?: PackageResolvingOptions): {
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined;
|
||||
declare function loadPackageJSON(cwd?: string): Promise<PackageJson | null>;
|
||||
declare function isPackageListed(name: string, cwd?: string): Promise<boolean>;
|
||||
|
||||
export { type PackageInfo, type PackageResolvingOptions, getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, loadPackageJSON, resolveModule };
|
||||
38
web/admin-spa/node_modules/local-pkg/dist/index.d.mts
generated
vendored
Normal file
38
web/admin-spa/node_modules/local-pkg/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { PackageJson } from 'pkg-types';
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
version: string;
|
||||
packageJson: PackageJson;
|
||||
}
|
||||
interface PackageResolvingOptions {
|
||||
paths?: string[];
|
||||
/**
|
||||
* @default 'auto'
|
||||
* Resolve path as posix or win32
|
||||
*/
|
||||
platform?: 'posix' | 'win32' | 'auto';
|
||||
}
|
||||
declare function resolveModule(name: string, options?: PackageResolvingOptions): string | undefined;
|
||||
declare function importModule<T = any>(path: string): Promise<T>;
|
||||
declare function isPackageExists(name: string, options?: PackageResolvingOptions): boolean;
|
||||
declare function getPackageInfo(name: string, options?: PackageResolvingOptions): Promise<{
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined>;
|
||||
declare function getPackageInfoSync(name: string, options?: PackageResolvingOptions): {
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined;
|
||||
declare function loadPackageJSON(cwd?: string): Promise<PackageJson | null>;
|
||||
declare function isPackageListed(name: string, cwd?: string): Promise<boolean>;
|
||||
|
||||
export { type PackageInfo, type PackageResolvingOptions, getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, loadPackageJSON, resolveModule };
|
||||
38
web/admin-spa/node_modules/local-pkg/dist/index.d.ts
generated
vendored
Normal file
38
web/admin-spa/node_modules/local-pkg/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { PackageJson } from 'pkg-types';
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
version: string;
|
||||
packageJson: PackageJson;
|
||||
}
|
||||
interface PackageResolvingOptions {
|
||||
paths?: string[];
|
||||
/**
|
||||
* @default 'auto'
|
||||
* Resolve path as posix or win32
|
||||
*/
|
||||
platform?: 'posix' | 'win32' | 'auto';
|
||||
}
|
||||
declare function resolveModule(name: string, options?: PackageResolvingOptions): string | undefined;
|
||||
declare function importModule<T = any>(path: string): Promise<T>;
|
||||
declare function isPackageExists(name: string, options?: PackageResolvingOptions): boolean;
|
||||
declare function getPackageInfo(name: string, options?: PackageResolvingOptions): Promise<{
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined>;
|
||||
declare function getPackageInfoSync(name: string, options?: PackageResolvingOptions): {
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined;
|
||||
declare function loadPackageJSON(cwd?: string): Promise<PackageJson | null>;
|
||||
declare function isPackageListed(name: string, cwd?: string): Promise<boolean>;
|
||||
|
||||
export { type PackageInfo, type PackageResolvingOptions, getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, loadPackageJSON, resolveModule };
|
||||
393
web/admin-spa/node_modules/local-pkg/dist/index.mjs
generated
vendored
Normal file
393
web/admin-spa/node_modules/local-pkg/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,393 @@
|
||||
import fs, { promises } from 'node:fs';
|
||||
import fsp from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
import path, { dirname, win32, join } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { interopDefault, resolvePathSync } from 'mlly';
|
||||
|
||||
/*
|
||||
How it works:
|
||||
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
||||
*/
|
||||
|
||||
class Node {
|
||||
value;
|
||||
next;
|
||||
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class Queue {
|
||||
#head;
|
||||
#tail;
|
||||
#size;
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
enqueue(value) {
|
||||
const node = new Node(value);
|
||||
|
||||
if (this.#head) {
|
||||
this.#tail.next = node;
|
||||
this.#tail = node;
|
||||
} else {
|
||||
this.#head = node;
|
||||
this.#tail = node;
|
||||
}
|
||||
|
||||
this.#size++;
|
||||
}
|
||||
|
||||
dequeue() {
|
||||
const current = this.#head;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#head = this.#head.next;
|
||||
this.#size--;
|
||||
return current.value;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#head = undefined;
|
||||
this.#tail = undefined;
|
||||
this.#size = 0;
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.#size;
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.#head;
|
||||
|
||||
while (current) {
|
||||
yield current.value;
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pLimit(concurrency) {
|
||||
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
||||
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
||||
}
|
||||
|
||||
const queue = new Queue();
|
||||
let activeCount = 0;
|
||||
|
||||
const next = () => {
|
||||
activeCount--;
|
||||
|
||||
if (queue.size > 0) {
|
||||
queue.dequeue()();
|
||||
}
|
||||
};
|
||||
|
||||
const run = async (fn, resolve, args) => {
|
||||
activeCount++;
|
||||
|
||||
const result = (async () => fn(...args))();
|
||||
|
||||
resolve(result);
|
||||
|
||||
try {
|
||||
await result;
|
||||
} catch {}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
const enqueue = (fn, resolve, args) => {
|
||||
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
||||
|
||||
(async () => {
|
||||
// This function needs to wait until the next microtask before comparing
|
||||
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
||||
// when the run function is dequeued and called. The comparison in the if-statement
|
||||
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
||||
await Promise.resolve();
|
||||
|
||||
if (activeCount < concurrency && queue.size > 0) {
|
||||
queue.dequeue()();
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
const generator = (fn, ...args) => new Promise(resolve => {
|
||||
enqueue(fn, resolve, args);
|
||||
});
|
||||
|
||||
Object.defineProperties(generator, {
|
||||
activeCount: {
|
||||
get: () => activeCount,
|
||||
},
|
||||
pendingCount: {
|
||||
get: () => queue.size,
|
||||
},
|
||||
clearQueue: {
|
||||
value: () => {
|
||||
queue.clear();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return generator;
|
||||
}
|
||||
|
||||
class EndError extends Error {
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
// The input can also be a promise, so we await it.
|
||||
const testElement = async (element, tester) => tester(await element);
|
||||
|
||||
// The input can also be a promise, so we `Promise.all()` them both.
|
||||
const finder = async element => {
|
||||
const values = await Promise.all(element);
|
||||
if (values[1] === true) {
|
||||
throw new EndError(values[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
async function pLocate(
|
||||
iterable,
|
||||
tester,
|
||||
{
|
||||
concurrency = Number.POSITIVE_INFINITY,
|
||||
preserveOrder = true,
|
||||
} = {},
|
||||
) {
|
||||
const limit = pLimit(concurrency);
|
||||
|
||||
// Start all the promises concurrently with optional limit.
|
||||
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
||||
|
||||
// Check the promises either serially or concurrently.
|
||||
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
||||
|
||||
try {
|
||||
await Promise.all(items.map(element => checkLimit(finder, element)));
|
||||
} catch (error) {
|
||||
if (error instanceof EndError) {
|
||||
return error.value;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const typeMappings = {
|
||||
directory: 'isDirectory',
|
||||
file: 'isFile',
|
||||
};
|
||||
|
||||
function checkType(type) {
|
||||
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Invalid type specified: ${type}`);
|
||||
}
|
||||
|
||||
const matchType = (type, stat) => stat[typeMappings[type]]();
|
||||
|
||||
const toPath$1 = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
||||
|
||||
async function locatePath(
|
||||
paths,
|
||||
{
|
||||
cwd = process.cwd(),
|
||||
type = 'file',
|
||||
allowSymlinks = true,
|
||||
concurrency,
|
||||
preserveOrder,
|
||||
} = {},
|
||||
) {
|
||||
checkType(type);
|
||||
cwd = toPath$1(cwd);
|
||||
|
||||
const statFunction = allowSymlinks ? promises.stat : promises.lstat;
|
||||
|
||||
return pLocate(paths, async path_ => {
|
||||
try {
|
||||
const stat = await statFunction(path.resolve(cwd, path_));
|
||||
return matchType(type, stat);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, {concurrency, preserveOrder});
|
||||
}
|
||||
|
||||
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
||||
|
||||
const findUpStop = Symbol('findUpStop');
|
||||
|
||||
async function findUpMultiple(name, options = {}) {
|
||||
let directory = path.resolve(toPath(options.cwd) || '');
|
||||
const {root} = path.parse(directory);
|
||||
const stopAt = path.resolve(directory, options.stopAt || root);
|
||||
const limit = options.limit || Number.POSITIVE_INFINITY;
|
||||
const paths = [name].flat();
|
||||
|
||||
const runMatcher = async locateOptions => {
|
||||
if (typeof name !== 'function') {
|
||||
return locatePath(paths, locateOptions);
|
||||
}
|
||||
|
||||
const foundPath = await name(locateOptions.cwd);
|
||||
if (typeof foundPath === 'string') {
|
||||
return locatePath([foundPath], locateOptions);
|
||||
}
|
||||
|
||||
return foundPath;
|
||||
};
|
||||
|
||||
const matches = [];
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const foundPath = await runMatcher({...options, cwd: directory});
|
||||
|
||||
if (foundPath === findUpStop) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (foundPath) {
|
||||
matches.push(path.resolve(directory, foundPath));
|
||||
}
|
||||
|
||||
if (directory === stopAt || matches.length >= limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
async function findUp(name, options = {}) {
|
||||
const matches = await findUpMultiple(name, {...options, limit: 1});
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
function _resolve(path, options = {}) {
|
||||
if (options.platform === "auto" || !options.platform)
|
||||
options.platform = process.platform === "win32" ? "win32" : "posix";
|
||||
if (process.versions.pnp) {
|
||||
const paths = options.paths || [];
|
||||
if (paths.length === 0)
|
||||
paths.push(process.cwd());
|
||||
const targetRequire = createRequire(import.meta.url);
|
||||
try {
|
||||
return targetRequire.resolve(path, { paths });
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
const modulePath = resolvePathSync(path, {
|
||||
url: options.paths
|
||||
});
|
||||
if (options.platform === "win32")
|
||||
return win32.normalize(modulePath);
|
||||
return modulePath;
|
||||
}
|
||||
function resolveModule(name, options = {}) {
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
async function importModule(path) {
|
||||
const i = await import(path);
|
||||
if (i)
|
||||
return interopDefault(i);
|
||||
return i;
|
||||
}
|
||||
function isPackageExists(name, options = {}) {
|
||||
return !!resolvePackage(name, options);
|
||||
}
|
||||
function getPackageJsonPath(name, options = {}) {
|
||||
const entry = resolvePackage(name, options);
|
||||
if (!entry)
|
||||
return;
|
||||
return searchPackageJSON(entry);
|
||||
}
|
||||
async function getPackageInfo(name, options = {}) {
|
||||
const packageJsonPath = getPackageJsonPath(name, options);
|
||||
if (!packageJsonPath)
|
||||
return;
|
||||
const packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, "utf8"));
|
||||
return {
|
||||
name,
|
||||
version: packageJson.version,
|
||||
rootPath: dirname(packageJsonPath),
|
||||
packageJsonPath,
|
||||
packageJson
|
||||
};
|
||||
}
|
||||
function getPackageInfoSync(name, options = {}) {
|
||||
const packageJsonPath = getPackageJsonPath(name, options);
|
||||
if (!packageJsonPath)
|
||||
return;
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
||||
return {
|
||||
name,
|
||||
version: packageJson.version,
|
||||
rootPath: dirname(packageJsonPath),
|
||||
packageJsonPath,
|
||||
packageJson
|
||||
};
|
||||
}
|
||||
function resolvePackage(name, options = {}) {
|
||||
try {
|
||||
return _resolve(`${name}/package.json`, options);
|
||||
} catch {
|
||||
}
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch (e) {
|
||||
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND")
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function searchPackageJSON(dir) {
|
||||
let packageJsonPath;
|
||||
while (true) {
|
||||
if (!dir)
|
||||
return;
|
||||
const newDir = dirname(dir);
|
||||
if (newDir === dir)
|
||||
return;
|
||||
dir = newDir;
|
||||
packageJsonPath = join(dir, "package.json");
|
||||
if (fs.existsSync(packageJsonPath))
|
||||
break;
|
||||
}
|
||||
return packageJsonPath;
|
||||
}
|
||||
async function loadPackageJSON(cwd = process.cwd()) {
|
||||
const path = await findUp("package.json", { cwd });
|
||||
if (!path || !fs.existsSync(path))
|
||||
return null;
|
||||
return JSON.parse(await fsp.readFile(path, "utf-8"));
|
||||
}
|
||||
async function isPackageListed(name, cwd) {
|
||||
const pkg = await loadPackageJSON(cwd) || {};
|
||||
return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
|
||||
}
|
||||
|
||||
export { getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, loadPackageJSON, resolveModule };
|
||||
65
web/admin-spa/node_modules/local-pkg/package.json
generated
vendored
Normal file
65
web/admin-spa/node_modules/local-pkg/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "local-pkg",
|
||||
"type": "module",
|
||||
"version": "0.5.1",
|
||||
"packageManager": "pnpm@9.13.2",
|
||||
"description": "Get information on local packages.",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu/local-pkg#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu/local-pkg.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu/local-pkg/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"package"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "nr build",
|
||||
"build": "unbuild",
|
||||
"lint": "eslint .",
|
||||
"release": "bumpp && npm publish",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run && node ./test/cjs.cjs && node ./test/esm.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"mlly": "^1.7.3",
|
||||
"pkg-types": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^3.9.2",
|
||||
"@antfu/ni": "^0.23.1",
|
||||
"@antfu/utils": "^0.7.10",
|
||||
"@types/chai": "^5.0.1",
|
||||
"@types/node": "^22.9.0",
|
||||
"bumpp": "^9.8.1",
|
||||
"chai": "^5.1.2",
|
||||
"eslint": "^9.15.0",
|
||||
"esno": "^4.8.0",
|
||||
"find-up": "^6.3.0",
|
||||
"typescript": "^5.6.3",
|
||||
"unbuild": "^2.0.0",
|
||||
"vitest": "^2.1.5"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user