From 5efcecd587c902277333eda716319097f6aa7456 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Sun, 10 Dec 2023 21:37:01 +0800 Subject: [PATCH 01/19] feat(cli): implement new standalone CLI with better UX --- .vscode/settings.json | 3 + package.json | 6 +- packages/cli/bin/run.cmd | 3 + packages/cli/bin/run.ts | 3 + packages/cli/package.json | 58 +++++ packages/cli/src/cli.ts | 245 ++++++++++++++++++ packages/cli/src/concurrency.ts | 51 ++++ packages/cli/src/path.ts | 66 +++++ packages/cli/src/perf.ts | 67 +++++ packages/cli/src/unminify.ts | 38 +++ packages/cli/src/unpacker.ts | 46 ++++ packages/cli/tsconfig.json | 27 ++ packages/cli/tsup.config.ts | 19 ++ packages/playground/package.json | 2 +- packages/unminify/src/cli.ts | 105 +++++++- patches/@clack__core@0.3.3.patch | 83 +++++++ patches/@clack__prompts@0.7.0.patch | 367 +++++++++++++++++++++++++++ pnpm-lock.yaml | 370 +++++++++++++++++++++++++++- vitest.config.js | 1 + 19 files changed, 1533 insertions(+), 27 deletions(-) create mode 100644 packages/cli/bin/run.cmd create mode 100644 packages/cli/bin/run.ts create mode 100644 packages/cli/package.json create mode 100644 packages/cli/src/cli.ts create mode 100644 packages/cli/src/concurrency.ts create mode 100644 packages/cli/src/path.ts create mode 100644 packages/cli/src/perf.ts create mode 100644 packages/cli/src/unminify.ts create mode 100644 packages/cli/src/unpacker.ts create mode 100644 packages/cli/tsconfig.json create mode 100644 packages/cli/tsup.config.ts create mode 100644 patches/@clack__core@0.3.3.patch create mode 100644 patches/@clack__prompts@0.7.0.patch diff --git a/.vscode/settings.json b/.vscode/settings.json index 44bc165e..616bc4f6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -40,6 +40,7 @@ "jsxs", "lebab", "Minifier", + "outro", "Paneview", "picocolors", "preact", @@ -48,7 +49,9 @@ "taze", "testcase", "testcases", + "unminified", "unminify", + "Unminifying", "unzlib", "utoa", "vutai", diff --git a/package.json b/package.json index 4ceb596e..95dd7676 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "private": true, "packageManager": "pnpm@8.11.0", "description": "🔪📦 Javascript decompiler, unpacker and unminify toolkit", - "author": "pionxzh", + "author": "Pionxzh", "license": "MIT", "homepage": "https://github.com/pionxzh/wakaru", "engines": { @@ -41,7 +41,9 @@ }, "pnpm": { "patchedDependencies": { - "ast-types@0.16.1": "patches/ast-types@0.16.1.patch" + "ast-types@0.16.1": "patches/ast-types@0.16.1.patch", + "@clack/core@0.3.3": "patches/@clack__core@0.3.3.patch", + "@clack/prompts@0.7.0": "patches/@clack__prompts@0.7.0.patch" } }, "resolutions": { diff --git a/packages/cli/bin/run.cmd b/packages/cli/bin/run.cmd new file mode 100644 index 00000000..1a09379f --- /dev/null +++ b/packages/cli/bin/run.cmd @@ -0,0 +1,3 @@ +@echo off + +pnpm exec tsx "%~dp0\run" %* diff --git a/packages/cli/bin/run.ts b/packages/cli/bin/run.ts new file mode 100644 index 00000000..f4117a50 --- /dev/null +++ b/packages/cli/bin/run.ts @@ -0,0 +1,3 @@ +#!/usr/bin/env -S node --import tsx --no-warnings=ExperimentalWarning + +import '../src/cli.ts' diff --git a/packages/cli/package.json b/packages/cli/package.json new file mode 100644 index 00000000..7f35b421 --- /dev/null +++ b/packages/cli/package.json @@ -0,0 +1,58 @@ +{ + "name": "@wakaru/cli", + "type": "module", + "version": "0.0.1", + "description": "🔪📦 Unminify and beautify bundled code", + "author": "Pionxzh", + "license": "MIT", + "bin": "dist/cli.cjs", + "files": [ + "dist", + "package.json" + ], + "engines": { + "node": ">=16.0.0" + }, + "scripts": { + "build": "tsup", + "dev-cli": "tsx src/cli.ts", + "test": "vitest run --globals", + "test:update": "vitest run --update --globals", + "test:watch": "vitest watch --globals", + "test:type": "tsc --noEmit", + "lint": "eslint src", + "lint:fix": "eslint src --fix" + }, + "dependencies": { + "@clack/core": "^0.3.3", + "@clack/prompts": "^0.7.0", + "fs-extra": "^11.1.1", + "globby": "^11.1.0", + "picocolors": "^1.0.0", + "yargs": "^17.7.2" + }, + "devDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/jscodeshift": "^0.11.11", + "@types/yargs": "^17.0.32", + "@wakaru/ast-utils": "workspace:*", + "@wakaru/test-utils": "workspace:*", + "@wakaru/unminify": "workspace:*", + "@wakaru/unpacker": "workspace:*", + "tsup": "^7.3.0", + "tsx": "^4.6.2", + "typescript": "^5.3.2" + }, + "publishConfig": { + "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.cjs", + "import": "./dist/index.js" + } + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts" + } +} diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts new file mode 100644 index 00000000..db36aae8 --- /dev/null +++ b/packages/cli/src/cli.ts @@ -0,0 +1,245 @@ +#!/usr/bin/env node +/* eslint-disable no-console */ +import os from 'node:os' +import path from 'node:path' +import process from 'node:process' +import { + cancel, + confirm, + intro, + isCancel, + log, + multiselect, + outro, + spinner, + text, +} from '@clack/prompts' +import fsa from 'fs-extra' +import c from 'picocolors' +import { version } from '../package.json' +import { Concurrency } from './concurrency' +import { findCommonBaseDir, getRelativePath, isPathInside, resolveGlob } from './path' +import { unminify } from './unminify' +import { unpacker } from './unpacker' + +enum Feature { + Unpacker = 'Unpacker', + Unminify = 'Unminify', +} + +async function main() { + const cwd = process.cwd() + + console.log() + intro(c.cyan(c.inverse(` Wakaru v${version} `))) + + const features = await multiselect({ + message: `Select features to use ${c.dim('(Use to select, to submit)')}`, + options: [ + { label: 'Unpacker - Unpacks bundled code into separated modules', value: Feature.Unpacker }, + { label: 'Unminify - Converts minified code into its readable form', value: Feature.Unminify }, + ], + initialValues: [Feature.Unpacker], + }) + + if (isCancel(features)) { + cancel('Cancelled') + return process.exit(0) + } + + outro(`Selected features: ${c.green(features.join(', '))}`) + + let unminifyInputPaths: string[] = [] + + if (features.includes(Feature.Unpacker)) { + intro(`${c.green(c.inverse(' Unpacker '))}`) + + const rawInputPath = await text({ + message: `Input file path ${c.dim('(Supports only single file)')}`, + placeholder: './input.js', + validate(value) { + if (!value) return 'Please enter a file path' + + const inputPath = path.resolve(value) + if (!fsa.existsSync(inputPath)) return 'Input does not exist' + if (!fsa.statSync(inputPath).isFile()) return 'Input is not a file' + + return undefined + }, + }) + + if (isCancel(rawInputPath)) { + cancel('Cancelled') + return process.exit(0) + } + + const inputPath = path.resolve(rawInputPath) + const outputPathPlaceholder = './out' + + const rawOutputPath = await text({ + message: `Output directory path ${c.dim('( to accept default)')}`, + placeholder: outputPathPlaceholder, + validate(value) { + if (!value) return undefined // default value + + const outputPath = path.resolve(value) + if (!fsa.statSync(outputPath).isDirectory()) return 'Output is not a directory' + if (!isPathInside(cwd, outputPath)) return 'Output is outside of the current working directory' + + return undefined + }, + }) + + if (isCancel(rawOutputPath)) { + cancel('Cancelled') + return process.exit(0) + } + + const outputPath = path.resolve(rawOutputPath || outputPathPlaceholder) + const relativeOutputPath = getRelativePath(cwd, outputPath) + + if (fsa.existsSync(outputPath)) { + const overwrite = await confirm({ + message: `Output directory already exists at ${c.green(relativeOutputPath)}. Overwrite?`, + initialValue: true, + }) + + if (isCancel(overwrite)) { + cancel('Cancelled') + return process.exit(0) + } + + if (!overwrite) { + cancel('Output directory already exists') + return process.exit(1) + } + } + + log.step('Unpacking...') + + const s = spinner() + s.start('...') + const items = await unpacker([inputPath], outputPath) + s.stop('Finished') + + const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) + const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) + const formattedElapsed = (totalElapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) + log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) + outro(`Output directory: ${c.green(relativeOutputPath)}`) + + unminifyInputPaths = items.flatMap(item => item.files) + } + + if (features.includes(Feature.Unminify)) { + intro(`${c.green(c.inverse(' Unminify '))}`) + + const unpacked = features.includes(Feature.Unpacker) + + if (unpacked && unminifyInputPaths.length === 0) { + // No need to continue if there are no unpacked files + return process.exit(0) + } + + if (!unpacked) { + const rawInputPath = await text({ + message: `Input file path ${c.dim('(Supports glob patterns)')}`, + placeholder: './*.js', + validate(value) { + if (!value) return 'Please enter a file path' + + const resolvedPaths = resolveGlob(value) + if (resolvedPaths.length === 0) return 'No files matched' + + return undefined + }, + }) + + if (isCancel(rawInputPath)) { + cancel('Cancelled') + return process.exit(0) + } + + unminifyInputPaths = resolveGlob(rawInputPath) + } + else { + log.success('Input file path') + log.message(c.dim('Skipped')) + } + + const commonBaseDir = findCommonBaseDir(unminifyInputPaths) + if (!commonBaseDir) { + log.error(`Could not find common base directory with input paths ${c.green(unminifyInputPaths.join(', '))}`) + return process.exit(1) + } + + let outputPathPlaceholder = './out' + if (unpacked) { + outputPathPlaceholder = getRelativePath(cwd, path.join(commonBaseDir, outputPathPlaceholder)) + } + + const rawOutputPath = await text({ + message: `Output directory path ${c.dim('( to accept default)')}`, + placeholder: outputPathPlaceholder, + validate(value) { + if (!value) return undefined // default value + + const outputPath = path.resolve(value) + if (fsa.existsSync(outputPath) && !fsa.statSync(outputPath).isDirectory()) return 'Output path is not a directory' + if (!isPathInside(cwd, outputPath)) return 'Output path is outside of the current working directory' + + return undefined + }, + }) + + if (isCancel(rawOutputPath)) { + cancel('Cancelled') + return process.exit(0) + } + + const outputPath = path.resolve(rawOutputPath || outputPathPlaceholder) + const relativeOutputPath = getRelativePath(cwd, outputPath) + + if (fsa.existsSync(outputPath)) { + const overwrite = await confirm({ + message: `Output directory already exists at ${c.green(relativeOutputPath)}. Overwrite?`, + initialValue: true, + }) + + if (isCancel(overwrite)) { + cancel('Cancelled') + return process.exit(0) + } + + if (!overwrite) { + cancel('Output directory already exists') + return process.exit(1) + } + } + + const concurrency = Math.min(os.cpus().length, 2) // TODO: Make this configurable + const concurrencyManager = new Concurrency({ concurrency }) + + log.step('Unminifying...') + + const s = spinner() + s.start('...') + await Promise.all( + unminifyInputPaths.map(p => concurrencyManager.add(async () => { + await unminify([p], commonBaseDir, outputPath, true) + s.message(`${c.green(path.relative(cwd, p))}`) + })), + ) + s.stop('Finished') + + log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files`) + + outro(`Output directory: ${c.green(relativeOutputPath)}`) + } + + console.log() + console.log(`Problems? Please report them at ${c.underline(c.cyan('https://github.com/pionxzh/wakaru/issues'))}`) + console.log() +} + +main().catch(err => console.error(err)) diff --git a/packages/cli/src/concurrency.ts b/packages/cli/src/concurrency.ts new file mode 100644 index 00000000..d254c816 --- /dev/null +++ b/packages/cli/src/concurrency.ts @@ -0,0 +1,51 @@ +// From https://github.com/fabiospampinato/promise-concurrency-limiter +// with MIT license +export class Concurrency { + private concurrency: number + private count: number + private queue: Set<() => void> + + constructor(options: { concurrency: number }) { + this.concurrency = options.concurrency + this.count = 0 + this.queue = new Set() + } + + public add(fn: () => Promise): Promise { + if (this.count < this.concurrency) { + return this.run(fn) + } + + return new Promise((resolve) => { + const callback = (): void => resolve(this.run(fn)) + + this.queue.add(callback) + }) + } + + private flush(): void { + for (const callback of this.queue) { + if (this.count >= this.concurrency) break + + this.queue.delete(callback) + + callback() + } + } + + private run(fn: () => Promise): Promise { + this.count++ + + const promise = fn() + + const cleanup = (): void => { + this.count-- + + this.flush() + } + + promise.then(cleanup, cleanup) + + return promise + } +} diff --git a/packages/cli/src/path.ts b/packages/cli/src/path.ts new file mode 100644 index 00000000..177bf067 --- /dev/null +++ b/packages/cli/src/path.ts @@ -0,0 +1,66 @@ +import path from 'node:path' +import process from 'node:process' +import fsa from 'fs-extra' +import * as globby from 'globby' + +/** + * Check if base path contains target path + */ +export function isPathInside(base: string, target: string): boolean { + const relative = path.relative(base, target) + return !relative.startsWith('..') && !path.isAbsolute(relative) +} + +/** + * Get relative path from one path to another. + * + * This is a wrapper around `path.relative` that prepends `./` to indicate it's in the current directory. + * + * @example + * path.relative('/a/b', '/a/b/d') // 'd' + * getRelativePath('/a/b', '/a/b/d') // './d' + */ +export function getRelativePath(from: string, to: string) { + let relativePath = path.relative(from, to) + + // Check if the path is in the current directory and doesn't start with '.' or '..' + if (!relativePath.startsWith('.') && !relativePath.startsWith('..')) { + // Prepend './' to indicate it's in the current directory + relativePath = `.${path.sep}${relativePath}` + } + + return relativePath +} + +export function findCommonBaseDir(paths: string[]): string | null { + if (!paths.length) return null + + const absPaths = paths.map(p => path.resolve(p)) + let commonParts = absPaths[0].split(path.sep) + + for (let i = 1; i < absPaths.length; i++) { + const parts = absPaths[i].split(path.sep) + for (let j = 0; j < commonParts.length; j++) { + if (commonParts[j] !== parts[j]) { + commonParts = commonParts.slice(0, j) + break + } + } + } + + const commonPath = commonParts.join(path.sep) + // if path is not a directory, use its parent directory + return fsa.statSync(commonPath).isDirectory() + ? commonPath + : path.dirname(commonPath) +} + +export function resolveGlob(glob: string) { + const cwd = process.cwd() + glob = path.normalize(glob).replace(/\\/g, '/') + return globby.sync(glob, { + cwd: process.cwd(), + absolute: true, + ignore: [path.join(cwd, '**/node_modules/**')], + }) +} diff --git a/packages/cli/src/perf.ts b/packages/cli/src/perf.ts new file mode 100644 index 00000000..1635a605 --- /dev/null +++ b/packages/cli/src/perf.ts @@ -0,0 +1,67 @@ +import { hrtime } from 'node:process' + +interface TimingStat { + filename: string + /** + * Timing measurement key + */ + key: string + /** + * Time in milliseconds + */ + time: number +} + +export class Timing { + private collected: TimingStat[] = [] + + constructor(private enabled: boolean = true) { } + + /** + * Collect a timing measurement + */ + collect(filename: string, key: string, fn: () => T): T { + if (!this.enabled) return fn() + + const { result, time } = this.measureTime(fn) + this.collected.push({ filename, key, time }) + + return result + } + + /** + * Collect a timing measurement + */ + async collectAsync(filename: string, key: string, fn: () => T): Promise { + if (!this.enabled) return fn() + + const { result, time } = await this.measureTimeAsync(fn) + this.collected.push({ filename, key, time }) + + return result + } + + /** + * Measure the time it takes to execute a function + */ + measureTime(fn: () => T) { + const start = hrtime() + const result = fn() + const end = hrtime(start) + const time = end[0] * 1e3 + end[1] / 1e6 + + return { result, time } + } + + /** + * Measure the time it takes to execute a async function + */ + async measureTimeAsync(fn: () => T) { + const start = hrtime() + const result = await fn() + const end = hrtime(start) + const time = end[0] * 1e3 + end[1] / 1e6 + + return { result, time } + } +} diff --git a/packages/cli/src/unminify.ts b/packages/cli/src/unminify.ts new file mode 100644 index 00000000..9558c3e5 --- /dev/null +++ b/packages/cli/src/unminify.ts @@ -0,0 +1,38 @@ +/* eslint-disable no-console */ +import * as path from 'node:path' +import process from 'node:process' +import { runTransformations, transformationRules } from '@wakaru/unminify' +import fsa from 'fs-extra' +import { Timing } from './perf' +import type { Transform } from 'jscodeshift' + +export async function unminify( + paths: string[], + baseDir: string, + outputDir: string, + perf: boolean, +) { + await fsa.ensureDir(outputDir) + + const cwd = process.cwd() + const timing = new Timing(perf) + + for (const p of paths) { + const outputPath = path.join(outputDir, path.relative(baseDir, p)) + const filename = path.relative(cwd, outputPath) + const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) + const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) + + await timing.measureTimeAsync(async () => { + const source = await measureAsync('read file', () => fsa.readFile(p, 'utf-8')) + + const transformations = transformationRules.map((rule) => { + const { id, transform } = rule + return (...args: Parameters) => measure(id, () => transform(...args)) + }) + const result = measure('runDefaultTransformation', () => runTransformations({ path: p, source }, transformations)) + + await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) + }) + } +} diff --git a/packages/cli/src/unpacker.ts b/packages/cli/src/unpacker.ts new file mode 100644 index 00000000..70449b4c --- /dev/null +++ b/packages/cli/src/unpacker.ts @@ -0,0 +1,46 @@ +import path from 'node:path' +import { unpack } from '@wakaru/unpacker' +import fsa from 'fs-extra' +import { Timing } from './perf' +import type { ModuleMapping } from '@wakaru/ast-utils/types' +import type { Module } from '@wakaru/unpacker' + +export interface UnpackerItem { + files: string[] + modules: Module[] + moduleIdMapping: ModuleMapping + elapsed: number +} + +export async function unpacker( + paths: string[], + outputDir: string, +): Promise { + fsa.ensureDirSync(outputDir) + + const result: UnpackerItem[] = [] + const files: string[] = [] + + for (const p of paths) { + const source = await fsa.readFile(p, 'utf-8') + + const timing = new Timing() + const { result: { modules, moduleIdMapping }, time: elapsed } = timing.measureTime(() => unpack(source)) + + for (const mod of modules) { + const filename = moduleIdMapping[mod.id] ?? `module-${mod.id}.js` + const outputPath = path.join(outputDir, filename) + await fsa.ensureDir(path.dirname(outputPath)) + await fsa.writeFile(outputPath, mod.code, 'utf-8') + files.push(outputPath) + } + + result.push({ + files, + modules, + moduleIdMapping, + elapsed, + }) + } + return result +} diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json new file mode 100644 index 00000000..bf2b2915 --- /dev/null +++ b/packages/cli/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "ESNext", + "lib": ["ESNext"], + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noEmit": true, + "outDir": "dist", + "sourceMap": true, + "esModuleInterop": true, + "isolatedModules": true, + "skipLibCheck": true + }, + "include": [ + "src" + ], + "exclude": [ + "node_modules", + "dist" + ] +} diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts new file mode 100644 index 00000000..4bdf389f --- /dev/null +++ b/packages/cli/tsup.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from 'tsup' + +export default defineConfig({ + entry: ['src/cli.ts'], + format: ['cjs', 'esm'], + dts: true, + splitting: true, + sourcemap: true, + clean: true, + define: { + 'process.env.NODE_DEBUG': 'undefined', + }, + // minify: true, + noExternal: [ + 'jscodeshift', + 'ast-types', + /@wakaru\/.+/, + ], +}) diff --git a/packages/playground/package.json b/packages/playground/package.json index 4aefe289..a5c16a04 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -4,7 +4,7 @@ "version": "0.0.1", "private": true, "description": "", - "author": "pionxzh", + "author": "Pionxzh", "license": "MIT", "sideEffects": false, "exports": { diff --git a/packages/unminify/src/cli.ts b/packages/unminify/src/cli.ts index 61a96fe8..0b784c39 100644 --- a/packages/unminify/src/cli.ts +++ b/packages/unminify/src/cli.ts @@ -9,10 +9,78 @@ import c from 'picocolors' import yargs from 'yargs' import { hideBin } from 'yargs/helpers' import { version } from '../package.json' -import { runDefaultTransformation } from '.' +import { TransformationRule } from './transformations' +import { runTransformations, transformationRules } from '.' +import type { Transform } from 'jscodeshift' type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'silent' +interface TimingStat { + filename: string + /** + * Timing measurement key + */ + key: string + /** + * Time in milliseconds + */ + time: number +} + +class Timing { + private collected: TimingStat[] = [] + + constructor(private enabled: boolean) { } + + /** + * Collect a timing measurement + */ + collect(filename: string, key: string, fn: () => T): T { + if (!this.enabled) return fn() + + const { result, time } = this.measureTime(fn) + this.collected.push({ filename, key, time }) + + return result + } + + /** + * Collect a timing measurement + */ + async collectAsync(filename: string, key: string, fn: () => T): Promise { + if (!this.enabled) return fn() + + const { result, time } = await this.measureTimeAsync(fn) + this.collected.push({ filename, key, time }) + + return result + } + + /** + * Measure the time it takes to execute a function + */ + measureTime(fn: () => T) { + const start = hrtime() + const result = fn() + const end = hrtime(start) + const time = end[0] * 1e3 + end[1] / 1e6 + + return { result, time } + } + + /** + * Measure the time it takes to execute a async function + */ + async measureTimeAsync(fn: () => T) { + const start = hrtime() + const result = await fn() + const end = hrtime(start) + const time = end[0] * 1e3 + end[1] / 1e6 + + return { result, time } + } +} + // eslint-disable-next-line no-unused-expressions yargs(hideBin(process.argv)) .scriptName('@wakaru/unminify') @@ -49,6 +117,11 @@ yargs(hideBin(process.argv)) type: 'boolean', default: false, }) + .option('perf', { + describe: 'enable performance statistics', + type: 'boolean', + default: false, + }) .positional('files', { describe: 'File paths to process (supports glob patterns)', type: 'string', @@ -61,6 +134,7 @@ yargs(hideBin(process.argv)) args.output, args.force, args.logLevel as LogLevel, + args.perf, ) }, ) @@ -71,6 +145,7 @@ async function codemod( output: string, force: boolean, logLevel: LogLevel, + perf: boolean, ) { const cwd = process.cwd() const globbyPaths = paths @@ -100,21 +175,29 @@ async function codemod( const commonBaseDir = findCommonBaseDir(resolvedPaths) if (!commonBaseDir) throw new Error('Could not find common base directory') - for (const p of resolvedPaths) { - const start = hrtime() + const timing = new Timing(perf) - const source = await fsa.readFile(p, 'utf-8') - const result = runDefaultTransformation({ - path: p, - source, - }) + for (const p of resolvedPaths) { const outputPath = path.join(outputDir, path.relative(commonBaseDir, p)) await fsa.ensureDir(path.dirname(outputPath)) - await fsa.writeFile(outputPath, result.code, 'utf-8') + + const filename = path.relative(cwd, outputPath) + const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) + const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) + + const { time: elapsed } = await timing.measureTimeAsync(async () => { + const source = await measureAsync('read file', () => fsa.readFile(p, 'utf-8')) + + const transformations = transformationRules.map((rule) => { + const { id, transform } = rule + return (...args: Parameters) => measure(id, () => transform(...args)) + }) + const result = measure('runDefaultTransformation', () => runTransformations({ path: p, source }, transformations)) + + await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) + }) if (logLevel !== 'silent') { - const end = hrtime(start) - const elapsed = end[0] * 1e9 + end[1] const formattedElapsed = (elapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) console.log(`${c.dim('•')} Transforming ${c.green(path.relative(cwd, outputPath))} ${c.dim(`(${formattedElapsed}ms)`)}`) } diff --git a/patches/@clack__core@0.3.3.patch b/patches/@clack__core@0.3.3.patch new file mode 100644 index 00000000..6fb443c5 --- /dev/null +++ b/patches/@clack__core@0.3.3.patch @@ -0,0 +1,83 @@ +diff --git a/dist/index.cjs b/dist/index.cjs +index 5f3b334a0dd9e92f77b37be07a74b713bb928b20..67b1440224b59338b1c261f8ecafbbd6a444768a 100644 +--- a/dist/index.cjs ++++ b/dist/index.cjs +@@ -1,14 +1,15 @@ +-"use strict";const sisteransi=require("sisteransi"),node_process=require("node:process"),readline=require("node:readline"),node_tty=require("node:tty"),color=require("picocolors");function _interopNamespaceDefault(t){const u=Object.create(null);if(t)for(const F in t)u[F]=t[F];return u.default=t,u}const readline__namespace=_interopNamespaceDefault(readline);function ansiRegex({onlyFirst:t=!1}={}){const u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(u,t?void 0:"g")}function stripAnsi(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(ansiRegex(),"")}var eastasianwidthExports={},eastasianwidth={get exports(){return eastasianwidthExports},set exports(t){eastasianwidthExports=t}};(function(t){var u={};t.exports=u,u.eastAsianWidth=function(e){var s=e.charCodeAt(0),C=e.length==2?e.charCodeAt(1):0,D=s;return 55296<=s&&s<=56319&&56320<=C&&C<=57343&&(s&=1023,C&=1023,D=s<<10|C,D+=65536),D==12288||65281<=D&&D<=65376||65504<=D&&D<=65510?"F":D==8361||65377<=D&&D<=65470||65474<=D&&D<=65479||65482<=D&&D<=65487||65490<=D&&D<=65495||65498<=D&&D<=65500||65512<=D&&D<=65518?"H":4352<=D&&D<=4447||4515<=D&&D<=4519||4602<=D&&D<=4607||9001<=D&&D<=9002||11904<=D&&D<=11929||11931<=D&&D<=12019||12032<=D&&D<=12245||12272<=D&&D<=12283||12289<=D&&D<=12350||12353<=D&&D<=12438||12441<=D&&D<=12543||12549<=D&&D<=12589||12593<=D&&D<=12686||12688<=D&&D<=12730||12736<=D&&D<=12771||12784<=D&&D<=12830||12832<=D&&D<=12871||12880<=D&&D<=13054||13056<=D&&D<=19903||19968<=D&&D<=42124||42128<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||55216<=D&&D<=55238||55243<=D&&D<=55291||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65106||65108<=D&&D<=65126||65128<=D&&D<=65131||110592<=D&&D<=110593||127488<=D&&D<=127490||127504<=D&&D<=127546||127552<=D&&D<=127560||127568<=D&&D<=127569||131072<=D&&D<=194367||177984<=D&&D<=196605||196608<=D&&D<=262141?"W":32<=D&&D<=126||162<=D&&D<=163||165<=D&&D<=166||D==172||D==175||10214<=D&&D<=10221||10629<=D&&D<=10630?"Na":D==161||D==164||167<=D&&D<=168||D==170||173<=D&&D<=174||176<=D&&D<=180||182<=D&&D<=186||188<=D&&D<=191||D==198||D==208||215<=D&&D<=216||222<=D&&D<=225||D==230||232<=D&&D<=234||236<=D&&D<=237||D==240||242<=D&&D<=243||247<=D&&D<=250||D==252||D==254||D==257||D==273||D==275||D==283||294<=D&&D<=295||D==299||305<=D&&D<=307||D==312||319<=D&&D<=322||D==324||328<=D&&D<=331||D==333||338<=D&&D<=339||358<=D&&D<=359||D==363||D==462||D==464||D==466||D==468||D==470||D==472||D==474||D==476||D==593||D==609||D==708||D==711||713<=D&&D<=715||D==717||D==720||728<=D&&D<=731||D==733||D==735||768<=D&&D<=879||913<=D&&D<=929||931<=D&&D<=937||945<=D&&D<=961||963<=D&&D<=969||D==1025||1040<=D&&D<=1103||D==1105||D==8208||8211<=D&&D<=8214||8216<=D&&D<=8217||8220<=D&&D<=8221||8224<=D&&D<=8226||8228<=D&&D<=8231||D==8240||8242<=D&&D<=8243||D==8245||D==8251||D==8254||D==8308||D==8319||8321<=D&&D<=8324||D==8364||D==8451||D==8453||D==8457||D==8467||D==8470||8481<=D&&D<=8482||D==8486||D==8491||8531<=D&&D<=8532||8539<=D&&D<=8542||8544<=D&&D<=8555||8560<=D&&D<=8569||D==8585||8592<=D&&D<=8601||8632<=D&&D<=8633||D==8658||D==8660||D==8679||D==8704||8706<=D&&D<=8707||8711<=D&&D<=8712||D==8715||D==8719||D==8721||D==8725||D==8730||8733<=D&&D<=8736||D==8739||D==8741||8743<=D&&D<=8748||D==8750||8756<=D&&D<=8759||8764<=D&&D<=8765||D==8776||D==8780||D==8786||8800<=D&&D<=8801||8804<=D&&D<=8807||8810<=D&&D<=8811||8814<=D&&D<=8815||8834<=D&&D<=8835||8838<=D&&D<=8839||D==8853||D==8857||D==8869||D==8895||D==8978||9312<=D&&D<=9449||9451<=D&&D<=9547||9552<=D&&D<=9587||9600<=D&&D<=9615||9618<=D&&D<=9621||9632<=D&&D<=9633||9635<=D&&D<=9641||9650<=D&&D<=9651||9654<=D&&D<=9655||9660<=D&&D<=9661||9664<=D&&D<=9665||9670<=D&&D<=9672||D==9675||9678<=D&&D<=9681||9698<=D&&D<=9701||D==9711||9733<=D&&D<=9734||D==9737||9742<=D&&D<=9743||9748<=D&&D<=9749||D==9756||D==9758||D==9792||D==9794||9824<=D&&D<=9825||9827<=D&&D<=9829||9831<=D&&D<=9834||9836<=D&&D<=9837||D==9839||9886<=D&&D<=9887||9918<=D&&D<=9919||9924<=D&&D<=9933||9935<=D&&D<=9953||D==9955||9960<=D&&D<=9983||D==10045||D==10071||10102<=D&&D<=10111||11093<=D&&D<=11097||12872<=D&&D<=12879||57344<=D&&D<=63743||65024<=D&&D<=65039||D==65533||127232<=D&&D<=127242||127248<=D&&D<=127277||127280<=D&&D<=127337||127344<=D&&D<=127386||917760<=D&&D<=917999||983040<=D&&D<=1048573||1048576<=D&&D<=1114109?"A":"N"},u.characterLength=function(e){var s=this.eastAsianWidth(e);return s=="F"||s=="W"||s=="A"?2:1};function F(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}u.length=function(e){for(var s=F(e),C=0,D=0;D=s-(E==2?1:0))if(i+E<=C)D+=o;else break;i+=E}return D}})(eastasianwidth);const eastAsianWidth=eastasianwidthExports;var emojiRegex=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};function stringWidth(t,u={}){if(typeof t!="string"||t.length===0||(u={ambiguousIsNarrow:!0,...u},t=stripAnsi(t),t.length===0))return 0;t=t.replace(emojiRegex()," ");const F=u.ambiguousIsNarrow?1:2;let e=0;for(const s of t){const C=s.codePointAt(0);if(C<=31||C>=127&&C<=159||C>=768&&C<=879)continue;switch(eastAsianWidth.eastAsianWidth(s)){case"F":case"W":e+=2;break;case"A":e+=F;break;default:e+=1}}return e}const ANSI_BACKGROUND_OFFSET=10,wrapAnsi16=(t=0)=>u=>`\x1B[${u+t}m`,wrapAnsi256=(t=0)=>u=>`\x1B[${38+t};5;${u}m`,wrapAnsi16m=(t=0)=>(u,F,e)=>`\x1B[${38+t};2;${u};${F};${e}m`,styles={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(styles.modifier);const foregroundColorNames=Object.keys(styles.color),backgroundColorNames=Object.keys(styles.bgColor);[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){const t=new Map;for(const[u,F]of Object.entries(styles)){for(const[e,s]of Object.entries(F))styles[e]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},F[e]=styles[e],t.set(s[0],s[1]);Object.defineProperty(styles,u,{value:F,enumerable:!1})}return Object.defineProperty(styles,"codes",{value:t,enumerable:!1}),styles.color.close="\x1B[39m",styles.bgColor.close="\x1B[49m",styles.color.ansi=wrapAnsi16(),styles.color.ansi256=wrapAnsi256(),styles.color.ansi16m=wrapAnsi16m(),styles.bgColor.ansi=wrapAnsi16(ANSI_BACKGROUND_OFFSET),styles.bgColor.ansi256=wrapAnsi256(ANSI_BACKGROUND_OFFSET),styles.bgColor.ansi16m=wrapAnsi16m(ANSI_BACKGROUND_OFFSET),Object.defineProperties(styles,{rgbToAnsi256:{value:(u,F,e)=>u===F&&F===e?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(e/255*5),enumerable:!1},hexToRgb:{value:u=>{const F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[e]=F;e.length===3&&(e=[...e].map(C=>C+C).join(""));const s=Number.parseInt(e,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:u=>styles.rgbToAnsi256(...styles.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value:u=>{if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,e,s;if(u>=232)F=((u-232)*10+8)/255,e=F,s=F;else{u-=16;const i=u%36;F=Math.floor(u/36)/5,e=Math.floor(i/6)/5,s=i%6/5}const C=Math.max(F,e,s)*2;if(C===0)return 30;let D=30+(Math.round(s)<<2|Math.round(e)<<1|Math.round(F));return C===2&&(D+=60),D},enumerable:!1},rgbToAnsi:{value:(u,F,e)=>styles.ansi256ToAnsi(styles.rgbToAnsi256(u,F,e)),enumerable:!1},hexToAnsi:{value:u=>styles.ansi256ToAnsi(styles.hexToAnsi256(u)),enumerable:!1}}),styles}const ansiStyles=assembleStyles(),ESCAPES=new Set(["\x1B","\x9B"]),END_CODE=39,ANSI_ESCAPE_BELL="\x07",ANSI_CSI="[",ANSI_OSC="]",ANSI_SGR_TERMINATOR="m",ANSI_ESCAPE_LINK=`${ANSI_OSC}8;;`,wrapAnsiCode=t=>`${ESCAPES.values().next().value}${ANSI_CSI}${t}${ANSI_SGR_TERMINATOR}`,wrapAnsiHyperlink=t=>`${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${t}${ANSI_ESCAPE_BELL}`,wordLengths=t=>t.split(" ").map(u=>stringWidth(u)),wrapWord=(t,u,F)=>{const e=[...u];let s=!1,C=!1,D=stringWidth(stripAnsi(t[t.length-1]));for(const[i,n]of e.entries()){const r=stringWidth(n);if(D+r<=F?t[t.length-1]+=n:(t.push(n),D=0),ESCAPES.has(n)&&(s=!0,C=e.slice(i+1).join("").startsWith(ANSI_ESCAPE_LINK)),s){C?n===ANSI_ESCAPE_BELL&&(s=!1,C=!1):n===ANSI_SGR_TERMINATOR&&(s=!1);continue}D+=r,D===F&&i0&&t.length>1&&(t[t.length-2]+=t.pop())},stringVisibleTrimSpacesRight=t=>{const u=t.split(" ");let F=u.length;for(;F>0&&!(stringWidth(u[F-1])>0);)F--;return F===u.length?t:u.slice(0,F).join(" ")+u.slice(F).join("")},exec=(t,u,F={})=>{if(F.trim!==!1&&t.trim()==="")return"";let e="",s,C;const D=wordLengths(t);let i=[""];for(const[r,o]of t.split(" ").entries()){F.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let E=stringWidth(i[i.length-1]);if(r!==0&&(E>=u&&(F.wordWrap===!1||F.trim===!1)&&(i.push(""),E=0),(E>0||F.trim===!1)&&(i[i.length-1]+=" ",E++)),F.hard&&D[r]>u){const a=u-E,x=1+Math.floor((D[r]-a-1)/u);Math.floor((D[r]-1)/u)u&&E>0&&D[r]>0){if(F.wordWrap===!1&&Eu&&F.wordWrap===!1){wrapWord(i,o,u);continue}i[i.length-1]+=o}F.trim!==!1&&(i=i.map(r=>stringVisibleTrimSpacesRight(r)));const n=[...i.join(` +-`)];for(const[r,o]of n.entries()){if(e+=o,ESCAPES.has(o)){const{groups:a}=new RegExp(`(?:\\${ANSI_CSI}(?\\d+)m|\\${ANSI_ESCAPE_LINK}(?.*)${ANSI_ESCAPE_BELL})`).exec(n.slice(r).join(""))||{groups:{}};if(a.code!==void 0){const x=Number.parseFloat(a.code);s=x===END_CODE?void 0:x}else a.uri!==void 0&&(C=a.uri.length===0?void 0:a.uri)}const E=ansiStyles.codes.get(Number(s));n[r+1]===` +-`?(C&&(e+=wrapAnsiHyperlink("")),s&&E&&(e+=wrapAnsiCode(E))):o===` +-`&&(s&&E&&(e+=wrapAnsiCode(s)),C&&(e+=wrapAnsiHyperlink(C)))}return e};function wrapAnsi(t,u,F){return String(t).normalize().replace(/\r\n/g,` ++"use strict";const sisteransi=require("sisteransi"),node_process=require("node:process"),r$2=require("node:readline"),node_tty=require("node:tty"),i$1=require("picocolors");function _interopDefaultCompat(C){return C&&typeof C=="object"&&"default"in C?C.default:C}function _interopNamespaceCompat(C){if(C&&typeof C=="object"&&"default"in C)return C;const F=Object.create(null);if(C)for(const t in C)F[t]=C[t];return F.default=C,F}const r__default=_interopDefaultCompat(r$2),r__namespace=_interopNamespaceCompat(r$2),i__default=_interopDefaultCompat(i$1);function ansiRegex({onlyFirst:C=!1}={}){const F=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(F,C?void 0:"g")}function stripAnsi(C){if(typeof C!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof C}\``);return C.replace(ansiRegex(),"")}function getDefaultExportFromCjs(C){return C&&C.__esModule&&Object.prototype.hasOwnProperty.call(C,"default")?C.default:C}var eastasianwidth={exports:{}};(function(C){var F={};C.exports=F,F.eastAsianWidth=function(E){var x=E.charCodeAt(0),B=E.length==2?E.charCodeAt(1):0,D=x;return 55296<=x&&x<=56319&&56320<=B&&B<=57343&&(x&=1023,B&=1023,D=x<<10|B,D+=65536),D==12288||65281<=D&&D<=65376||65504<=D&&D<=65510?"F":D==8361||65377<=D&&D<=65470||65474<=D&&D<=65479||65482<=D&&D<=65487||65490<=D&&D<=65495||65498<=D&&D<=65500||65512<=D&&D<=65518?"H":4352<=D&&D<=4447||4515<=D&&D<=4519||4602<=D&&D<=4607||9001<=D&&D<=9002||11904<=D&&D<=11929||11931<=D&&D<=12019||12032<=D&&D<=12245||12272<=D&&D<=12283||12289<=D&&D<=12350||12353<=D&&D<=12438||12441<=D&&D<=12543||12549<=D&&D<=12589||12593<=D&&D<=12686||12688<=D&&D<=12730||12736<=D&&D<=12771||12784<=D&&D<=12830||12832<=D&&D<=12871||12880<=D&&D<=13054||13056<=D&&D<=19903||19968<=D&&D<=42124||42128<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||55216<=D&&D<=55238||55243<=D&&D<=55291||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65106||65108<=D&&D<=65126||65128<=D&&D<=65131||110592<=D&&D<=110593||127488<=D&&D<=127490||127504<=D&&D<=127546||127552<=D&&D<=127560||127568<=D&&D<=127569||131072<=D&&D<=194367||177984<=D&&D<=196605||196608<=D&&D<=262141?"W":32<=D&&D<=126||162<=D&&D<=163||165<=D&&D<=166||D==172||D==175||10214<=D&&D<=10221||10629<=D&&D<=10630?"Na":D==161||D==164||167<=D&&D<=168||D==170||173<=D&&D<=174||176<=D&&D<=180||182<=D&&D<=186||188<=D&&D<=191||D==198||D==208||215<=D&&D<=216||222<=D&&D<=225||D==230||232<=D&&D<=234||236<=D&&D<=237||D==240||242<=D&&D<=243||247<=D&&D<=250||D==252||D==254||D==257||D==273||D==275||D==283||294<=D&&D<=295||D==299||305<=D&&D<=307||D==312||319<=D&&D<=322||D==324||328<=D&&D<=331||D==333||338<=D&&D<=339||358<=D&&D<=359||D==363||D==462||D==464||D==466||D==468||D==470||D==472||D==474||D==476||D==593||D==609||D==708||D==711||713<=D&&D<=715||D==717||D==720||728<=D&&D<=731||D==733||D==735||768<=D&&D<=879||913<=D&&D<=929||931<=D&&D<=937||945<=D&&D<=961||963<=D&&D<=969||D==1025||1040<=D&&D<=1103||D==1105||D==8208||8211<=D&&D<=8214||8216<=D&&D<=8217||8220<=D&&D<=8221||8224<=D&&D<=8226||8228<=D&&D<=8231||D==8240||8242<=D&&D<=8243||D==8245||D==8251||D==8254||D==8308||D==8319||8321<=D&&D<=8324||D==8364||D==8451||D==8453||D==8457||D==8467||D==8470||8481<=D&&D<=8482||D==8486||D==8491||8531<=D&&D<=8532||8539<=D&&D<=8542||8544<=D&&D<=8555||8560<=D&&D<=8569||D==8585||8592<=D&&D<=8601||8632<=D&&D<=8633||D==8658||D==8660||D==8679||D==8704||8706<=D&&D<=8707||8711<=D&&D<=8712||D==8715||D==8719||D==8721||D==8725||D==8730||8733<=D&&D<=8736||D==8739||D==8741||8743<=D&&D<=8748||D==8750||8756<=D&&D<=8759||8764<=D&&D<=8765||D==8776||D==8780||D==8786||8800<=D&&D<=8801||8804<=D&&D<=8807||8810<=D&&D<=8811||8814<=D&&D<=8815||8834<=D&&D<=8835||8838<=D&&D<=8839||D==8853||D==8857||D==8869||D==8895||D==8978||9312<=D&&D<=9449||9451<=D&&D<=9547||9552<=D&&D<=9587||9600<=D&&D<=9615||9618<=D&&D<=9621||9632<=D&&D<=9633||9635<=D&&D<=9641||9650<=D&&D<=9651||9654<=D&&D<=9655||9660<=D&&D<=9661||9664<=D&&D<=9665||9670<=D&&D<=9672||D==9675||9678<=D&&D<=9681||9698<=D&&D<=9701||D==9711||9733<=D&&D<=9734||D==9737||9742<=D&&D<=9743||9748<=D&&D<=9749||D==9756||D==9758||D==9792||D==9794||9824<=D&&D<=9825||9827<=D&&D<=9829||9831<=D&&D<=9834||9836<=D&&D<=9837||D==9839||9886<=D&&D<=9887||9918<=D&&D<=9919||9924<=D&&D<=9933||9935<=D&&D<=9953||D==9955||9960<=D&&D<=9983||D==10045||D==10071||10102<=D&&D<=10111||11093<=D&&D<=11097||12872<=D&&D<=12879||57344<=D&&D<=63743||65024<=D&&D<=65039||D==65533||127232<=D&&D<=127242||127248<=D&&D<=127277||127280<=D&&D<=127337||127344<=D&&D<=127386||917760<=D&&D<=917999||983040<=D&&D<=1048573||1048576<=D&&D<=1114109?"A":"N"},F.characterLength=function(E){var x=this.eastAsianWidth(E);return x=="F"||x=="W"||x=="A"?2:1};function t(E){return E.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}F.length=function(E){for(var x=t(E),B=0,D=0;D=x-(b==2?1:0))if(A+b<=B)D+=k;else break;A+=b}return D}})(eastasianwidth);var eastasianwidthExports=eastasianwidth.exports;const eastAsianWidth=getDefaultExportFromCjs(eastasianwidthExports);var emojiRegex=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};const emojiRegex$1=getDefaultExportFromCjs(emojiRegex);function stringWidth(C,F={}){if(typeof C!="string"||C.length===0||(F={ambiguousIsNarrow:!0,...F},C=stripAnsi(C),C.length===0))return 0;C=C.replace(emojiRegex$1()," ");const t=F.ambiguousIsNarrow?1:2;let E=0;for(const x of C){const B=x.codePointAt(0);if(B<=31||B>=127&&B<=159||B>=768&&B<=879)continue;switch(eastAsianWidth.eastAsianWidth(x)){case"F":case"W":E+=2;break;case"A":E+=t;break;default:E+=1}}return E}const ANSI_BACKGROUND_OFFSET=10,wrapAnsi16=(C=0)=>F=>`\x1B[${F+C}m`,wrapAnsi256=(C=0)=>F=>`\x1B[${38+C};5;${F}m`,wrapAnsi16m=(C=0)=>(F,t,E)=>`\x1B[${38+C};2;${F};${t};${E}m`,styles={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(styles.modifier);const foregroundColorNames=Object.keys(styles.color),backgroundColorNames=Object.keys(styles.bgColor);[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){const C=new Map;for(const[F,t]of Object.entries(styles)){for(const[E,x]of Object.entries(t))styles[E]={open:`\x1B[${x[0]}m`,close:`\x1B[${x[1]}m`},t[E]=styles[E],C.set(x[0],x[1]);Object.defineProperty(styles,F,{value:t,enumerable:!1})}return Object.defineProperty(styles,"codes",{value:C,enumerable:!1}),styles.color.close="\x1B[39m",styles.bgColor.close="\x1B[49m",styles.color.ansi=wrapAnsi16(),styles.color.ansi256=wrapAnsi256(),styles.color.ansi16m=wrapAnsi16m(),styles.bgColor.ansi=wrapAnsi16(ANSI_BACKGROUND_OFFSET),styles.bgColor.ansi256=wrapAnsi256(ANSI_BACKGROUND_OFFSET),styles.bgColor.ansi16m=wrapAnsi16m(ANSI_BACKGROUND_OFFSET),Object.defineProperties(styles,{rgbToAnsi256:{value:(F,t,E)=>F===t&&t===E?F<8?16:F>248?231:Math.round((F-8)/247*24)+232:16+36*Math.round(F/255*5)+6*Math.round(t/255*5)+Math.round(E/255*5),enumerable:!1},hexToRgb:{value:F=>{const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(F.toString(16));if(!t)return[0,0,0];let[E]=t;E.length===3&&(E=[...E].map(B=>B+B).join(""));const x=Number.parseInt(E,16);return[x>>16&255,x>>8&255,x&255]},enumerable:!1},hexToAnsi256:{value:F=>styles.rgbToAnsi256(...styles.hexToRgb(F)),enumerable:!1},ansi256ToAnsi:{value:F=>{if(F<8)return 30+F;if(F<16)return 90+(F-8);let t,E,x;if(F>=232)t=((F-232)*10+8)/255,E=t,x=t;else{F-=16;const A=F%36;t=Math.floor(F/36)/5,E=Math.floor(A/6)/5,x=A%6/5}const B=Math.max(t,E,x)*2;if(B===0)return 30;let D=30+(Math.round(x)<<2|Math.round(E)<<1|Math.round(t));return B===2&&(D+=60),D},enumerable:!1},rgbToAnsi:{value:(F,t,E)=>styles.ansi256ToAnsi(styles.rgbToAnsi256(F,t,E)),enumerable:!1},hexToAnsi:{value:F=>styles.ansi256ToAnsi(styles.hexToAnsi256(F)),enumerable:!1}}),styles}const ansiStyles=assembleStyles(),ESCAPES=new Set(["\x1B","\x9B"]),END_CODE=39,ANSI_ESCAPE_BELL="\x07",ANSI_CSI="[",ANSI_OSC="]",ANSI_SGR_TERMINATOR="m",ANSI_ESCAPE_LINK=`${ANSI_OSC}8;;`,wrapAnsiCode=C=>`${ESCAPES.values().next().value}${ANSI_CSI}${C}${ANSI_SGR_TERMINATOR}`,wrapAnsiHyperlink=C=>`${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${C}${ANSI_ESCAPE_BELL}`,wordLengths=C=>C.split(" ").map(F=>stringWidth(F)),wrapWord=(C,F,t)=>{const E=[...F];let x=!1,B=!1,D=stringWidth(stripAnsi(C[C.length-1]));for(const[A,w]of E.entries()){const v=stringWidth(w);if(D+v<=t?C[C.length-1]+=w:(C.push(w),D=0),ESCAPES.has(w)&&(x=!0,B=E.slice(A+1).join("").startsWith(ANSI_ESCAPE_LINK)),x){B?w===ANSI_ESCAPE_BELL&&(x=!1,B=!1):w===ANSI_SGR_TERMINATOR&&(x=!1);continue}D+=v,D===t&&A0&&C.length>1&&(C[C.length-2]+=C.pop())},stringVisibleTrimSpacesRight=C=>{const F=C.split(" ");let t=F.length;for(;t>0&&!(stringWidth(F[t-1])>0);)t--;return t===F.length?C:F.slice(0,t).join(" ")+F.slice(t).join("")},exec=(C,F,t={})=>{if(t.trim!==!1&&C.trim()==="")return"";let E="",x,B;const D=wordLengths(C);let A=[""];for(const[v,k]of C.split(" ").entries()){t.trim!==!1&&(A[A.length-1]=A[A.length-1].trimStart());let b=stringWidth(A[A.length-1]);if(v!==0&&(b>=F&&(t.wordWrap===!1||t.trim===!1)&&(A.push(""),b=0),(b>0||t.trim===!1)&&(A[A.length-1]+=" ",b++)),t.hard&&D[v]>F){const $=F-b,S=1+Math.floor((D[v]-$-1)/F);Math.floor((D[v]-1)/F)F&&b>0&&D[v]>0){if(t.wordWrap===!1&&bF&&t.wordWrap===!1){wrapWord(A,k,F);continue}A[A.length-1]+=k}t.trim!==!1&&(A=A.map(v=>stringVisibleTrimSpacesRight(v)));const w=[...A.join(` ++`)];for(const[v,k]of w.entries()){if(E+=k,ESCAPES.has(k)){const{groups:$}=new RegExp(`(?:\\${ANSI_CSI}(?\\d+)m|\\${ANSI_ESCAPE_LINK}(?.*)${ANSI_ESCAPE_BELL})`).exec(w.slice(v).join(""))||{groups:{}};if($.code!==void 0){const S=Number.parseFloat($.code);x=S===END_CODE?void 0:S}else $.uri!==void 0&&(B=$.uri.length===0?void 0:$.uri)}const b=ansiStyles.codes.get(Number(x));w[v+1]===` ++`?(B&&(E+=wrapAnsiHyperlink("")),x&&b&&(E+=wrapAnsiCode(b))):k===` ++`&&(x&&b&&(E+=wrapAnsiCode(x)),B&&(E+=wrapAnsiHyperlink(B)))}return E};function wrapAnsi(C,F,t){return String(C).normalize().replace(/\r\n/g,` + `).split(` +-`).map(e=>exec(e,u,F)).join(` +-`)}function diffLines(t,u){if(t===u)return;const F=t.split(` +-`),e=u.split(` +-`),s=[];for(let C=0;C{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),s()},this.input.pipe(u),this.rl=readline.createInterface({input:this.input,output:u,tabSize:2,prompt:"",escapeCodeTimeout:50}),readline.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),setRawMode(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((F,e)=>{this.once("submit",()=>{this.output.write(sisteransi.cursor.show),this.output.off("resize",this.render),setRawMode(this.input,!1),F(this.value)}),this.once("cancel",()=>{this.output.write(sisteransi.cursor.show),this.output.off("resize",this.render),setRawMode(this.input,!1),F(cancel)})})}on(u,F){const e=this.subscribers.get(u)??[];e.push({cb:F}),this.subscribers.set(u,e)}once(u,F){const e=this.subscribers.get(u)??[];e.push({cb:F,once:!0}),this.subscribers.set(u,e)}emit(u,...F){const e=this.subscribers.get(u)??[],s=[];for(const C of e)C.cb(...F),C.once&&s.push(()=>e.splice(e.indexOf(C),1));for(const C of s)C()}unsubscribe(){this.subscribers.clear()}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&!this._track&&aliases.has(F.name)&&this.emit("cursor",aliases.get(F.name)),F?.name&&keys.has(F.name)&&this.emit("cursor",F.name),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}u===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` +-`),setRawMode(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const u=wrapAnsi(this._prevFrame,process.stdout.columns,{hard:!0}).split(` +-`).length-1;this.output.write(sisteransi.cursor.move(-999,u*-1))}render(){const u=wrapAnsi(this._render(this)??"",process.stdout.columns,{hard:!0});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(sisteransi.cursor.hide);else{const F=diffLines(this._prevFrame,u);if(this.restoreCursor(),F&&F?.length===1){const e=F[0];this.output.write(sisteransi.cursor.move(0,e)),this.output.write(sisteransi.erase.lines(1));const s=u.split(` +-`);this.output.write(s[e]),this._prevFrame=u,this.output.write(sisteransi.cursor.move(0,s.length-e-1));return}else if(F&&F?.length>1){const e=F[0];this.output.write(sisteransi.cursor.move(0,e)),this.output.write(sisteransi.erase.down());const C=u.split(` +-`).slice(e);this.output.write(C.join(` +-`)),this._prevFrame=u;return}this.output.write(sisteransi.erase.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}class ConfirmPrompt extends Prompt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",F=>{this.output.write(sisteransi.cursor.move(0,-1)),this.value=F,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class GroupMultiSelectPrompt extends Prompt{constructor(u){super(u,!1),this.cursor=0;const{options:F}=u;this.options=Object.entries(F).flatMap(([e,s])=>[{value:e,group:!0,label:e},...s.map(C=>({...C,group:e}))]),this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===u.cursorAt),0),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(u){return this.options.filter(F=>F.group===u)}isGroupSelected(u){return this.getGroupItems(u).every(e=>this.value.includes(e.value))}toggleValue(){const u=this.options[this.cursor];if(u.group===!0){const F=u.value,e=this.getGroupItems(F);this.isGroupSelected(F)?this.value=this.value.filter(s=>e.findIndex(C=>C.value===s)===-1):this.value=[...this.value,...e.map(s=>s.value)],this.value=Array.from(new Set(this.value))}else{const F=this.value.includes(u.value);this.value=F?this.value.filter(e=>e!==u.value):[...this.value,u.value]}}}class MultiSelectPrompt extends Prompt{constructor(u){super(u,!1),this.cursor=0,this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===u.cursorAt),0),this.on("key",F=>{F==="a"&&this.toggleAll()}),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(F=>F.value)}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(F=>F!==this._value):[...this.value,this._value]}}class PasswordPrompt extends Prompt{constructor({mask:u,...F}){super(F),this.valueWithCursor="",this._mask="\u2022",this._mask=u??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${color.inverse(color.hidden("_"))}`;else{const e=this.masked.slice(0,this.cursor),s=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${color.inverse(s[0])}${s.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}class SelectPrompt extends Prompt{constructor(u){super(u,!1),this.cursor=0,this.options=u.options,this.cursor=this.options.findIndex(({value:F})=>F===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}class SelectKeyPrompt extends Prompt{constructor(u){super(u,!1),this.cursor=0,this.options=u.options;const F=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(F.indexOf(u.initialValue),0),this.on("key",e=>{if(!F.includes(e))return;const s=this.options.find(({value:[C]})=>C?.toLowerCase()===e);s&&(this.value=s.value,this.state="submit",this.emit("submit"))})}}class TextPrompt extends Prompt{constructor(u){super(u),this.valueWithCursor="",this.on("finalize",()=>{this.value||(this.value=u.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${color.inverse(color.hidden("_"))}`;else{const F=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${F}${color.inverse(e[0])}${e.slice(1)}`}})}get cursor(){return this._cursor}}function block({input:t=node_process.stdin,output:u=node_process.stdout,overwrite:F=!0,hideCursor:e=!0}={}){const s=readline__namespace.createInterface({input:t,output:u,prompt:"",tabSize:1});readline__namespace.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);const C=(D,{name:i})=>{if(String(D)===""&&process.exit(0),!F)return;let r=i==="return"?0:-1,o=i==="return"?-1:0;readline__namespace.moveCursor(u,r,o,()=>{readline__namespace.clearLine(u,1,()=>{t.once("keypress",C)})})};return e&&process.stdout.write(sisteransi.cursor.hide),t.once("keypress",C),()=>{t.off("keypress",C),e&&process.stdout.write(sisteransi.cursor.show),t.isTTY&&t.setRawMode(!1),s.terminal=!1,s.close()}}exports.ConfirmPrompt=ConfirmPrompt,exports.GroupMultiSelectPrompt=GroupMultiSelectPrompt,exports.MultiSelectPrompt=MultiSelectPrompt,exports.PasswordPrompt=PasswordPrompt,exports.Prompt=Prompt,exports.SelectKeyPrompt=SelectKeyPrompt,exports.SelectPrompt=SelectPrompt,exports.TextPrompt=TextPrompt,exports.block=block,exports.isCancel=isCancel; ++`).map(E=>exec(E,F,t)).join(` ++`)}var f=Object.defineProperty,d=(C,F,t)=>F in C?f(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,o$3=(C,F,t)=>(d(C,typeof F!="symbol"?F+"":F,t),t);function g(C,F){if(C===F)return;const t=C.split(` ++`),E=F.split(` ++`),x=[];for(let B=0;B{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),x()},this.input.pipe(F),this.rl=r__default.createInterface({input:this.input,output:F,tabSize:2,prompt:"",escapeCodeTimeout:50}),r__default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),p$1(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((t,E)=>{this.once("submit",()=>{this.output.write(sisteransi.cursor.show),this.output.off("resize",this.render),p$1(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(sisteransi.cursor.show),this.output.off("resize",this.render),p$1(this.input,!1),t(c$1)})})}on(F,t){const E=this.subscribers.get(F)??[];E.push({cb:t}),this.subscribers.set(F,E)}once(F,t){const E=this.subscribers.get(F)??[];E.push({cb:t,once:!0}),this.subscribers.set(F,E)}emit(F,...t){const E=this.subscribers.get(F)??[],x=[];for(const B of E)B.cb(...t),B.once&&x.push(()=>E.splice(E.indexOf(B),1));for(const B of x)B()}unsubscribe(){this.subscribers.clear()}onKeypress(F,t){if(this.state==="error"&&(this.state="active"),t?.name&&!this._track&&m$1.has(t.name)&&this.emit("cursor",m$1.get(t.name)),t?.name&&y.has(t.name)&&this.emit("cursor",t.name),F&&(F.toLowerCase()==="y"||F.toLowerCase()==="n")&&this.emit("confirm",F.toLowerCase()==="y"),F===" "&&this.opts.autocomplete){const E=this.opts.autocomplete(this.value);E&&(this.rl.write(E),this.emit("value",E))}if(F===" "&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),F&&this.emit("key",F.toLowerCase()),t?.name==="return"){if(this.opts.validate){const E=this.opts.validate(this.value);E&&(this.error=E,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}F===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` ++`),p$1(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const F=wrapAnsi(this._prevFrame,process.stdout.columns,{hard:!0}).split(` ++`).length-1;this.output.write(sisteransi.cursor.move(-999,F*-1))}render(){const F=wrapAnsi(this._render(this)??"",process.stdout.columns,{hard:!0});if(F!==this._prevFrame){if(this.state==="initial")this.output.write(sisteransi.cursor.hide);else{const t=g(this._prevFrame,F);if(this.restoreCursor(),t&&t?.length===1){const E=t[0];this.output.write(sisteransi.cursor.move(0,E)),this.output.write(sisteransi.erase.lines(1));const x=F.split(` ++`);this.output.write(x[E]),this._prevFrame=F,this.output.write(sisteransi.cursor.move(0,x.length-E-1));return}else if(t&&t?.length>1){const E=t[0];this.output.write(sisteransi.cursor.move(0,E)),this.output.write(sisteransi.erase.down());const x=F.split(` ++`).slice(E);this.output.write(x.join(` ++`)),this._prevFrame=F;return}this.output.write(sisteransi.erase.down())}this.output.write(F),this.state==="initial"&&(this.state="active"),this._prevFrame=F}}}class s extends _{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(F){super(F,!1),this.value=!!F.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(sisteransi.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var a=Object.defineProperty,n$3=(C,F,t)=>F in C?a(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,l$3=(C,F,t)=>(n$3(C,typeof F!="symbol"?F+"":F,t),t);class p extends _{constructor(F){super(F,!1),l$3(this,"options"),l$3(this,"cursor",0);const{options:t}=F;this.options=Object.entries(t).flatMap(([E,x])=>[{value:E,group:!0,label:E},...x.map(B=>({...B,group:E}))]),this.value=[...F.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:E})=>E===F.cursorAt),0),this.on("cursor",E=>{switch(E){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(F){return this.options.filter(t=>t.group===F)}isGroupSelected(F){return this.getGroupItems(F).every(t=>this.value.includes(t.value))}toggleValue(){const F=this.options[this.cursor];if(F.group===!0){const t=F.value,E=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(x=>E.findIndex(B=>B.value===x)===-1):this.value=[...this.value,...E.map(x=>x.value)],this.value=Array.from(new Set(this.value))}else{const t=this.value.includes(F.value);this.value=t?this.value.filter(E=>E!==F.value):[...this.value,F.value]}}}var o$2=Object.defineProperty,r$1=(C,F,t)=>F in C?o$2(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,l$2=(C,F,t)=>(r$1(C,typeof F!="symbol"?F+"":F,t),t);let u$3=class extends _{constructor(F){super(F,!1),l$2(this,"options"),l$2(this,"cursor",0),this.options=F.options,this.value=[...F.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===F.cursorAt),0),this.on("key",t=>{t==="a"&&this.toggleAll()}),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const F=this.value.length===this.options.length;this.value=F?[]:this.options.map(t=>t.value)}toggleValue(){const F=this.value.includes(this._value);this.value=F?this.value.filter(t=>t!==this._value):[...this.value,this._value]}};var u$2=Object.defineProperty,n$2=(C,F,t)=>F in C?u$2(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,e=(C,F,t)=>(n$2(C,typeof F!="symbol"?F+"":F,t),t);class m extends _{constructor({mask:F,...t}){super(t),e(this,"valueWithCursor",""),e(this,"_mask","\u2022"),this._mask=F??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${i__default.inverse(i__default.hidden("_"))}`;else{const E=this.masked.slice(0,this.cursor),x=this.masked.slice(this.cursor);this.valueWithCursor=`${E}${i__default.inverse(x[0])}${x.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}var o$1=Object.defineProperty,n$1=(C,F,t)=>F in C?o$1(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,r=(C,F,t)=>(n$1(C,typeof F!="symbol"?F+"":F,t),t);let u$1=class extends _{constructor(F){super(F,!1),r(this,"options"),r(this,"cursor",0),this.options=F.options,this.cursor=this.options.findIndex(({value:t})=>t===F.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var u=Object.defineProperty,l$1=(C,F,t)=>F in C?u(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,i=(C,F,t)=>(l$1(C,typeof F!="symbol"?F+"":F,t),t);class c extends _{constructor(F){super(F,!1),i(this,"options"),i(this,"cursor",0),this.options=F.options;const t=this.options.map(({value:[E]})=>E?.toLowerCase());this.cursor=Math.max(t.indexOf(F.initialValue),0),this.on("key",E=>{if(!t.includes(E))return;const x=this.options.find(({value:[B]})=>B?.toLowerCase()===E);x&&(this.value=x.value,this.state="submit",this.emit("submit"))})}}var l=Object.defineProperty,h=(C,F,t)=>F in C?l(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,o=(C,F,t)=>(h(C,typeof F!="symbol"?F+"":F,t),t);class n extends _{constructor(F){super(F),o(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=F.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${i__default.inverse(i__default.hidden("_"))}`;else{const t=this.value.slice(0,this.cursor),E=this.value.slice(this.cursor);this.valueWithCursor=`${t}${i__default.inverse(E[0])}${E.slice(1)}`}})}get cursor(){return this._cursor}}function block({input:C=node_process.stdin,output:F=node_process.stdout,overwrite:t=!0,hideCursor:E=!0}={}){const x=r__namespace.createInterface({input:C,output:F,prompt:"",tabSize:1});r__namespace.emitKeypressEvents(C,x),C.isTTY&&C.setRawMode(!0);const B=(D,{name:A})=>{if(String(D)===""&&process.exit(0),!t)return;let w=A==="return"?0:-1,v=A==="return"?-1:0;r__namespace.moveCursor(F,w,v,()=>{r__namespace.clearLine(F,1,()=>{C.once("keypress",B)})})};return E&&process.stdout.write(sisteransi.cursor.hide),C.once("keypress",B),()=>{C.off("keypress",B),E&&process.stdout.write(sisteransi.cursor.show),x.terminal=!1,x.close()}}exports.ConfirmPrompt=s,exports.GroupMultiSelectPrompt=p,exports.MultiSelectPrompt=u$3,exports.PasswordPrompt=m,exports.Prompt=_,exports.SelectKeyPrompt=c,exports.SelectPrompt=u$1,exports.TextPrompt=n,exports.block=block,exports.isCancel=isCancel; ++//# sourceMappingURL=index.cjs.map +diff --git a/dist/index.d.ts b/dist/index.d.ts +index c86606801795decb5a2a61c858e7c4c1c9606510..1f9534c831ffbf563bae8a01cc6935a89eb0d362 100644 +--- a/dist/index.d.ts ++++ b/dist/index.d.ts +@@ -4,6 +4,7 @@ declare function isCancel(value: unknown): value is symbol; + interface PromptOptions { + render(this: Omit): string | void; + placeholder?: string; ++ autocomplete?: ((value: any) => string | void) | undefined; + initialValue?: any; + validate?: ((value: any) => string | void) | undefined; + input?: Readable; +@@ -148,4 +149,4 @@ declare function block({ input, output, overwrite, hideCursor, }?: { + hideCursor?: boolean | undefined; + }): () => void; + +-export { ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, State, TextPrompt, block, isCancel }; ++export { ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, type State, TextPrompt, block, isCancel }; +diff --git a/dist/index.mjs b/dist/index.mjs +index a9acb4cff1f5a6cd587eb30a846ce0f6009765e9..af702caf101666267d662f0888c33da363c5fbc7 100644 +--- a/dist/index.mjs ++++ b/dist/index.mjs +@@ -1,14 +1,15 @@ +-import{cursor as x,erase as d}from"sisteransi";import{stdin as k,stdout as y}from"node:process";import*as f from"node:readline";import S from"node:readline";import{WriteStream as O}from"node:tty";import l from"picocolors";function z({onlyFirst:t=!1}={}){const u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(u,t?void 0:"g")}function $(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(z(),"")}var m={},G={get exports(){return m},set exports(t){m=t}};(function(t){var u={};t.exports=u,u.eastAsianWidth=function(e){var s=e.charCodeAt(0),C=e.length==2?e.charCodeAt(1):0,D=s;return 55296<=s&&s<=56319&&56320<=C&&C<=57343&&(s&=1023,C&=1023,D=s<<10|C,D+=65536),D==12288||65281<=D&&D<=65376||65504<=D&&D<=65510?"F":D==8361||65377<=D&&D<=65470||65474<=D&&D<=65479||65482<=D&&D<=65487||65490<=D&&D<=65495||65498<=D&&D<=65500||65512<=D&&D<=65518?"H":4352<=D&&D<=4447||4515<=D&&D<=4519||4602<=D&&D<=4607||9001<=D&&D<=9002||11904<=D&&D<=11929||11931<=D&&D<=12019||12032<=D&&D<=12245||12272<=D&&D<=12283||12289<=D&&D<=12350||12353<=D&&D<=12438||12441<=D&&D<=12543||12549<=D&&D<=12589||12593<=D&&D<=12686||12688<=D&&D<=12730||12736<=D&&D<=12771||12784<=D&&D<=12830||12832<=D&&D<=12871||12880<=D&&D<=13054||13056<=D&&D<=19903||19968<=D&&D<=42124||42128<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||55216<=D&&D<=55238||55243<=D&&D<=55291||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65106||65108<=D&&D<=65126||65128<=D&&D<=65131||110592<=D&&D<=110593||127488<=D&&D<=127490||127504<=D&&D<=127546||127552<=D&&D<=127560||127568<=D&&D<=127569||131072<=D&&D<=194367||177984<=D&&D<=196605||196608<=D&&D<=262141?"W":32<=D&&D<=126||162<=D&&D<=163||165<=D&&D<=166||D==172||D==175||10214<=D&&D<=10221||10629<=D&&D<=10630?"Na":D==161||D==164||167<=D&&D<=168||D==170||173<=D&&D<=174||176<=D&&D<=180||182<=D&&D<=186||188<=D&&D<=191||D==198||D==208||215<=D&&D<=216||222<=D&&D<=225||D==230||232<=D&&D<=234||236<=D&&D<=237||D==240||242<=D&&D<=243||247<=D&&D<=250||D==252||D==254||D==257||D==273||D==275||D==283||294<=D&&D<=295||D==299||305<=D&&D<=307||D==312||319<=D&&D<=322||D==324||328<=D&&D<=331||D==333||338<=D&&D<=339||358<=D&&D<=359||D==363||D==462||D==464||D==466||D==468||D==470||D==472||D==474||D==476||D==593||D==609||D==708||D==711||713<=D&&D<=715||D==717||D==720||728<=D&&D<=731||D==733||D==735||768<=D&&D<=879||913<=D&&D<=929||931<=D&&D<=937||945<=D&&D<=961||963<=D&&D<=969||D==1025||1040<=D&&D<=1103||D==1105||D==8208||8211<=D&&D<=8214||8216<=D&&D<=8217||8220<=D&&D<=8221||8224<=D&&D<=8226||8228<=D&&D<=8231||D==8240||8242<=D&&D<=8243||D==8245||D==8251||D==8254||D==8308||D==8319||8321<=D&&D<=8324||D==8364||D==8451||D==8453||D==8457||D==8467||D==8470||8481<=D&&D<=8482||D==8486||D==8491||8531<=D&&D<=8532||8539<=D&&D<=8542||8544<=D&&D<=8555||8560<=D&&D<=8569||D==8585||8592<=D&&D<=8601||8632<=D&&D<=8633||D==8658||D==8660||D==8679||D==8704||8706<=D&&D<=8707||8711<=D&&D<=8712||D==8715||D==8719||D==8721||D==8725||D==8730||8733<=D&&D<=8736||D==8739||D==8741||8743<=D&&D<=8748||D==8750||8756<=D&&D<=8759||8764<=D&&D<=8765||D==8776||D==8780||D==8786||8800<=D&&D<=8801||8804<=D&&D<=8807||8810<=D&&D<=8811||8814<=D&&D<=8815||8834<=D&&D<=8835||8838<=D&&D<=8839||D==8853||D==8857||D==8869||D==8895||D==8978||9312<=D&&D<=9449||9451<=D&&D<=9547||9552<=D&&D<=9587||9600<=D&&D<=9615||9618<=D&&D<=9621||9632<=D&&D<=9633||9635<=D&&D<=9641||9650<=D&&D<=9651||9654<=D&&D<=9655||9660<=D&&D<=9661||9664<=D&&D<=9665||9670<=D&&D<=9672||D==9675||9678<=D&&D<=9681||9698<=D&&D<=9701||D==9711||9733<=D&&D<=9734||D==9737||9742<=D&&D<=9743||9748<=D&&D<=9749||D==9756||D==9758||D==9792||D==9794||9824<=D&&D<=9825||9827<=D&&D<=9829||9831<=D&&D<=9834||9836<=D&&D<=9837||D==9839||9886<=D&&D<=9887||9918<=D&&D<=9919||9924<=D&&D<=9933||9935<=D&&D<=9953||D==9955||9960<=D&&D<=9983||D==10045||D==10071||10102<=D&&D<=10111||11093<=D&&D<=11097||12872<=D&&D<=12879||57344<=D&&D<=63743||65024<=D&&D<=65039||D==65533||127232<=D&&D<=127242||127248<=D&&D<=127277||127280<=D&&D<=127337||127344<=D&&D<=127386||917760<=D&&D<=917999||983040<=D&&D<=1048573||1048576<=D&&D<=1114109?"A":"N"},u.characterLength=function(e){var s=this.eastAsianWidth(e);return s=="F"||s=="W"||s=="A"?2:1};function F(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}u.length=function(e){for(var s=F(e),C=0,D=0;D=s-(n==2?1:0))if(i+n<=C)D+=a;else break;i+=n}return D}})(G);const K=m;var Y=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};function c(t,u={}){if(typeof t!="string"||t.length===0||(u={ambiguousIsNarrow:!0,...u},t=$(t),t.length===0))return 0;t=t.replace(Y()," ");const F=u.ambiguousIsNarrow?1:2;let e=0;for(const s of t){const C=s.codePointAt(0);if(C<=31||C>=127&&C<=159||C>=768&&C<=879)continue;switch(K.eastAsianWidth(s)){case"F":case"W":e+=2;break;case"A":e+=F;break;default:e+=1}}return e}const v=10,M=(t=0)=>u=>`\x1B[${u+t}m`,L=(t=0)=>u=>`\x1B[${38+t};5;${u}m`,T=(t=0)=>(u,F,e)=>`\x1B[${38+t};2;${u};${F};${e}m`,r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r.modifier);const Z=Object.keys(r.color),H=Object.keys(r.bgColor);[...Z,...H];function U(){const t=new Map;for(const[u,F]of Object.entries(r)){for(const[e,s]of Object.entries(F))r[e]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},F[e]=r[e],t.set(s[0],s[1]);Object.defineProperty(r,u,{value:F,enumerable:!1})}return Object.defineProperty(r,"codes",{value:t,enumerable:!1}),r.color.close="\x1B[39m",r.bgColor.close="\x1B[49m",r.color.ansi=M(),r.color.ansi256=L(),r.color.ansi16m=T(),r.bgColor.ansi=M(v),r.bgColor.ansi256=L(v),r.bgColor.ansi16m=T(v),Object.defineProperties(r,{rgbToAnsi256:{value:(u,F,e)=>u===F&&F===e?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(e/255*5),enumerable:!1},hexToRgb:{value:u=>{const F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[e]=F;e.length===3&&(e=[...e].map(C=>C+C).join(""));const s=Number.parseInt(e,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:u=>r.rgbToAnsi256(...r.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value:u=>{if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,e,s;if(u>=232)F=((u-232)*10+8)/255,e=F,s=F;else{u-=16;const i=u%36;F=Math.floor(u/36)/5,e=Math.floor(i/6)/5,s=i%6/5}const C=Math.max(F,e,s)*2;if(C===0)return 30;let D=30+(Math.round(s)<<2|Math.round(e)<<1|Math.round(F));return C===2&&(D+=60),D},enumerable:!1},rgbToAnsi:{value:(u,F,e)=>r.ansi256ToAnsi(r.rgbToAnsi256(u,F,e)),enumerable:!1},hexToAnsi:{value:u=>r.ansi256ToAnsi(r.hexToAnsi256(u)),enumerable:!1}}),r}const q=U(),p=new Set(["\x1B","\x9B"]),J=39,b="\x07",W="[",Q="]",I="m",w=`${Q}8;;`,N=t=>`${p.values().next().value}${W}${t}${I}`,j=t=>`${p.values().next().value}${w}${t}${b}`,X=t=>t.split(" ").map(u=>c(u)),_=(t,u,F)=>{const e=[...u];let s=!1,C=!1,D=c($(t[t.length-1]));for(const[i,o]of e.entries()){const E=c(o);if(D+E<=F?t[t.length-1]+=o:(t.push(o),D=0),p.has(o)&&(s=!0,C=e.slice(i+1).join("").startsWith(w)),s){C?o===b&&(s=!1,C=!1):o===I&&(s=!1);continue}D+=E,D===F&&i0&&t.length>1&&(t[t.length-2]+=t.pop())},DD=t=>{const u=t.split(" ");let F=u.length;for(;F>0&&!(c(u[F-1])>0);)F--;return F===u.length?t:u.slice(0,F).join(" ")+u.slice(F).join("")},uD=(t,u,F={})=>{if(F.trim!==!1&&t.trim()==="")return"";let e="",s,C;const D=X(t);let i=[""];for(const[E,a]of t.split(" ").entries()){F.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let n=c(i[i.length-1]);if(E!==0&&(n>=u&&(F.wordWrap===!1||F.trim===!1)&&(i.push(""),n=0),(n>0||F.trim===!1)&&(i[i.length-1]+=" ",n++)),F.hard&&D[E]>u){const B=u-n,A=1+Math.floor((D[E]-B-1)/u);Math.floor((D[E]-1)/u)u&&n>0&&D[E]>0){if(F.wordWrap===!1&&nu&&F.wordWrap===!1){_(i,a,u);continue}i[i.length-1]+=a}F.trim!==!1&&(i=i.map(E=>DD(E)));const o=[...i.join(` +-`)];for(const[E,a]of o.entries()){if(e+=a,p.has(a)){const{groups:B}=new RegExp(`(?:\\${W}(?\\d+)m|\\${w}(?.*)${b})`).exec(o.slice(E).join(""))||{groups:{}};if(B.code!==void 0){const A=Number.parseFloat(B.code);s=A===J?void 0:A}else B.uri!==void 0&&(C=B.uri.length===0?void 0:B.uri)}const n=q.codes.get(Number(s));o[E+1]===` +-`?(C&&(e+=j("")),s&&n&&(e+=N(n))):a===` +-`&&(s&&n&&(e+=N(s)),C&&(e+=j(C)))}return e};function P(t,u,F){return String(t).normalize().replace(/\r\n/g,` ++import{cursor as l,erase as m}from"sisteransi";import{stdin as $,stdout as k}from"node:process";import*as f from"node:readline";import _ from"node:readline";import{WriteStream as U}from"node:tty";import c from"picocolors";function q({onlyFirst:t=!1}={}){const u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(u,t?void 0:"g")}function S(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(q(),"")}function j(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var M={exports:{}};(function(t){var u={};t.exports=u,u.eastAsianWidth=function(e){var s=e.charCodeAt(0),C=e.length==2?e.charCodeAt(1):0,D=s;return 55296<=s&&s<=56319&&56320<=C&&C<=57343&&(s&=1023,C&=1023,D=s<<10|C,D+=65536),D==12288||65281<=D&&D<=65376||65504<=D&&D<=65510?"F":D==8361||65377<=D&&D<=65470||65474<=D&&D<=65479||65482<=D&&D<=65487||65490<=D&&D<=65495||65498<=D&&D<=65500||65512<=D&&D<=65518?"H":4352<=D&&D<=4447||4515<=D&&D<=4519||4602<=D&&D<=4607||9001<=D&&D<=9002||11904<=D&&D<=11929||11931<=D&&D<=12019||12032<=D&&D<=12245||12272<=D&&D<=12283||12289<=D&&D<=12350||12353<=D&&D<=12438||12441<=D&&D<=12543||12549<=D&&D<=12589||12593<=D&&D<=12686||12688<=D&&D<=12730||12736<=D&&D<=12771||12784<=D&&D<=12830||12832<=D&&D<=12871||12880<=D&&D<=13054||13056<=D&&D<=19903||19968<=D&&D<=42124||42128<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||55216<=D&&D<=55238||55243<=D&&D<=55291||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65106||65108<=D&&D<=65126||65128<=D&&D<=65131||110592<=D&&D<=110593||127488<=D&&D<=127490||127504<=D&&D<=127546||127552<=D&&D<=127560||127568<=D&&D<=127569||131072<=D&&D<=194367||177984<=D&&D<=196605||196608<=D&&D<=262141?"W":32<=D&&D<=126||162<=D&&D<=163||165<=D&&D<=166||D==172||D==175||10214<=D&&D<=10221||10629<=D&&D<=10630?"Na":D==161||D==164||167<=D&&D<=168||D==170||173<=D&&D<=174||176<=D&&D<=180||182<=D&&D<=186||188<=D&&D<=191||D==198||D==208||215<=D&&D<=216||222<=D&&D<=225||D==230||232<=D&&D<=234||236<=D&&D<=237||D==240||242<=D&&D<=243||247<=D&&D<=250||D==252||D==254||D==257||D==273||D==275||D==283||294<=D&&D<=295||D==299||305<=D&&D<=307||D==312||319<=D&&D<=322||D==324||328<=D&&D<=331||D==333||338<=D&&D<=339||358<=D&&D<=359||D==363||D==462||D==464||D==466||D==468||D==470||D==472||D==474||D==476||D==593||D==609||D==708||D==711||713<=D&&D<=715||D==717||D==720||728<=D&&D<=731||D==733||D==735||768<=D&&D<=879||913<=D&&D<=929||931<=D&&D<=937||945<=D&&D<=961||963<=D&&D<=969||D==1025||1040<=D&&D<=1103||D==1105||D==8208||8211<=D&&D<=8214||8216<=D&&D<=8217||8220<=D&&D<=8221||8224<=D&&D<=8226||8228<=D&&D<=8231||D==8240||8242<=D&&D<=8243||D==8245||D==8251||D==8254||D==8308||D==8319||8321<=D&&D<=8324||D==8364||D==8451||D==8453||D==8457||D==8467||D==8470||8481<=D&&D<=8482||D==8486||D==8491||8531<=D&&D<=8532||8539<=D&&D<=8542||8544<=D&&D<=8555||8560<=D&&D<=8569||D==8585||8592<=D&&D<=8601||8632<=D&&D<=8633||D==8658||D==8660||D==8679||D==8704||8706<=D&&D<=8707||8711<=D&&D<=8712||D==8715||D==8719||D==8721||D==8725||D==8730||8733<=D&&D<=8736||D==8739||D==8741||8743<=D&&D<=8748||D==8750||8756<=D&&D<=8759||8764<=D&&D<=8765||D==8776||D==8780||D==8786||8800<=D&&D<=8801||8804<=D&&D<=8807||8810<=D&&D<=8811||8814<=D&&D<=8815||8834<=D&&D<=8835||8838<=D&&D<=8839||D==8853||D==8857||D==8869||D==8895||D==8978||9312<=D&&D<=9449||9451<=D&&D<=9547||9552<=D&&D<=9587||9600<=D&&D<=9615||9618<=D&&D<=9621||9632<=D&&D<=9633||9635<=D&&D<=9641||9650<=D&&D<=9651||9654<=D&&D<=9655||9660<=D&&D<=9661||9664<=D&&D<=9665||9670<=D&&D<=9672||D==9675||9678<=D&&D<=9681||9698<=D&&D<=9701||D==9711||9733<=D&&D<=9734||D==9737||9742<=D&&D<=9743||9748<=D&&D<=9749||D==9756||D==9758||D==9792||D==9794||9824<=D&&D<=9825||9827<=D&&D<=9829||9831<=D&&D<=9834||9836<=D&&D<=9837||D==9839||9886<=D&&D<=9887||9918<=D&&D<=9919||9924<=D&&D<=9933||9935<=D&&D<=9953||D==9955||9960<=D&&D<=9983||D==10045||D==10071||10102<=D&&D<=10111||11093<=D&&D<=11097||12872<=D&&D<=12879||57344<=D&&D<=63743||65024<=D&&D<=65039||D==65533||127232<=D&&D<=127242||127248<=D&&D<=127277||127280<=D&&D<=127337||127344<=D&&D<=127386||917760<=D&&D<=917999||983040<=D&&D<=1048573||1048576<=D&&D<=1114109?"A":"N"},u.characterLength=function(e){var s=this.eastAsianWidth(e);return s=="F"||s=="W"||s=="A"?2:1};function F(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}u.length=function(e){for(var s=F(e),C=0,D=0;D=s-(o==2?1:0))if(i+o<=C)D+=h;else break;i+=o}return D}})(M);var J=M.exports;const Q=j(J);var X=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};const DD=j(X);function A(t,u={}){if(typeof t!="string"||t.length===0||(u={ambiguousIsNarrow:!0,...u},t=S(t),t.length===0))return 0;t=t.replace(DD()," ");const F=u.ambiguousIsNarrow?1:2;let e=0;for(const s of t){const C=s.codePointAt(0);if(C<=31||C>=127&&C<=159||C>=768&&C<=879)continue;switch(Q.eastAsianWidth(s)){case"F":case"W":e+=2;break;case"A":e+=F;break;default:e+=1}}return e}const d=10,P=(t=0)=>u=>`\x1B[${u+t}m`,T=(t=0)=>u=>`\x1B[${38+t};5;${u}m`,O=(t=0)=>(u,F,e)=>`\x1B[${38+t};2;${u};${F};${e}m`,r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r.modifier);const uD=Object.keys(r.color),FD=Object.keys(r.bgColor);[...uD,...FD];function tD(){const t=new Map;for(const[u,F]of Object.entries(r)){for(const[e,s]of Object.entries(F))r[e]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},F[e]=r[e],t.set(s[0],s[1]);Object.defineProperty(r,u,{value:F,enumerable:!1})}return Object.defineProperty(r,"codes",{value:t,enumerable:!1}),r.color.close="\x1B[39m",r.bgColor.close="\x1B[49m",r.color.ansi=P(),r.color.ansi256=T(),r.color.ansi16m=O(),r.bgColor.ansi=P(d),r.bgColor.ansi256=T(d),r.bgColor.ansi16m=O(d),Object.defineProperties(r,{rgbToAnsi256:{value:(u,F,e)=>u===F&&F===e?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(e/255*5),enumerable:!1},hexToRgb:{value:u=>{const F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[e]=F;e.length===3&&(e=[...e].map(C=>C+C).join(""));const s=Number.parseInt(e,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:u=>r.rgbToAnsi256(...r.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value:u=>{if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,e,s;if(u>=232)F=((u-232)*10+8)/255,e=F,s=F;else{u-=16;const i=u%36;F=Math.floor(u/36)/5,e=Math.floor(i/6)/5,s=i%6/5}const C=Math.max(F,e,s)*2;if(C===0)return 30;let D=30+(Math.round(s)<<2|Math.round(e)<<1|Math.round(F));return C===2&&(D+=60),D},enumerable:!1},rgbToAnsi:{value:(u,F,e)=>r.ansi256ToAnsi(r.rgbToAnsi256(u,F,e)),enumerable:!1},hexToAnsi:{value:u=>r.ansi256ToAnsi(r.hexToAnsi256(u)),enumerable:!1}}),r}const eD=tD(),g=new Set(["\x1B","\x9B"]),sD=39,b="\x07",W="[",CD="]",I="m",w=`${CD}8;;`,N=t=>`${g.values().next().value}${W}${t}${I}`,L=t=>`${g.values().next().value}${w}${t}${b}`,iD=t=>t.split(" ").map(u=>A(u)),y=(t,u,F)=>{const e=[...u];let s=!1,C=!1,D=A(S(t[t.length-1]));for(const[i,n]of e.entries()){const E=A(n);if(D+E<=F?t[t.length-1]+=n:(t.push(n),D=0),g.has(n)&&(s=!0,C=e.slice(i+1).join("").startsWith(w)),s){C?n===b&&(s=!1,C=!1):n===I&&(s=!1);continue}D+=E,D===F&&i0&&t.length>1&&(t[t.length-2]+=t.pop())},rD=t=>{const u=t.split(" ");let F=u.length;for(;F>0&&!(A(u[F-1])>0);)F--;return F===u.length?t:u.slice(0,F).join(" ")+u.slice(F).join("")},ED=(t,u,F={})=>{if(F.trim!==!1&&t.trim()==="")return"";let e="",s,C;const D=iD(t);let i=[""];for(const[E,h]of t.split(" ").entries()){F.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let o=A(i[i.length-1]);if(E!==0&&(o>=u&&(F.wordWrap===!1||F.trim===!1)&&(i.push(""),o=0),(o>0||F.trim===!1)&&(i[i.length-1]+=" ",o++)),F.hard&&D[E]>u){const B=u-o,p=1+Math.floor((D[E]-B-1)/u);Math.floor((D[E]-1)/u)u&&o>0&&D[E]>0){if(F.wordWrap===!1&&ou&&F.wordWrap===!1){y(i,h,u);continue}i[i.length-1]+=h}F.trim!==!1&&(i=i.map(E=>rD(E)));const n=[...i.join(` ++`)];for(const[E,h]of n.entries()){if(e+=h,g.has(h)){const{groups:B}=new RegExp(`(?:\\${W}(?\\d+)m|\\${w}(?.*)${b})`).exec(n.slice(E).join(""))||{groups:{}};if(B.code!==void 0){const p=Number.parseFloat(B.code);s=p===sD?void 0:p}else B.uri!==void 0&&(C=B.uri.length===0?void 0:B.uri)}const o=eD.codes.get(Number(s));n[E+1]===` ++`?(C&&(e+=L("")),s&&o&&(e+=N(o))):h===` ++`&&(s&&o&&(e+=N(s)),C&&(e+=L(C)))}return e};function R(t,u,F){return String(t).normalize().replace(/\r\n/g,` + `).split(` +-`).map(e=>uD(e,u,F)).join(` +-`)}function FD(t,u){if(t===u)return;const F=t.split(` ++`).map(e=>ED(e,u,F)).join(` ++`)}var oD=Object.defineProperty,nD=(t,u,F)=>u in t?oD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,a=(t,u,F)=>(nD(t,typeof u!="symbol"?u+"":u,F),F);function aD(t,u){if(t===u)return;const F=t.split(` + `),e=u.split(` +-`),s=[];for(let C=0;C{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),s()},this.input.pipe(u),this.rl=S.createInterface({input:this.input,output:u,tabSize:2,prompt:"",escapeCodeTimeout:50}),S.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),g(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((F,e)=>{this.once("submit",()=>{this.output.write(x.show),this.output.off("resize",this.render),g(this.input,!1),F(this.value)}),this.once("cancel",()=>{this.output.write(x.show),this.output.off("resize",this.render),g(this.input,!1),F(R)})})}on(u,F){const e=this.subscribers.get(u)??[];e.push({cb:F}),this.subscribers.set(u,e)}once(u,F){const e=this.subscribers.get(u)??[];e.push({cb:F,once:!0}),this.subscribers.set(u,e)}emit(u,...F){const e=this.subscribers.get(u)??[],s=[];for(const C of e)C.cb(...F),C.once&&s.push(()=>e.splice(e.indexOf(C),1));for(const C of s)C()}unsubscribe(){this.subscribers.clear()}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&!this._track&&V.has(F.name)&&this.emit("cursor",V.get(F.name)),F?.name&&tD.has(F.name)&&this.emit("cursor",F.name),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}u===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` +-`),g(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const u=P(this._prevFrame,process.stdout.columns,{hard:!0}).split(` +-`).length-1;this.output.write(x.move(-999,u*-1))}render(){const u=P(this._render(this)??"",process.stdout.columns,{hard:!0});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(x.hide);else{const F=FD(this._prevFrame,u);if(this.restoreCursor(),F&&F?.length===1){const e=F[0];this.output.write(x.move(0,e)),this.output.write(d.lines(1));const s=u.split(` +-`);this.output.write(s[e]),this._prevFrame=u,this.output.write(x.move(0,s.length-e-1));return}else if(F&&F?.length>1){const e=F[0];this.output.write(x.move(0,e)),this.output.write(d.down());const C=u.split(` +-`).slice(e);this.output.write(C.join(` +-`)),this._prevFrame=u;return}this.output.write(d.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}class sD extends h{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",F=>{this.output.write(x.move(0,-1)),this.value=F,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class CD extends h{constructor(u){super(u,!1),this.cursor=0;const{options:F}=u;this.options=Object.entries(F).flatMap(([e,s])=>[{value:e,group:!0,label:e},...s.map(C=>({...C,group:e}))]),this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===u.cursorAt),0),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(u){return this.options.filter(F=>F.group===u)}isGroupSelected(u){return this.getGroupItems(u).every(e=>this.value.includes(e.value))}toggleValue(){const u=this.options[this.cursor];if(u.group===!0){const F=u.value,e=this.getGroupItems(F);this.isGroupSelected(F)?this.value=this.value.filter(s=>e.findIndex(C=>C.value===s)===-1):this.value=[...this.value,...e.map(s=>s.value)],this.value=Array.from(new Set(this.value))}else{const F=this.value.includes(u.value);this.value=F?this.value.filter(e=>e!==u.value):[...this.value,u.value]}}}class iD extends h{constructor(u){super(u,!1),this.cursor=0,this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===u.cursorAt),0),this.on("key",F=>{F==="a"&&this.toggleAll()}),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(F=>F.value)}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(F=>F!==this._value):[...this.value,this._value]}}class rD extends h{constructor({mask:u,...F}){super(F),this.valueWithCursor="",this._mask="\u2022",this._mask=u??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${l.inverse(l.hidden("_"))}`;else{const e=this.masked.slice(0,this.cursor),s=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${l.inverse(s[0])}${s.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}class ED extends h{constructor(u){super(u,!1),this.cursor=0,this.options=u.options,this.cursor=this.options.findIndex(({value:F})=>F===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}class nD extends h{constructor(u){super(u,!1),this.cursor=0,this.options=u.options;const F=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(F.indexOf(u.initialValue),0),this.on("key",e=>{if(!F.includes(e))return;const s=this.options.find(({value:[C]})=>C?.toLowerCase()===e);s&&(this.value=s.value,this.state="submit",this.emit("submit"))})}}class oD extends h{constructor(u){super(u),this.valueWithCursor="",this.on("finalize",()=>{this.value||(this.value=u.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${l.inverse(l.hidden("_"))}`;else{const F=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${F}${l.inverse(e[0])}${e.slice(1)}`}})}get cursor(){return this._cursor}}function aD({input:t=k,output:u=y,overwrite:F=!0,hideCursor:e=!0}={}){const s=f.createInterface({input:t,output:u,prompt:"",tabSize:1});f.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);const C=(D,{name:i})=>{if(String(D)===""&&process.exit(0),!F)return;let E=i==="return"?0:-1,a=i==="return"?-1:0;f.moveCursor(u,E,a,()=>{f.clearLine(u,1,()=>{t.once("keypress",C)})})};return e&&process.stdout.write(x.hide),t.once("keypress",C),()=>{t.off("keypress",C),e&&process.stdout.write(x.show),t.isTTY&&t.setRawMode(!1),s.terminal=!1,s.close()}}export{sD as ConfirmPrompt,CD as GroupMultiSelectPrompt,iD as MultiSelectPrompt,rD as PasswordPrompt,h as Prompt,nD as SelectKeyPrompt,ED as SelectPrompt,oD as TextPrompt,aD as block,eD as isCancel}; ++`),s=[];for(let C=0;C{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),s()},this.input.pipe(u),this.rl=_.createInterface({input:this.input,output:u,tabSize:2,prompt:"",escapeCodeTimeout:50}),_.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),v(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((F,e)=>{this.once("submit",()=>{this.output.write(l.show),this.output.off("resize",this.render),v(this.input,!1),F(this.value)}),this.once("cancel",()=>{this.output.write(l.show),this.output.off("resize",this.render),v(this.input,!1),F(V)})})}on(u,F){const e=this.subscribers.get(u)??[];e.push({cb:F}),this.subscribers.set(u,e)}once(u,F){const e=this.subscribers.get(u)??[];e.push({cb:F,once:!0}),this.subscribers.set(u,e)}emit(u,...F){const e=this.subscribers.get(u)??[],s=[];for(const C of e)C.cb(...F),C.once&&s.push(()=>e.splice(e.indexOf(C),1));for(const C of s)C()}unsubscribe(){this.subscribers.clear()}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&!this._track&&z.has(F.name)&&this.emit("cursor",z.get(F.name)),F?.name&&lD.has(F.name)&&this.emit("cursor",F.name),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u===" "&&this.opts.autocomplete){const e=this.opts.autocomplete(this.value);e&&(this.rl.write(e),this.emit("value",e))}if(u===" "&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}u===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` ++`),v(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const u=R(this._prevFrame,process.stdout.columns,{hard:!0}).split(` ++`).length-1;this.output.write(l.move(-999,u*-1))}render(){const u=R(this._render(this)??"",process.stdout.columns,{hard:!0});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(l.hide);else{const F=aD(this._prevFrame,u);if(this.restoreCursor(),F&&F?.length===1){const e=F[0];this.output.write(l.move(0,e)),this.output.write(m.lines(1));const s=u.split(` ++`);this.output.write(s[e]),this._prevFrame=u,this.output.write(l.move(0,s.length-e-1));return}else if(F&&F?.length>1){const e=F[0];this.output.write(l.move(0,e)),this.output.write(m.down());const s=u.split(` ++`).slice(e);this.output.write(s.join(` ++`)),this._prevFrame=u;return}this.output.write(m.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}class xD extends x{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",F=>{this.output.write(l.move(0,-1)),this.value=F,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var BD=Object.defineProperty,cD=(t,u,F)=>u in t?BD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,G=(t,u,F)=>(cD(t,typeof u!="symbol"?u+"":u,F),F);class AD extends x{constructor(u){super(u,!1),G(this,"options"),G(this,"cursor",0);const{options:F}=u;this.options=Object.entries(F).flatMap(([e,s])=>[{value:e,group:!0,label:e},...s.map(C=>({...C,group:e}))]),this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===u.cursorAt),0),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(u){return this.options.filter(F=>F.group===u)}isGroupSelected(u){return this.getGroupItems(u).every(F=>this.value.includes(F.value))}toggleValue(){const u=this.options[this.cursor];if(u.group===!0){const F=u.value,e=this.getGroupItems(F);this.isGroupSelected(F)?this.value=this.value.filter(s=>e.findIndex(C=>C.value===s)===-1):this.value=[...this.value,...e.map(s=>s.value)],this.value=Array.from(new Set(this.value))}else{const F=this.value.includes(u.value);this.value=F?this.value.filter(e=>e!==u.value):[...this.value,u.value]}}}var pD=Object.defineProperty,fD=(t,u,F)=>u in t?pD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,K=(t,u,F)=>(fD(t,typeof u!="symbol"?u+"":u,F),F);let gD=class extends x{constructor(u){super(u,!1),K(this,"options"),K(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===u.cursorAt),0),this.on("key",F=>{F==="a"&&this.toggleAll()}),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(F=>F.value)}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(F=>F!==this._value):[...this.value,this._value]}};var vD=Object.defineProperty,mD=(t,u,F)=>u in t?vD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,Y=(t,u,F)=>(mD(t,typeof u!="symbol"?u+"":u,F),F);class dD extends x{constructor({mask:u,...F}){super(F),Y(this,"valueWithCursor",""),Y(this,"_mask","\u2022"),this._mask=u??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${c.inverse(c.hidden("_"))}`;else{const e=this.masked.slice(0,this.cursor),s=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${c.inverse(s[0])}${s.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}var bD=Object.defineProperty,wD=(t,u,F)=>u in t?bD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,Z=(t,u,F)=>(wD(t,typeof u!="symbol"?u+"":u,F),F);let yD=class extends x{constructor(u){super(u,!1),Z(this,"options"),Z(this,"cursor",0),this.options=u.options,this.cursor=this.options.findIndex(({value:F})=>F===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var $D=Object.defineProperty,kD=(t,u,F)=>u in t?$D(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,H=(t,u,F)=>(kD(t,typeof u!="symbol"?u+"":u,F),F);class _D extends x{constructor(u){super(u,!1),H(this,"options"),H(this,"cursor",0),this.options=u.options;const F=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(F.indexOf(u.initialValue),0),this.on("key",e=>{if(!F.includes(e))return;const s=this.options.find(({value:[C]})=>C?.toLowerCase()===e);s&&(this.value=s.value,this.state="submit",this.emit("submit"))})}}var SD=Object.defineProperty,jD=(t,u,F)=>u in t?SD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,MD=(t,u,F)=>(jD(t,typeof u!="symbol"?u+"":u,F),F);class PD extends x{constructor(u){super(u),MD(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=u.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${c.inverse(c.hidden("_"))}`;else{const F=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${F}${c.inverse(e[0])}${e.slice(1)}`}})}get cursor(){return this._cursor}}function TD({input:t=$,output:u=k,overwrite:F=!0,hideCursor:e=!0}={}){const s=f.createInterface({input:t,output:u,prompt:"",tabSize:1});f.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);const C=(D,{name:i})=>{if(String(D)===""&&process.exit(0),!F)return;let n=i==="return"?0:-1,E=i==="return"?-1:0;f.moveCursor(u,n,E,()=>{f.clearLine(u,1,()=>{t.once("keypress",C)})})};return e&&process.stdout.write(l.hide),t.once("keypress",C),()=>{t.off("keypress",C),e&&process.stdout.write(l.show),s.terminal=!1,s.close()}}export{xD as ConfirmPrompt,AD as GroupMultiSelectPrompt,gD as MultiSelectPrompt,dD as PasswordPrompt,x as Prompt,_D as SelectKeyPrompt,yD as SelectPrompt,PD as TextPrompt,TD as block,hD as isCancel}; ++//# sourceMappingURL=index.mjs.map diff --git a/patches/@clack__prompts@0.7.0.patch b/patches/@clack__prompts@0.7.0.patch new file mode 100644 index 00000000..a6ef0459 --- /dev/null +++ b/patches/@clack__prompts@0.7.0.patch @@ -0,0 +1,367 @@ +diff --git a/dist/index.cjs b/dist/index.cjs +index 84256fcf4d4e0f84f398779edfdca2be11d10918..799e582560eae9e65c6eae98c514f723f27eab03 100644 +--- a/dist/index.cjs ++++ b/dist/index.cjs +@@ -1,77 +1,78 @@ +-"use strict";const core=require("@clack/core"),process$1=require("node:process"),color=require("picocolors"),sisteransi=require("sisteransi");function isUnicodeSupported(){return process$1.platform!=="win32"?process$1.env.TERM!=="linux":Boolean(process$1.env.CI)||Boolean(process$1.env.WT_SESSION)||Boolean(process$1.env.TERMINUS_SUBLIME)||process$1.env.ConEmuTask==="{cmd::Cmder}"||process$1.env.TERM_PROGRAM==="Terminus-Sublime"||process$1.env.TERM_PROGRAM==="vscode"||process$1.env.TERM==="xterm-256color"||process$1.env.TERM==="alacritty"||process$1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const unicode=isUnicodeSupported(),s=(t,n)=>unicode?t:n,S_STEP_ACTIVE=s("\u25C6","*"),S_STEP_CANCEL=s("\u25A0","x"),S_STEP_ERROR=s("\u25B2","x"),S_STEP_SUBMIT=s("\u25C7","o"),S_BAR_START=s("\u250C","T"),S_BAR=s("\u2502","|"),S_BAR_END=s("\u2514","\u2014"),S_RADIO_ACTIVE=s("\u25CF",">"),S_RADIO_INACTIVE=s("\u25CB"," "),S_CHECKBOX_ACTIVE=s("\u25FB","[\u2022]"),S_CHECKBOX_SELECTED=s("\u25FC","[+]"),S_CHECKBOX_INACTIVE=s("\u25FB","[ ]"),S_PASSWORD_MASK=s("\u25AA","\u2022"),S_BAR_H=s("\u2500","-"),S_CORNER_TOP_RIGHT=s("\u256E","+"),S_CONNECT_LEFT=s("\u251C","+"),S_CORNER_BOTTOM_RIGHT=s("\u256F","+"),S_INFO=s("\u25CF","\u2022"),S_SUCCESS=s("\u25C6","*"),S_WARN=s("\u25B2","!"),S_ERROR=s("\u25A0","x"),symbol=t=>{switch(t){case"initial":case"active":return color.cyan(S_STEP_ACTIVE);case"cancel":return color.red(S_STEP_CANCEL);case"error":return color.yellow(S_STEP_ERROR);case"submit":return color.green(S_STEP_SUBMIT)}},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`,i=t.placeholder?color.inverse(t.placeholder[0])+color.dim(t.placeholder.slice(1)):color.inverse(color.hidden("_")),e=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()} +-${color.yellow(S_BAR)} ${e} +-${color.yellow(S_BAR_END)} ${color.yellow(this.error)} +-`;case"submit":return`${n}${color.gray(S_BAR)} ${color.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${color.gray(S_BAR)} ${color.strikethrough(color.dim(this.value??""))}${this.value?.trim()?` +-`+color.gray(S_BAR):""}`;default:return`${n}${color.cyan(S_BAR)} ${e} +-${color.cyan(S_BAR_END)} +-`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??S_PASSWORD_MASK,render(){const n=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`,i=this.valueWithCursor,e=this.masked;switch(this.state){case"error":return`${n.trim()} +-${color.yellow(S_BAR)} ${e} +-${color.yellow(S_BAR_END)} ${color.yellow(this.error)} +-`;case"submit":return`${n}${color.gray(S_BAR)} ${color.dim(e)}`;case"cancel":return`${n}${color.gray(S_BAR)} ${color.strikethrough(color.dim(e??""))}${e?` +-`+color.gray(S_BAR):""}`;default:return`${n}${color.cyan(S_BAR)} ${i} +-${color.cyan(S_BAR_END)} +-`}}}).prompt(),confirm=t=>{const n=t.active??"Yes",i=t.inactive??"No";return new core.ConfirmPrompt({active:n,inactive:i,initialValue:t.initialValue??!0,render(){const e=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`,r=this.value?n:i;switch(this.state){case"submit":return`${e}${color.gray(S_BAR)} ${color.dim(r)}`;case"cancel":return`${e}${color.gray(S_BAR)} ${color.strikethrough(color.dim(r))} +-${color.gray(S_BAR)}`;default:return`${e}${color.cyan(S_BAR)} ${this.value?`${color.green(S_RADIO_ACTIVE)} ${n}`:`${color.dim(S_RADIO_INACTIVE)} ${color.dim(n)}`} ${color.dim("/")} ${this.value?`${color.dim(S_RADIO_INACTIVE)} ${color.dim(i)}`:`${color.green(S_RADIO_ACTIVE)} ${i}`} +-${color.cyan(S_BAR_END)} +-`}}}).prompt()},select=t=>{const n=(e,r)=>{const c=e.label??String(e.value);return r==="active"?`${color.green(S_RADIO_ACTIVE)} ${c} ${e.hint?color.dim(`(${e.hint})`):""}`:r==="selected"?`${color.dim(c)}`:r==="cancelled"?`${color.strikethrough(color.dim(c))}`:`${color.dim(S_RADIO_INACTIVE)} ${color.dim(c)}`};let i=0;return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const e=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`;switch(this.state){case"submit":return`${e}${color.gray(S_BAR)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${e}${color.gray(S_BAR)} ${n(this.options[this.cursor],"cancelled")} +-${color.gray(S_BAR)}`;default:{const r=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+r-3?i=Math.max(Math.min(this.cursor-r+3,this.options.length-r),0):this.cursor0,a=ro===0&&c||o===u.length-1&&a?color.dim("..."):n(l,o+i===this.cursor?"active":"inactive")).join(` +-${color.cyan(S_BAR)} `)} +-${color.cyan(S_BAR_END)} +-`}}}}).prompt()},selectKey=t=>{const n=(i,e="inactive")=>{const r=i.label??String(i.value);return e==="selected"?`${color.dim(r)}`:e==="cancelled"?`${color.strikethrough(color.dim(r))}`:e==="active"?`${color.bgCyan(color.gray(` ${i.value} `))} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:`${color.gray(color.bgWhite(color.inverse(` ${i.value} `)))} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const i=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${n(this.options.find(e=>e.value===this.value),"selected")}`;case"cancel":return`${i}${color.gray(S_BAR)} ${n(this.options[0],"cancelled")} +-${color.gray(S_BAR)}`;default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r)=>n(e,r===this.cursor?"active":"inactive")).join(` +-${color.cyan(S_BAR)} `)} +-${color.cyan(S_BAR_END)} +-`}}}).prompt()},multiselect=t=>{const n=(i,e)=>{const r=i.label??String(i.value);return e==="active"?`${color.cyan(S_CHECKBOX_ACTIVE)} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="selected"?`${color.green(S_CHECKBOX_SELECTED)} ${color.dim(r)}`:e==="cancelled"?`${color.strikethrough(color.dim(r))}`:e==="active-selected"?`${color.green(S_CHECKBOX_SELECTED)} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="submitted"?`${color.dim(r)}`:`${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(r)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. +-${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`},render(){let i=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,"submitted")).join(color.dim(", "))||color.dim("none")}`;case"cancel":{const e=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(color.dim(", "));return`${i}${color.gray(S_BAR)} ${e.trim()?`${e} +-${color.gray(S_BAR)}`:""}`}case"error":{const e=this.error.split(` +-`).map((r,c)=>c===0?`${color.yellow(S_BAR_END)} ${color.yellow(r)}`:` ${r}`).join(` +-`);return i+color.yellow(S_BAR)+" "+this.options.map((r,c)=>{const a=this.value.includes(r.value),l=c===this.cursor;return l&&a?n(r,"active-selected"):a?n(r,"selected"):n(r,l?"active":"inactive")}).join(` +-${color.yellow(S_BAR)} `)+` +-`+e+` +-`}default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r)=>{const c=this.value.includes(e.value),a=r===this.cursor;return a&&c?n(e,"active-selected"):c?n(e,"selected"):n(e,a?"active":"inactive")}).join(` +-${color.cyan(S_BAR)} `)} +-${color.cyan(S_BAR_END)} +-`}}}).prompt()},groupMultiselect=t=>{const n=(i,e,r=[])=>{const c=i.label??String(i.value),a=typeof i.group=="string",l=a&&(r[r.indexOf(i)+1]??{group:!0}),o=a&&l.group===!0,u=a?`${o?S_BAR_END:S_BAR} `:"";return e==="active"?`${color.dim(u)}${color.cyan(S_CHECKBOX_ACTIVE)} ${c} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="group-active"?`${u}${color.cyan(S_CHECKBOX_ACTIVE)} ${color.dim(c)}`:e==="group-active-selected"?`${u}${color.green(S_CHECKBOX_SELECTED)} ${color.dim(c)}`:e==="selected"?`${color.dim(u)}${color.green(S_CHECKBOX_SELECTED)} ${color.dim(c)}`:e==="cancelled"?`${color.strikethrough(color.dim(c))}`:e==="active-selected"?`${color.dim(u)}${color.green(S_CHECKBOX_SELECTED)} ${c} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="submitted"?`${color.dim(c)}`:`${color.dim(u)}${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(c)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. +-${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`},render(){let i=`${color.gray(S_BAR)} +-${symbol(this.state)} ${t.message} +-`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,"submitted")).join(color.dim(", "))}`;case"cancel":{const e=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(color.dim(", "));return`${i}${color.gray(S_BAR)} ${e.trim()?`${e} +-${color.gray(S_BAR)}`:""}`}case"error":{const e=this.error.split(` +-`).map((r,c)=>c===0?`${color.yellow(S_BAR_END)} ${color.yellow(r)}`:` ${r}`).join(` +-`);return`${i}${color.yellow(S_BAR)} ${this.options.map((r,c,a)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),o=c===this.cursor;return!o&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,l?"group-active-selected":"group-active",a):o&&l?n(r,"active-selected",a):l?n(r,"selected",a):n(r,o?"active":"inactive",a)}).join(` +-${color.yellow(S_BAR)} `)} +-${e} +-`}default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r,c)=>{const a=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),l=r===this.cursor;return!l&&typeof e.group=="string"&&this.options[this.cursor].value===e.group?n(e,a?"group-active-selected":"group-active",c):l&&a?n(e,"active-selected",c):a?n(e,"selected",c):n(e,l?"active":"inactive",c)}).join(` +-${color.cyan(S_BAR)} `)} +-${color.cyan(S_BAR_END)} +-`}}}).prompt()},strip=t=>t.replace(ansiRegex(),""),note=(t="",n="")=>{const i=` ++"use strict";const core=require("@clack/core"),process$1=require("node:process"),e=require("picocolors"),sisteransi=require("sisteransi");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const process__default=_interopDefaultCompat(process$1),e__default=_interopDefaultCompat(e);function isUnicodeSupported(){return process__default.platform!=="win32"?process__default.env.TERM!=="linux":!!process__default.env.CI||!!process__default.env.WT_SESSION||!!process__default.env.TERMINUS_SUBLIME||process__default.env.ConEmuTask==="{cmd::Cmder}"||process__default.env.TERM_PROGRAM==="Terminus-Sublime"||process__default.env.TERM_PROGRAM==="vscode"||process__default.env.TERM==="xterm-256color"||process__default.env.TERM==="alacritty"||process__default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var u$1=Object.defineProperty,i=(t,c,r)=>c in t?u$1(t,c,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[c]=r,n=(t,c,r)=>(i(t,typeof c!="symbol"?c+"":c,r),r);class Concurrency{constructor(c){n(this,"concurrency"),n(this,"count"),n(this,"queue"),this.concurrency=c.concurrency,this.count=0,this.queue=new Set}add(c){return this.count{const o=()=>r(this.run(c));this.queue.add(o)})}flush(){for(const c of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(c),c()}}run(c){this.count++;const r=c(),o=()=>{this.count--,this.flush()};return r.then(o,o),r}}const S=isUnicodeSupported(),u=(t,c)=>S?t:c,U=u("\u25C6","*"),R=u("\u25A0","x"),E=u("\u25B2","x"),b=u("\u25C7","o"),X=u("\u250C","T"),a=u("\u2502","|"),m=u("\u2514","\u2014"),V=u("\u25CF",">"),P=u("\u25CB"," "),T=u("\u25FB","[\u2022]"),v=u("\u25FC","[+]"),C=u("\u25FB","[ ]"),F=u("\u25AA","\u2022"),k=u("\u2500","-"),J=u("\u256E","+"),Y=u("\u251C","+"),Q=u("\u256F","+"),ee=u("\u25CF","\u2022"),te=u("\u25C6","*"),re=u("\u25B2","!"),se=u("\u25A0","x"),h=t=>{switch(t){case"initial":case"active":return e__default.cyan(U);case"cancel":return e__default.red(R);case"error":return e__default.yellow(E);case"submit":return e__default.green(b)}},O=t=>{const{cursor:c,options:r,style:o}=t,s=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);let l=0;c>=l+s-3?l=Math.max(Math.min(c-s+3,r.length-s),0):c0,d=s{const I=g===0&&$,x=g===M.length-1&&d;return I||x?e__default.dim("..."):o(p,g+l===c)})},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const c=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`,r=t.placeholder?e__default.inverse(t.placeholder[0])+e__default.dim(t.placeholder.slice(1)):e__default.inverse(e__default.hidden("_")),o=this.value?this.valueWithCursor:r;switch(this.state){case"error":return`${c.trim()} ++${e__default.yellow(a)} ${o} ++${e__default.yellow(m)} ${e__default.yellow(this.error)} ++`;case"submit":return`${c}${e__default.gray(a)} ${e__default.dim(this.value||t.placeholder)}`;case"cancel":return`${c}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(this.value??""))}${this.value?.trim()?` ++`+e__default.gray(a):""}`;default:return`${c}${e__default.cyan(a)} ${o} ++${e__default.cyan(m)} ++`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??F,render(){const c=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`,r=this.valueWithCursor,o=this.masked;switch(this.state){case"error":return`${c.trim()} ++${e__default.yellow(a)} ${o} ++${e__default.yellow(m)} ${e__default.yellow(this.error)} ++`;case"submit":return`${c}${e__default.gray(a)} ${e__default.dim(o)}`;case"cancel":return`${c}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(o??""))}${o?` ++`+e__default.gray(a):""}`;default:return`${c}${e__default.cyan(a)} ${r} ++${e__default.cyan(m)} ++`}}}).prompt(),confirm=t=>{const c=t.active??"Yes",r=t.inactive??"No";return new core.ConfirmPrompt({active:c,inactive:r,initialValue:t.initialValue??!0,render(){const o=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`,s=this.value?c:r;switch(this.state){case"submit":return`${o}${e__default.gray(a)} ${e__default.dim(s)}`;case"cancel":return`${o}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(s))} ++${e__default.gray(a)}`;default:return`${o}${e__default.cyan(a)} ${this.value?`${e__default.green(V)} ${c}`:`${e__default.dim(P)} ${e__default.dim(c)}`} ${e__default.dim("/")} ${this.value?`${e__default.dim(P)} ${e__default.dim(r)}`:`${e__default.green(V)} ${r}`} ++${e__default.cyan(m)} ++`}}}).prompt()},select=t=>{const c=(r,o)=>{const s=r.label??String(r.value);switch(o){case"selected":return`${e__default.dim(s)}`;case"active":return`${e__default.green(V)} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`;case"cancelled":return`${e__default.strikethrough(e__default.dim(s))}`;default:return`${e__default.dim(P)} ${e__default.dim(s)}`}};return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const r=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`;switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${c(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${e__default.gray(a)} ${c(this.options[this.cursor],"cancelled")} ++${e__default.gray(a)}`;default:return`${r}${e__default.cyan(a)} ${O({cursor:this.cursor,options:this.options,maxItems:t.maxItems,style:(o,s)=>c(o,s?"active":"inactive")}).join(` ++${e__default.cyan(a)} `)} ++${e__default.cyan(m)} ++`}}}).prompt()},selectKey=t=>{const c=(r,o="inactive")=>{const s=r.label??String(r.value);return o==="selected"?`${e__default.dim(s)}`:o==="cancelled"?`${e__default.strikethrough(e__default.dim(s))}`:o==="active"?`${e__default.bgCyan(e__default.gray(` ${r.value} `))} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`:`${e__default.gray(e__default.bgWhite(e__default.inverse(` ${r.value} `)))} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const r=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`;switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${c(this.options.find(o=>o.value===this.value),"selected")}`;case"cancel":return`${r}${e__default.gray(a)} ${c(this.options[0],"cancelled")} ++${e__default.gray(a)}`;default:return`${r}${e__default.cyan(a)} ${this.options.map((o,s)=>c(o,s===this.cursor?"active":"inactive")).join(` ++${e__default.cyan(a)} `)} ++${e__default.cyan(m)} ++`}}}).prompt()},multiselect=t=>{const c=(r,o)=>{const s=r.label??String(r.value);return o==="active"?`${e__default.cyan(T)} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="selected"?`${e__default.green(v)} ${e__default.dim(s)}`:o==="cancelled"?`${e__default.strikethrough(e__default.dim(s))}`:o==="active-selected"?`${e__default.green(v)} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="submitted"?`${e__default.dim(s)}`:`${e__default.dim(C)} ${e__default.dim(s)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option. ++${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){let r=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`;const o=(s,l)=>{const $=this.value.includes(s.value);return l&&$?c(s,"active-selected"):$?c(s,"selected"):c(s,l?"active":"inactive")};switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>c(s,"submitted")).join(e__default.dim(", "))||e__default.dim("none")}`;case"cancel":{const s=this.options.filter(({value:l})=>this.value.includes(l)).map(l=>c(l,"cancelled")).join(e__default.dim(", "));return`${r}${e__default.gray(a)} ${s.trim()?`${s} ++${e__default.gray(a)}`:""}`}case"error":{const s=this.error.split(` ++`).map((l,$)=>$===0?`${e__default.yellow(m)} ${e__default.yellow(l)}`:` ${l}`).join(` ++`);return r+e__default.yellow(a)+" "+O({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(` ++${e__default.yellow(a)} `)+` ++`+s+` ++`}default:return`${r}${e__default.cyan(a)} ${O({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(` ++${e__default.cyan(a)} `)} ++${e__default.cyan(m)} ++`}}}).prompt()},groupMultiselect=t=>{const c=(r,o,s=[])=>{const l=r.label??String(r.value),$=typeof r.group=="string",d=$&&(s[s.indexOf(r)+1]??{group:!0}),p=$&&d.group===!0,g=$?`${p?m:a} `:"";return o==="active"?`${e__default.dim(g)}${e__default.cyan(T)} ${l} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="group-active"?`${g}${e__default.cyan(T)} ${e__default.dim(l)}`:o==="group-active-selected"?`${g}${e__default.green(v)} ${e__default.dim(l)}`:o==="selected"?`${e__default.dim(g)}${e__default.green(v)} ${e__default.dim(l)}`:o==="cancelled"?`${e__default.strikethrough(e__default.dim(l))}`:o==="active-selected"?`${e__default.dim(g)}${e__default.green(v)} ${l} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="submitted"?`${e__default.dim(l)}`:`${e__default.dim(g)}${e__default.dim(C)} ${e__default.dim(l)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option. ++${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){let r=`${e__default.gray(a)} ++${h(this.state)} ${t.message} ++`;switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${this.options.filter(({value:o})=>this.value.includes(o)).map(o=>c(o,"submitted")).join(e__default.dim(", "))}`;case"cancel":{const o=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>c(s,"cancelled")).join(e__default.dim(", "));return`${r}${e__default.gray(a)} ${o.trim()?`${o} ++${e__default.gray(a)}`:""}`}case"error":{const o=this.error.split(` ++`).map((s,l)=>l===0?`${e__default.yellow(m)} ${e__default.yellow(s)}`:` ${s}`).join(` ++`);return`${r}${e__default.yellow(a)} ${this.options.map((s,l,$)=>{const d=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),p=l===this.cursor;return!p&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?c(s,d?"group-active-selected":"group-active",$):p&&d?c(s,"active-selected",$):d?c(s,"selected",$):c(s,p?"active":"inactive",$)}).join(` ++${e__default.yellow(a)} `)} ++${o} ++`}default:return`${r}${e__default.cyan(a)} ${this.options.map((o,s,l)=>{const $=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),d=s===this.cursor;return!d&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?c(o,$?"group-active-selected":"group-active",l):d&&$?c(o,"active-selected",l):$?c(o,"selected",l):c(o,d?"active":"inactive",l)}).join(` ++${e__default.cyan(a)} `)} ++${e__default.cyan(m)} ++`}}}).prompt()},_=t=>t.replace(ne(),""),note=(t="",c="")=>{const r=` + ${t} + `.split(` +-`),e=strip(n).length,r=Math.max(i.reduce((a,l)=>(l=strip(l),l.length>a?l.length:a),0),e)+2,c=i.map(a=>`${color.gray(S_BAR)} ${color.dim(a)}${" ".repeat(r-strip(a).length)}${color.gray(S_BAR)}`).join(` +-`);process.stdout.write(`${color.gray(S_BAR)} +-${color.green(S_STEP_SUBMIT)} ${color.reset(n)} ${color.gray(S_BAR_H.repeat(Math.max(r-e-1,1))+S_CORNER_TOP_RIGHT)} +-${c} +-${color.gray(S_CONNECT_LEFT+S_BAR_H.repeat(r+2)+S_CORNER_BOTTOM_RIGHT)} +-`)},cancel=(t="")=>{process.stdout.write(`${color.gray(S_BAR_END)} ${color.red(t)} ++`),o=_(c).length,s=Math.max(r.reduce(($,d)=>(d=_(d),d.length>$?d.length:$),0),o)+2,l=r.map($=>`${e__default.gray(a)} ${e__default.dim($)}${" ".repeat(s-_($).length)}${e__default.gray(a)}`).join(` ++`);process.stdout.write(`${e__default.gray(a)} ++${e__default.green(b)} ${e__default.reset(c)} ${e__default.gray(k.repeat(Math.max(s-o-1,1))+J)} ++${l} ++${e__default.gray(Y+k.repeat(s+2)+Q)} ++`)},cancel=(t="")=>{process.stdout.write(`${e__default.gray(m)} ${e__default.red(t)} + +-`)},intro=(t="")=>{process.stdout.write(`${color.gray(S_BAR_START)} ${t} +-`)},outro=(t="")=>{process.stdout.write(`${color.gray(S_BAR)} +-${color.gray(S_BAR_END)} ${t} ++`)},intro=(t="")=>{process.stdout.write(`${e__default.gray(X)} ${t} ++`)},outro=(t="")=>{process.stdout.write(`${e__default.gray(a)} ++${e__default.gray(m)} ${t} + +-`)},log={message:(t="",{symbol:n=color.gray(S_BAR)}={})=>{const i=[`${color.gray(S_BAR)}`];if(t){const[e,...r]=t.split(` +-`);i.push(`${n} ${e}`,...r.map(c=>`${color.gray(S_BAR)} ${c}`))}process.stdout.write(`${i.join(` ++`)},log={message:(t="",{symbol:c=e__default.gray(a)}={})=>{const r=[`${e__default.gray(a)}`];if(t){const[o,...s]=t.split(` ++`);r.push(`${c} ${o}`,...s.map(l=>`${e__default.gray(a)} ${l}`))}process.stdout.write(`${r.join(` + `)} +-`)},info:t=>{log.message(t,{symbol:color.blue(S_INFO)})},success:t=>{log.message(t,{symbol:color.green(S_SUCCESS)})},step:t=>{log.message(t,{symbol:color.green(S_STEP_SUBMIT)})},warn:t=>{log.message(t,{symbol:color.yellow(S_WARN)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:color.red(S_ERROR)})}},spinner=()=>{const t=unicode?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=unicode?80:120;let i,e,r=!1,c="";const a=(d="")=>{r=!0,i=core.block(),c=d.replace(/\.+$/,""),process.stdout.write(`${color.gray(S_BAR)} +-`);let $=0,m=0;e=setInterval(()=>{const h=color.magenta(t[$]),g=".".repeat(Math.floor(m)).slice(0,3);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${h} ${c}${g}`),$=$+1{c=d??c,r=!1,clearInterval(e);const m=$===0?color.green(S_STEP_SUBMIT):$===1?color.red(S_STEP_CANCEL):color.red(S_STEP_ERROR);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${m} ${c} +-`),i()},o=(d="")=>{c=d??c},u=d=>{const $=d>1?"Something went wrong":"Canceled";r&&l($,d)};return process.on("uncaughtExceptionMonitor",()=>u(2)),process.on("unhandledRejection",()=>u(2)),process.on("SIGINT",()=>u(1)),process.on("SIGTERM",()=>u(1)),process.on("exit",u),{start:a,stop:l,message:o}};function ansiRegex(){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}const group=async(t,n)=>{const i={},e=Object.keys(t);for(const r of e){const c=t[r],a=await c({results:i})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&core.isCancel(a)){i[r]="canceled",n.onCancel({results:i});continue}i[r]=a}return i};exports.isCancel=core.isCancel,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.text=text; ++`)},info:t=>{log.message(t,{symbol:e__default.blue(ee)})},success:t=>{log.message(t,{symbol:e__default.green(te)})},step:t=>{log.message(t,{symbol:e__default.green(b)})},warn:t=>{log.message(t,{symbol:e__default.yellow(re)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:e__default.red(se)})}},spinner=()=>{const t=S?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],c=S?80:120;let r,o,s=!1,l="";const $=w=>{const y=w>1?"Something went wrong":"Canceled";s&&x(y,w)},d=()=>$(2),p=()=>$(1),g=()=>{process.on("uncaughtExceptionMonitor",d),process.on("unhandledRejection",d),process.on("SIGINT",p),process.on("SIGTERM",p),process.on("exit",$)},M=()=>{process.removeListener("uncaughtExceptionMonitor",d),process.removeListener("unhandledRejection",d),process.removeListener("SIGINT",p),process.removeListener("SIGTERM",p),process.removeListener("exit",$)},I=(w="")=>{s=!0,r=core.block(),l=w.replace(/\.+$/,""),process.stdout.write(`${e__default.gray(a)} ++`);let y=0,f=0;g(),o=setInterval(()=>{const j=e__default.magenta(t[y]),q=".".repeat(Math.floor(f)).slice(0,3);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${j} ${l}${q}`),y=y+1{l=w??l,s=!1,clearInterval(o);const f=y===0?e__default.green(b):y===1?e__default.red(R):e__default.red(E);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${f} ${l} ++`),M(),r()};return{start:I,stop:x,message:(w="")=>{l=w??l}}};function ne(){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}const group=async(t,c)=>{const r={},o=Object.keys(t);for(const s of o){const l=t[s],$=await l({results:r})?.catch(d=>{throw d});if(typeof c?.onCancel=="function"&&core.isCancel($)){r[s]="canceled",c.onCancel({results:r});continue}r[s]=$}return r},tasks=async(t,c=1/0)=>{const r=new Concurrency({concurrency:c});await Promise.all(t.filter(o=>o.enabled!==!1).map(o=>r.add(async()=>{const s=spinner();s.start(o.title);const l=await o.task(s.message);s.stop(l||o.title)})))};exports.isCancel=core.isCancel,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.tasks=tasks,exports.text=text; ++//# sourceMappingURL=index.cjs.map +diff --git a/dist/index.d.ts b/dist/index.d.ts +index e03f8d08dfa029db261d15e71d18dd33df0783fa..1221899971f61fdc08e28c132dd9ee7b3efc1528 100644 +--- a/dist/index.d.ts ++++ b/dist/index.d.ts +@@ -31,30 +31,31 @@ type Option = Value extends Primitive ? { + label: string; + hint?: string; + }; +-interface SelectOptions[], Value> { ++interface SelectOptions { + message: string; +- options: Options; ++ options: Option[]; + initialValue?: Value; + maxItems?: number; + } +-declare const select: [], Value>(opts: SelectOptions) => Promise; +-declare const selectKey: [], Value extends string>(opts: SelectOptions) => Promise; +-interface MultiSelectOptions[], Value> { ++declare const select: (opts: SelectOptions) => Promise; ++declare const selectKey: (opts: SelectOptions) => Promise; ++interface MultiSelectOptions { + message: string; +- options: Options; ++ options: Option[]; + initialValues?: Value[]; ++ maxItems?: number; + required?: boolean; + cursorAt?: Value; + } +-declare const multiselect: [], Value>(opts: MultiSelectOptions) => Promise; +-interface GroupMultiSelectOptions[], Value> { ++declare const multiselect: (opts: MultiSelectOptions) => Promise; ++interface GroupMultiSelectOptions { + message: string; +- options: Record; ++ options: Record[]>; + initialValues?: Value[]; + required?: boolean; + cursorAt?: Value; + } +-declare const groupMultiselect: [], Value>(opts: GroupMultiSelectOptions) => Promise; ++declare const groupMultiselect: (opts: GroupMultiSelectOptions) => Promise; + declare const note: (message?: string, title?: string) => void; + declare const cancel: (message?: string) => void; + declare const intro: (title?: string) => void; +@@ -101,6 +102,24 @@ type PromptGroup = { + * Define a group of prompts to be displayed + * and return a results of objects within the group + */ +-declare const group: (prompts: PromptGroup, opts?: PromptGroupOptions | undefined) => Promise extends infer T_1 ? { [P in keyof T_1]: PromptGroupAwaitedReturn[P]; } : never>; ++declare const group: (prompts: PromptGroup, opts?: PromptGroupOptions | undefined) => Promise<{ [P in keyof PromptGroupAwaitedReturn]: PromptGroupAwaitedReturn[P]; }>; ++type Task = { ++ /** ++ * Task title ++ */ ++ title: string; ++ /** ++ * Task function ++ */ ++ task: (message: (string: string) => void) => string | Promise | void | Promise; ++ /** ++ * If enabled === false the task will be skipped ++ */ ++ enabled?: boolean; ++}; ++/** ++ * Define a group of tasks to be executed ++ */ ++declare const tasks: (tasks: Task[], concurrency?: number) => Promise; + +-export { ConfirmOptions, GroupMultiSelectOptions, LogMessageOptions, MultiSelectOptions, PasswordOptions, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, SelectOptions, TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, text }; ++export { type ConfirmOptions, type GroupMultiSelectOptions, type LogMessageOptions, type MultiSelectOptions, type PasswordOptions, type PromptGroup, type PromptGroupAwaitedReturn, type PromptGroupOptions, type SelectOptions, type Task, type TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, tasks, text }; +diff --git a/dist/index.mjs b/dist/index.mjs +index f9c08c661777a51a0f186d0009022a3f0c94c22a..c19b18c330407622d412d3e4bf4c6f0fee498afa 100644 +--- a/dist/index.mjs ++++ b/dist/index.mjs +@@ -1,77 +1,78 @@ +-import{TextPrompt as V,PasswordPrompt as j,ConfirmPrompt as N,SelectPrompt as k,SelectKeyPrompt as W,MultiSelectPrompt as D,GroupMultiSelectPrompt as L,isCancel as G,block as F}from"@clack/core";export{isCancel}from"@clack/core";import h from"node:process";import e from"picocolors";import{cursor as T,erase as A}from"sisteransi";function q(){return h.platform!=="win32"?h.env.TERM!=="linux":Boolean(h.env.CI)||Boolean(h.env.WT_SESSION)||Boolean(h.env.TERMINUS_SUBLIME)||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const _=q(),o=(r,n)=>_?r:n,H=o("\u25C6","*"),I=o("\u25A0","x"),x=o("\u25B2","x"),S=o("\u25C7","o"),K=o("\u250C","T"),a=o("\u2502","|"),d=o("\u2514","\u2014"),b=o("\u25CF",">"),E=o("\u25CB"," "),C=o("\u25FB","[\u2022]"),w=o("\u25FC","[+]"),M=o("\u25FB","[ ]"),U=o("\u25AA","\u2022"),B=o("\u2500","-"),Z=o("\u256E","+"),z=o("\u251C","+"),X=o("\u256F","+"),J=o("\u25CF","\u2022"),Y=o("\u25C6","*"),Q=o("\u25B2","!"),ee=o("\u25A0","x"),y=r=>{switch(r){case"initial":case"active":return e.cyan(H);case"cancel":return e.red(I);case"error":return e.yellow(x);case"submit":return e.green(S)}},te=r=>new V({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){const n=`${e.gray(a)} ++import{TextPrompt as W,PasswordPrompt as F,ConfirmPrompt as N,SelectPrompt as U,SelectKeyPrompt as D,MultiSelectPrompt as Z,GroupMultiSelectPrompt as z,isCancel as J,block as K}from"@clack/core";export{isCancel}from"@clack/core";import h from"node:process";import e from"picocolors";import{cursor as k,erase as A}from"sisteransi";function Y(){return h.platform!=="win32"?h.env.TERM!=="linux":!!h.env.CI||!!h.env.WT_SESSION||!!h.env.TERMINUS_SUBLIME||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Q=Object.defineProperty,X=(r,n,t)=>n in r?Q(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t,C=(r,n,t)=>(X(r,typeof n!="symbol"?n+"":n,t),t);class H{constructor(n){C(this,"concurrency"),C(this,"count"),C(this,"queue"),this.concurrency=n.concurrency,this.count=0,this.queue=new Set}add(n){return this.count{const i=()=>t(this.run(n));this.queue.add(i)})}flush(){for(const n of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(n),n()}}run(n){this.count++;const t=n(),i=()=>{this.count--,this.flush()};return t.then(i,i),t}}const I=Y(),l=(r,n)=>I?r:n,ee=l("\u25C6","*"),V=l("\u25A0","x"),q=l("\u25B2","x"),x=l("\u25C7","o"),te=l("\u250C","T"),a=l("\u2502","|"),$=l("\u2514","\u2014"),T=l("\u25CF",">"),j=l("\u25CB"," "),P=l("\u25FB","[\u2022]"),f=l("\u25FC","[+]"),B=l("\u25FB","[ ]"),re=l("\u25AA","\u2022"),G=l("\u2500","-"),se=l("\u256E","+"),ie=l("\u251C","+"),ne=l("\u256F","+"),ae=l("\u25CF","\u2022"),oe=l("\u25C6","*"),ce=l("\u25B2","!"),ue=l("\u25A0","x"),y=r=>{switch(r){case"initial":case"active":return e.cyan(ee);case"cancel":return e.red(V);case"error":return e.yellow(q);case"submit":return e.green(x)}},R=r=>{const{cursor:n,options:t,style:i}=r,s=r.maxItems===void 0?1/0:Math.max(r.maxItems,5);let o=0;n>=o+s-3?o=Math.max(Math.min(n-s+3,t.length-s),0):n0,u=s{const S=m===0&&c,b=m===M.length-1&&u;return S||b?e.dim("..."):i(d,m+o===n)})},le=r=>new W({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){const n=`${e.gray(a)} + ${y(this.state)} ${r.message} +-`,i=r.placeholder?e.inverse(r.placeholder[0])+e.dim(r.placeholder.slice(1)):e.inverse(e.hidden("_")),t=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()} +-${e.yellow(a)} ${t} +-${e.yellow(d)} ${e.yellow(this.error)} ++`,t=r.placeholder?e.inverse(r.placeholder[0])+e.dim(r.placeholder.slice(1)):e.inverse(e.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${n.trim()} ++${e.yellow(a)} ${i} ++${e.yellow($)} ${e.yellow(this.error)} + `;case"submit":return`${n}${e.gray(a)} ${e.dim(this.value||r.placeholder)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(this.value??""))}${this.value?.trim()?` +-`+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${t} +-${e.cyan(d)} +-`}}}).prompt(),re=r=>new j({validate:r.validate,mask:r.mask??U,render(){const n=`${e.gray(a)} +-${y(this.state)} ${r.message} +-`,i=this.valueWithCursor,t=this.masked;switch(this.state){case"error":return`${n.trim()} +-${e.yellow(a)} ${t} +-${e.yellow(d)} ${e.yellow(this.error)} +-`;case"submit":return`${n}${e.gray(a)} ${e.dim(t)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(t??""))}${t?` + `+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${i} +-${e.cyan(d)} +-`}}}).prompt(),se=r=>{const n=r.active??"Yes",i=r.inactive??"No";return new N({active:n,inactive:i,initialValue:r.initialValue??!0,render(){const t=`${e.gray(a)} ++${e.cyan($)} ++`}}}).prompt(),$e=r=>new F({validate:r.validate,mask:r.mask??re,render(){const n=`${e.gray(a)} ++${y(this.state)} ${r.message} ++`,t=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()} ++${e.yellow(a)} ${i} ++${e.yellow($)} ${e.yellow(this.error)} ++`;case"submit":return`${n}${e.gray(a)} ${e.dim(i)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(i??""))}${i?` ++`+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${t} ++${e.cyan($)} ++`}}}).prompt(),de=r=>{const n=r.active??"Yes",t=r.inactive??"No";return new N({active:n,inactive:t,initialValue:r.initialValue??!0,render(){const i=`${e.gray(a)} + ${y(this.state)} ${r.message} +-`,s=this.value?n:i;switch(this.state){case"submit":return`${t}${e.gray(a)} ${e.dim(s)}`;case"cancel":return`${t}${e.gray(a)} ${e.strikethrough(e.dim(s))} +-${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${this.value?`${e.green(b)} ${n}`:`${e.dim(E)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(E)} ${e.dim(i)}`:`${e.green(b)} ${i}`} +-${e.cyan(d)} +-`}}}).prompt()},ie=r=>{const n=(t,s)=>{const c=t.label??String(t.value);return s==="active"?`${e.green(b)} ${c} ${t.hint?e.dim(`(${t.hint})`):""}`:s==="selected"?`${e.dim(c)}`:s==="cancelled"?`${e.strikethrough(e.dim(c))}`:`${e.dim(E)} ${e.dim(c)}`};let i=0;return new k({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)} ++`,s=this.value?n:t;switch(this.state){case"submit":return`${i}${e.gray(a)} ${e.dim(s)}`;case"cancel":return`${i}${e.gray(a)} ${e.strikethrough(e.dim(s))} ++${e.gray(a)}`;default:return`${i}${e.cyan(a)} ${this.value?`${e.green(T)} ${n}`:`${e.dim(j)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(j)} ${e.dim(t)}`:`${e.green(T)} ${t}`} ++${e.cyan($)} ++`}}}).prompt()},me=r=>{const n=(t,i)=>{const s=t.label??String(t.value);switch(i){case"selected":return`${e.dim(s)}`;case"active":return`${e.green(T)} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`;case"cancelled":return`${e.strikethrough(e.dim(s))}`;default:return`${e.dim(j)} ${e.dim(s)}`}};return new U({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)} + ${y(this.state)} ${r.message} + `;switch(this.state){case"submit":return`${t}${e.gray(a)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${e.gray(a)} ${n(this.options[this.cursor],"cancelled")} +-${e.gray(a)}`;default:{const s=r.maxItems===void 0?1/0:Math.max(r.maxItems,5);this.cursor>=i+s-3?i=Math.max(Math.min(this.cursor-s+3,this.options.length-s),0):this.cursor0,l=sm===0&&c?e.dim("..."):m===$.length-1&&l?e.dim("..."):n(u,m+i===this.cursor?"active":"inactive")).join(` ++${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${R({cursor:this.cursor,options:this.options,maxItems:r.maxItems,style:(i,s)=>n(i,s?"active":"inactive")}).join(` + ${e.cyan(a)} `)} +-${e.cyan(d)} +-`}}}}).prompt()},ne=r=>{const n=(i,t="inactive")=>{const s=i.label??String(i.value);return t==="selected"?`${e.dim(s)}`:t==="cancelled"?`${e.strikethrough(e.dim(s))}`:t==="active"?`${e.bgCyan(e.gray(` ${i.value} `))} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${i.value} `)))} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`};return new W({options:r.options,initialValue:r.initialValue,render(){const i=`${e.gray(a)} ++${e.cyan($)} ++`}}}).prompt()},he=r=>{const n=(t,i="inactive")=>{const s=t.label??String(t.value);return i==="selected"?`${e.dim(s)}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active"?`${e.bgCyan(e.gray(` ${t.value} `))} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${t.value} `)))} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`};return new D({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)} + ${y(this.state)} ${r.message} +-`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${n(this.options.find(t=>t.value===this.value),"selected")}`;case"cancel":return`${i}${e.gray(a)} ${n(this.options[0],"cancelled")} +-${e.gray(a)}`;default:return`${i}${e.cyan(a)} ${this.options.map((t,s)=>n(t,s===this.cursor?"active":"inactive")).join(` ++`;switch(this.state){case"submit":return`${t}${e.gray(a)} ${n(this.options.find(i=>i.value===this.value),"selected")}`;case"cancel":return`${t}${e.gray(a)} ${n(this.options[0],"cancelled")} ++${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${this.options.map((i,s)=>n(i,s===this.cursor?"active":"inactive")).join(` + ${e.cyan(a)} `)} +-${e.cyan(d)} +-`}}}).prompt()},ae=r=>{const n=(i,t)=>{const s=i.label??String(i.value);return t==="active"?`${e.cyan(C)} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="selected"?`${e.green(w)} ${e.dim(s)}`:t==="cancelled"?`${e.strikethrough(e.dim(s))}`:t==="active-selected"?`${e.green(w)} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="submitted"?`${e.dim(s)}`:`${e.dim(M)} ${e.dim(s)}`};return new D({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. +-${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let i=`${e.gray(a)} ++${e.cyan($)} ++`}}}).prompt()},pe=r=>{const n=(t,i)=>{const s=t.label??String(t.value);return i==="active"?`${e.cyan(P)} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="selected"?`${e.green(f)} ${e.dim(s)}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active-selected"?`${e.green(f)} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="submitted"?`${e.dim(s)}`:`${e.dim(B)} ${e.dim(s)}`};return new Z({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option. ++${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let t=`${e.gray(a)} + ${y(this.state)} ${r.message} +-`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${this.options.filter(({value:t})=>this.value.includes(t)).map(t=>n(t,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const t=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${i}${e.gray(a)} ${t.trim()?`${t} +-${e.gray(a)}`:""}`}case"error":{const t=this.error.split(` +-`).map((s,c)=>c===0?`${e.yellow(d)} ${e.yellow(s)}`:` ${s}`).join(` +-`);return i+e.yellow(a)+" "+this.options.map((s,c)=>{const l=this.value.includes(s.value),u=c===this.cursor;return u&&l?n(s,"active-selected"):l?n(s,"selected"):n(s,u?"active":"inactive")}).join(` ++`;const i=(s,o)=>{const c=this.value.includes(s.value);return o&&c?n(s,"active-selected"):c?n(s,"selected"):n(s,o?"active":"inactive")};switch(this.state){case"submit":return`${t}${e.gray(a)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const s=this.options.filter(({value:o})=>this.value.includes(o)).map(o=>n(o,"cancelled")).join(e.dim(", "));return`${t}${e.gray(a)} ${s.trim()?`${s} ++${e.gray(a)}`:""}`}case"error":{const s=this.error.split(` ++`).map((o,c)=>c===0?`${e.yellow($)} ${e.yellow(o)}`:` ${o}`).join(` ++`);return t+e.yellow(a)+" "+R({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(` + ${e.yellow(a)} `)+` +-`+t+` +-`}default:return`${i}${e.cyan(a)} ${this.options.map((t,s)=>{const c=this.value.includes(t.value),l=s===this.cursor;return l&&c?n(t,"active-selected"):c?n(t,"selected"):n(t,l?"active":"inactive")}).join(` ++`+s+` ++`}default:return`${t}${e.cyan(a)} ${R({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(` + ${e.cyan(a)} `)} +-${e.cyan(d)} +-`}}}).prompt()},ce=r=>{const n=(i,t,s=[])=>{const c=i.label??String(i.value),l=typeof i.group=="string",u=l&&(s[s.indexOf(i)+1]??{group:!0}),m=l&&u.group===!0,$=l?`${m?d:a} `:"";return t==="active"?`${e.dim($)}${e.cyan(C)} ${c} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="group-active"?`${$}${e.cyan(C)} ${e.dim(c)}`:t==="group-active-selected"?`${$}${e.green(w)} ${e.dim(c)}`:t==="selected"?`${e.dim($)}${e.green(w)} ${e.dim(c)}`:t==="cancelled"?`${e.strikethrough(e.dim(c))}`:t==="active-selected"?`${e.dim($)}${e.green(w)} ${c} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="submitted"?`${e.dim(c)}`:`${e.dim($)}${e.dim(M)} ${e.dim(c)}`};return new L({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. +-${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let i=`${e.gray(a)} ++${e.cyan($)} ++`}}}).prompt()},ge=r=>{const n=(t,i,s=[])=>{const o=t.label??String(t.value),c=typeof t.group=="string",u=c&&(s[s.indexOf(t)+1]??{group:!0}),d=c&&u.group===!0,m=c?`${d?$:a} `:"";return i==="active"?`${e.dim(m)}${e.cyan(P)} ${o} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="group-active"?`${m}${e.cyan(P)} ${e.dim(o)}`:i==="group-active-selected"?`${m}${e.green(f)} ${e.dim(o)}`:i==="selected"?`${e.dim(m)}${e.green(f)} ${e.dim(o)}`:i==="cancelled"?`${e.strikethrough(e.dim(o))}`:i==="active-selected"?`${e.dim(m)}${e.green(f)} ${o} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="submitted"?`${e.dim(o)}`:`${e.dim(m)}${e.dim(B)} ${e.dim(o)}`};return new z({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option. ++${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let t=`${e.gray(a)} + ${y(this.state)} ${r.message} +-`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${this.options.filter(({value:t})=>this.value.includes(t)).map(t=>n(t,"submitted")).join(e.dim(", "))}`;case"cancel":{const t=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${i}${e.gray(a)} ${t.trim()?`${t} +-${e.gray(a)}`:""}`}case"error":{const t=this.error.split(` +-`).map((s,c)=>c===0?`${e.yellow(d)} ${e.yellow(s)}`:` ${s}`).join(` +-`);return`${i}${e.yellow(a)} ${this.options.map((s,c,l)=>{const u=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),m=c===this.cursor;return!m&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?n(s,u?"group-active-selected":"group-active",l):m&&u?n(s,"active-selected",l):u?n(s,"selected",l):n(s,m?"active":"inactive",l)}).join(` ++`;switch(this.state){case"submit":return`${t}${e.gray(a)} ${this.options.filter(({value:i})=>this.value.includes(i)).map(i=>n(i,"submitted")).join(e.dim(", "))}`;case"cancel":{const i=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${t}${e.gray(a)} ${i.trim()?`${i} ++${e.gray(a)}`:""}`}case"error":{const i=this.error.split(` ++`).map((s,o)=>o===0?`${e.yellow($)} ${e.yellow(s)}`:` ${s}`).join(` ++`);return`${t}${e.yellow(a)} ${this.options.map((s,o,c)=>{const u=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),d=o===this.cursor;return!d&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?n(s,u?"group-active-selected":"group-active",c):d&&u?n(s,"active-selected",c):u?n(s,"selected",c):n(s,d?"active":"inactive",c)}).join(` + ${e.yellow(a)} `)} +-${t} +-`}default:return`${i}${e.cyan(a)} ${this.options.map((t,s,c)=>{const l=this.value.includes(t.value)||t.group===!0&&this.isGroupSelected(`${t.value}`),u=s===this.cursor;return!u&&typeof t.group=="string"&&this.options[this.cursor].value===t.group?n(t,l?"group-active-selected":"group-active",c):u&&l?n(t,"active-selected",c):l?n(t,"selected",c):n(t,u?"active":"inactive",c)}).join(` ++${i} ++`}default:return`${t}${e.cyan(a)} ${this.options.map((i,s,o)=>{const c=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),u=s===this.cursor;return!u&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?n(i,c?"group-active-selected":"group-active",o):u&&c?n(i,"active-selected",o):c?n(i,"selected",o):n(i,u?"active":"inactive",o)}).join(` + ${e.cyan(a)} `)} +-${e.cyan(d)} +-`}}}).prompt()},R=r=>r.replace(me(),""),le=(r="",n="")=>{const i=` ++${e.cyan($)} ++`}}}).prompt()},E=r=>r.replace(be(),""),ye=(r="",n="")=>{const t=` + ${r} + `.split(` +-`),t=R(n).length,s=Math.max(i.reduce((l,u)=>(u=R(u),u.length>l?u.length:l),0),t)+2,c=i.map(l=>`${e.gray(a)} ${e.dim(l)}${" ".repeat(s-R(l).length)}${e.gray(a)}`).join(` ++`),i=E(n).length,s=Math.max(t.reduce((c,u)=>(u=E(u),u.length>c?u.length:c),0),i)+2,o=t.map(c=>`${e.gray(a)} ${e.dim(c)}${" ".repeat(s-E(c).length)}${e.gray(a)}`).join(` + `);process.stdout.write(`${e.gray(a)} +-${e.green(S)} ${e.reset(n)} ${e.gray(B.repeat(Math.max(s-t-1,1))+Z)} +-${c} +-${e.gray(z+B.repeat(s+2)+X)} +-`)},ue=(r="")=>{process.stdout.write(`${e.gray(d)} ${e.red(r)} ++${e.green(x)} ${e.reset(n)} ${e.gray(G.repeat(Math.max(s-i-1,1))+se)} ++${o} ++${e.gray(ie+G.repeat(s+2)+ne)} ++`)},ve=(r="")=>{process.stdout.write(`${e.gray($)} ${e.red(r)} + +-`)},oe=(r="")=>{process.stdout.write(`${e.gray(K)} ${r} +-`)},$e=(r="")=>{process.stdout.write(`${e.gray(a)} +-${e.gray(d)} ${r} ++`)},we=(r="")=>{process.stdout.write(`${e.gray(te)} ${r} ++`)},fe=(r="")=>{process.stdout.write(`${e.gray(a)} ++${e.gray($)} ${r} + +-`)},f={message:(r="",{symbol:n=e.gray(a)}={})=>{const i=[`${e.gray(a)}`];if(r){const[t,...s]=r.split(` +-`);i.push(`${n} ${t}`,...s.map(c=>`${e.gray(a)} ${c}`))}process.stdout.write(`${i.join(` ++`)},v={message:(r="",{symbol:n=e.gray(a)}={})=>{const t=[`${e.gray(a)}`];if(r){const[i,...s]=r.split(` ++`);t.push(`${n} ${i}`,...s.map(o=>`${e.gray(a)} ${o}`))}process.stdout.write(`${t.join(` + `)} +-`)},info:r=>{f.message(r,{symbol:e.blue(J)})},success:r=>{f.message(r,{symbol:e.green(Y)})},step:r=>{f.message(r,{symbol:e.green(S)})},warn:r=>{f.message(r,{symbol:e.yellow(Q)})},warning:r=>{f.warn(r)},error:r=>{f.message(r,{symbol:e.red(ee)})}},de=()=>{const r=_?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=_?80:120;let i,t,s=!1,c="";const l=(v="")=>{s=!0,i=F(),c=v.replace(/\.+$/,""),process.stdout.write(`${e.gray(a)} +-`);let g=0,p=0;t=setInterval(()=>{const O=e.magenta(r[g]),P=".".repeat(Math.floor(p)).slice(0,3);process.stdout.write(T.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${O} ${c}${P}`),g=g+1{c=v??c,s=!1,clearInterval(t);const p=g===0?e.green(S):g===1?e.red(I):e.red(x);process.stdout.write(T.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${p} ${c} +-`),i()},m=(v="")=>{c=v??c},$=v=>{const g=v>1?"Something went wrong":"Canceled";s&&u(g,v)};return process.on("uncaughtExceptionMonitor",()=>$(2)),process.on("unhandledRejection",()=>$(2)),process.on("SIGINT",()=>$(1)),process.on("SIGTERM",()=>$(1)),process.on("exit",$),{start:l,stop:u,message:m}};function me(){const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,"g")}const he=async(r,n)=>{const i={},t=Object.keys(r);for(const s of t){const c=r[s],l=await c({results:i})?.catch(u=>{throw u});if(typeof n?.onCancel=="function"&&G(l)){i[s]="canceled",n.onCancel({results:i});continue}i[s]=l}return i};export{ue as cancel,se as confirm,he as group,ce as groupMultiselect,oe as intro,f as log,ae as multiselect,le as note,$e as outro,re as password,ie as select,ne as selectKey,de as spinner,te as text}; ++`)},info:r=>{v.message(r,{symbol:e.blue(ae)})},success:r=>{v.message(r,{symbol:e.green(oe)})},step:r=>{v.message(r,{symbol:e.green(x)})},warn:r=>{v.message(r,{symbol:e.yellow(ce)})},warning:r=>{v.warn(r)},error:r=>{v.message(r,{symbol:e.red(ue)})}},O=()=>{const r=I?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=I?80:120;let t,i,s=!1,o="";const c=g=>{const p=g>1?"Something went wrong":"Canceled";s&&b(p,g)},u=()=>c(2),d=()=>c(1),m=()=>{process.on("uncaughtExceptionMonitor",u),process.on("unhandledRejection",u),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",c)},M=()=>{process.removeListener("uncaughtExceptionMonitor",u),process.removeListener("unhandledRejection",u),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",c)},S=(g="")=>{s=!0,t=K(),o=g.replace(/\.+$/,""),process.stdout.write(`${e.gray(a)} ++`);let p=0,w=0;m(),i=setInterval(()=>{const _=e.magenta(r[p]),L=".".repeat(Math.floor(w)).slice(0,3);process.stdout.write(k.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${_} ${o}${L}`),p=p+1{o=g??o,s=!1,clearInterval(i);const w=p===0?e.green(x):p===1?e.red(V):e.red(q);process.stdout.write(k.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${w} ${o} ++`),M(),t()};return{start:S,stop:b,message:(g="")=>{o=g??o}}};function be(){const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,"g")}const xe=async(r,n)=>{const t={},i=Object.keys(r);for(const s of i){const o=r[s],c=await o({results:t})?.catch(u=>{throw u});if(typeof n?.onCancel=="function"&&J(c)){t[s]="canceled",n.onCancel({results:t});continue}t[s]=c}return t},Me=async(r,n=1/0)=>{const t=new H({concurrency:n});await Promise.all(r.filter(i=>i.enabled!==!1).map(i=>t.add(async()=>{const s=O();s.start(i.title);const o=await i.task(s.message);s.stop(o||i.title)})))};export{ve as cancel,de as confirm,xe as group,ge as groupMultiselect,we as intro,v as log,pe as multiselect,ye as note,fe as outro,$e as password,me as select,he as selectKey,O as spinner,Me as tasks,le as text}; ++//# sourceMappingURL=index.mjs.map diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b507390..0a63a6cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,12 @@ overrides: ast-types: ^0.16.1 patchedDependencies: + '@clack/core@0.3.3': + hash: eqexlyo4xb4wow7zklitcmhm24 + path: patches/@clack__core@0.3.3.patch + '@clack/prompts@0.7.0': + hash: phrwq726kjmeof6tfupe6bspsa + path: patches/@clack__prompts@0.7.0.patch ast-types@0.16.1: hash: lbcpk3ulhul2sxdbqn4xesbaem path: patches/ast-types@0.16.1.patch @@ -81,7 +87,7 @@ importers: version: 0.16.1(patch_hash=lbcpk3ulhul2sxdbqn4xesbaem) jscodeshift: specifier: ^0.15.1 - version: 0.15.1(@babel/preset-env@7.23.3) + version: 0.15.1 tsup: specifier: ^7.3.0 version: 7.3.0(typescript@5.3.2) @@ -91,6 +97,58 @@ importers: packages/browserfs: {} + packages/cli: + dependencies: + '@clack/core': + specifier: ^0.3.3 + version: 0.3.3(patch_hash=eqexlyo4xb4wow7zklitcmhm24) + '@clack/prompts': + specifier: ^0.7.0 + version: 0.7.0(patch_hash=phrwq726kjmeof6tfupe6bspsa) + fs-extra: + specifier: ^11.1.1 + version: 11.1.1 + globby: + specifier: ^11.1.0 + version: 11.1.0 + picocolors: + specifier: ^1.0.0 + version: 1.0.0 + yargs: + specifier: ^17.7.2 + version: 17.7.2 + devDependencies: + '@types/fs-extra': + specifier: ^11.0.4 + version: 11.0.4 + '@types/jscodeshift': + specifier: ^0.11.11 + version: 0.11.11 + '@types/yargs': + specifier: ^17.0.32 + version: 17.0.32 + '@wakaru/ast-utils': + specifier: workspace:* + version: link:../ast-utils + '@wakaru/test-utils': + specifier: workspace:* + version: link:../test-utils + '@wakaru/unminify': + specifier: workspace:* + version: link:../unminify + '@wakaru/unpacker': + specifier: workspace:* + version: link:../unpacker + tsup: + specifier: ^7.3.0 + version: 7.3.0(typescript@5.3.2) + tsx: + specifier: ^4.6.2 + version: 4.6.2 + typescript: + specifier: ^5.3.2 + version: 5.3.2 + packages/ds: {} packages/ide: @@ -303,7 +361,7 @@ importers: version: 0.11.11 jscodeshift: specifier: ^0.15.1 - version: 0.15.1(@babel/preset-env@7.23.3) + version: 0.15.1 typescript: specifier: ^5.3.2 version: 5.3.2 @@ -413,7 +471,7 @@ importers: version: 0.16.1(patch_hash=lbcpk3ulhul2sxdbqn4xesbaem) jscodeshift: specifier: ^0.15.1 - version: 0.15.1(@babel/preset-env@7.23.3) + version: 0.15.1 tsup: specifier: ^7.3.0 version: 7.3.0(typescript@5.3.2) @@ -505,7 +563,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@ampproject/remapping': 2.2.1 - '@babel/code-frame': 7.22.13 + '@babel/code-frame': 7.23.4 '@babel/generator': 7.23.4 '@babel/helper-compilation-targets': 7.22.15 '@babel/helper-module-transforms': 7.23.3(@babel/core@7.23.3) @@ -1760,6 +1818,25 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true + /@clack/core@0.3.3(patch_hash=eqexlyo4xb4wow7zklitcmhm24): + resolution: {integrity: sha512-5ZGyb75BUBjlll6eOa1m/IZBxwk91dooBWhPSL67sWcLS0zt9SnswRL0l26TVdBhb0wnWORRxUn//uH6n4z7+A==} + dependencies: + picocolors: 1.0.0 + sisteransi: 1.0.5 + dev: false + patched: true + + /@clack/prompts@0.7.0(patch_hash=phrwq726kjmeof6tfupe6bspsa): + resolution: {integrity: sha512-0MhX9/B4iL6Re04jPrttDm+BsP8y6mS7byuv0BvXgdXhbV5PdlsHt55dvNsuBCPZ7xq1oTAOOuotR9NFbQyMSA==} + dependencies: + '@clack/core': 0.3.3(patch_hash=eqexlyo4xb4wow7zklitcmhm24) + picocolors: 1.0.0 + sisteransi: 1.0.5 + dev: false + bundledDependencies: + - is-unicode-supported + patched: true + /@codemirror/autocomplete@6.9.0(@codemirror/language@6.8.0)(@codemirror/state@6.3.1)(@codemirror/view@6.22.0)(@lezer/common@1.0.3): resolution: {integrity: sha512-Fbwm0V/Wn3BkEJZRhr0hi5BhCo5a7eBL6LYaliPjOSwCyfOpnjXY59HruSxOUNV+1OYer0Tgx1zRNQttjXyDog==} peerDependencies: @@ -1891,6 +1968,15 @@ packages: dev: true optional: true + /@esbuild/android-arm64@0.18.20: + resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-arm64@0.19.5: resolution: {integrity: sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==} engines: {node: '>=12'} @@ -1917,6 +2003,15 @@ packages: dev: true optional: true + /@esbuild/android-arm@0.18.20: + resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-arm@0.19.5: resolution: {integrity: sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==} engines: {node: '>=12'} @@ -1943,6 +2038,15 @@ packages: dev: true optional: true + /@esbuild/android-x64@0.18.20: + resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + /@esbuild/android-x64@0.19.5: resolution: {integrity: sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==} engines: {node: '>=12'} @@ -1969,6 +2073,15 @@ packages: dev: true optional: true + /@esbuild/darwin-arm64@0.18.20: + resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /@esbuild/darwin-arm64@0.19.5: resolution: {integrity: sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==} engines: {node: '>=12'} @@ -1995,6 +2108,15 @@ packages: dev: true optional: true + /@esbuild/darwin-x64@0.18.20: + resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /@esbuild/darwin-x64@0.19.5: resolution: {integrity: sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==} engines: {node: '>=12'} @@ -2021,6 +2143,15 @@ packages: dev: true optional: true + /@esbuild/freebsd-arm64@0.18.20: + resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/freebsd-arm64@0.19.5: resolution: {integrity: sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==} engines: {node: '>=12'} @@ -2047,6 +2178,15 @@ packages: dev: true optional: true + /@esbuild/freebsd-x64@0.18.20: + resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/freebsd-x64@0.19.5: resolution: {integrity: sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==} engines: {node: '>=12'} @@ -2073,6 +2213,15 @@ packages: dev: true optional: true + /@esbuild/linux-arm64@0.18.20: + resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-arm64@0.19.5: resolution: {integrity: sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==} engines: {node: '>=12'} @@ -2099,6 +2248,15 @@ packages: dev: true optional: true + /@esbuild/linux-arm@0.18.20: + resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-arm@0.19.5: resolution: {integrity: sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==} engines: {node: '>=12'} @@ -2125,6 +2283,15 @@ packages: dev: true optional: true + /@esbuild/linux-ia32@0.18.20: + resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-ia32@0.19.5: resolution: {integrity: sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==} engines: {node: '>=12'} @@ -2151,6 +2318,15 @@ packages: dev: true optional: true + /@esbuild/linux-loong64@0.18.20: + resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-loong64@0.19.5: resolution: {integrity: sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==} engines: {node: '>=12'} @@ -2177,6 +2353,15 @@ packages: dev: true optional: true + /@esbuild/linux-mips64el@0.18.20: + resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-mips64el@0.19.5: resolution: {integrity: sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==} engines: {node: '>=12'} @@ -2203,6 +2388,15 @@ packages: dev: true optional: true + /@esbuild/linux-ppc64@0.18.20: + resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-ppc64@0.19.5: resolution: {integrity: sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==} engines: {node: '>=12'} @@ -2229,6 +2423,15 @@ packages: dev: true optional: true + /@esbuild/linux-riscv64@0.18.20: + resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-riscv64@0.19.5: resolution: {integrity: sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==} engines: {node: '>=12'} @@ -2255,6 +2458,15 @@ packages: dev: true optional: true + /@esbuild/linux-s390x@0.18.20: + resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-s390x@0.19.5: resolution: {integrity: sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==} engines: {node: '>=12'} @@ -2281,6 +2493,15 @@ packages: dev: true optional: true + /@esbuild/linux-x64@0.18.20: + resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /@esbuild/linux-x64@0.19.5: resolution: {integrity: sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==} engines: {node: '>=12'} @@ -2307,6 +2528,15 @@ packages: dev: true optional: true + /@esbuild/netbsd-x64@0.18.20: + resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/netbsd-x64@0.19.5: resolution: {integrity: sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==} engines: {node: '>=12'} @@ -2333,6 +2563,15 @@ packages: dev: true optional: true + /@esbuild/openbsd-x64@0.18.20: + resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + /@esbuild/openbsd-x64@0.19.5: resolution: {integrity: sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==} engines: {node: '>=12'} @@ -2359,6 +2598,15 @@ packages: dev: true optional: true + /@esbuild/sunos-x64@0.18.20: + resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + /@esbuild/sunos-x64@0.19.5: resolution: {integrity: sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==} engines: {node: '>=12'} @@ -2385,6 +2633,15 @@ packages: dev: true optional: true + /@esbuild/win32-arm64@0.18.20: + resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-arm64@0.19.5: resolution: {integrity: sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==} engines: {node: '>=12'} @@ -2411,6 +2668,15 @@ packages: dev: true optional: true + /@esbuild/win32-ia32@0.18.20: + resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-ia32@0.19.5: resolution: {integrity: sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==} engines: {node: '>=12'} @@ -2437,6 +2703,15 @@ packages: dev: true optional: true + /@esbuild/win32-x64@0.18.20: + resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@esbuild/win32-x64@0.19.5: resolution: {integrity: sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==} engines: {node: '>=12'} @@ -5235,7 +5510,7 @@ packages: check-error: 1.0.3 deep-eql: 4.1.3 get-func-name: 2.0.2 - loupe: 2.3.6 + loupe: 2.3.7 pathval: 1.1.1 type-detect: 4.0.8 @@ -5764,6 +6039,36 @@ packages: '@esbuild/win32-x64': 0.18.15 dev: true + /esbuild@0.18.20: + resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.18.20 + '@esbuild/android-arm64': 0.18.20 + '@esbuild/android-x64': 0.18.20 + '@esbuild/darwin-arm64': 0.18.20 + '@esbuild/darwin-x64': 0.18.20 + '@esbuild/freebsd-arm64': 0.18.20 + '@esbuild/freebsd-x64': 0.18.20 + '@esbuild/linux-arm': 0.18.20 + '@esbuild/linux-arm64': 0.18.20 + '@esbuild/linux-ia32': 0.18.20 + '@esbuild/linux-loong64': 0.18.20 + '@esbuild/linux-mips64el': 0.18.20 + '@esbuild/linux-ppc64': 0.18.20 + '@esbuild/linux-riscv64': 0.18.20 + '@esbuild/linux-s390x': 0.18.20 + '@esbuild/linux-x64': 0.18.20 + '@esbuild/netbsd-x64': 0.18.20 + '@esbuild/openbsd-x64': 0.18.20 + '@esbuild/sunos-x64': 0.18.20 + '@esbuild/win32-arm64': 0.18.20 + '@esbuild/win32-ia32': 0.18.20 + '@esbuild/win32-x64': 0.18.20 + dev: true + /esbuild@0.19.5: resolution: {integrity: sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==} engines: {node: '>=12'} @@ -6282,6 +6587,7 @@ packages: glob-parent: 5.1.2 merge2: 1.4.1 micromatch: 4.0.5 + dev: true /fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} @@ -6587,7 +6893,7 @@ packages: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.3.0 + fast-glob: 3.3.2 ignore: 5.2.4 merge2: 1.4.1 slash: 3.0.0 @@ -7142,7 +7448,7 @@ packages: argparse: 2.0.1 dev: true - /jscodeshift@0.15.1(@babel/preset-env@7.23.3): + /jscodeshift@0.15.1: resolution: {integrity: sha512-hIJfxUy8Rt4HkJn/zZPU9ChKfKZM1342waJ1QC2e2YsPcWhM+3BJ4dcfQCzArTrk1jJeNLB341H+qOcEHRxJZg==} hasBin: true peerDependencies: @@ -7158,6 +7464,39 @@ packages: '@babel/plugin-transform-nullish-coalescing-operator': 7.22.11(@babel/core@7.23.3) '@babel/plugin-transform-optional-chaining': 7.23.4(@babel/core@7.23.3) '@babel/plugin-transform-private-methods': 7.22.5(@babel/core@7.23.3) + '@babel/preset-flow': 7.23.3(@babel/core@7.23.3) + '@babel/preset-typescript': 7.23.3(@babel/core@7.23.3) + '@babel/register': 7.22.15(@babel/core@7.23.3) + babel-core: 7.0.0-bridge.0(@babel/core@7.23.3) + chalk: 4.1.2 + flow-parser: 0.212.0 + graceful-fs: 4.2.11 + micromatch: 4.0.5 + neo-async: 2.6.2 + node-dir: 0.1.17 + recast: 0.23.4 + temp: 0.8.4 + write-file-atomic: 2.4.3 + transitivePeerDependencies: + - supports-color + dev: true + + /jscodeshift@0.15.1(@babel/preset-env@7.23.3): + resolution: {integrity: sha512-hIJfxUy8Rt4HkJn/zZPU9ChKfKZM1342waJ1QC2e2YsPcWhM+3BJ4dcfQCzArTrk1jJeNLB341H+qOcEHRxJZg==} + hasBin: true + peerDependencies: + '@babel/preset-env': ^7.1.6 + peerDependenciesMeta: + '@babel/preset-env': + optional: true + dependencies: + '@babel/core': 7.23.3 + '@babel/parser': 7.23.4 + '@babel/plugin-transform-class-properties': 7.23.3(@babel/core@7.23.3) + '@babel/plugin-transform-modules-commonjs': 7.23.3(@babel/core@7.23.3) + '@babel/plugin-transform-nullish-coalescing-operator': 7.23.4(@babel/core@7.23.3) + '@babel/plugin-transform-optional-chaining': 7.23.4(@babel/core@7.23.3) + '@babel/plugin-transform-private-methods': 7.23.3(@babel/core@7.23.3) '@babel/preset-env': 7.23.3(@babel/core@7.23.3) '@babel/preset-flow': 7.23.3(@babel/core@7.23.3) '@babel/preset-typescript': 7.23.3(@babel/core@7.23.3) @@ -7379,11 +7718,6 @@ packages: dependencies: js-tokens: 4.0.0 - /loupe@2.3.6: - resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} - dependencies: - get-func-name: 2.0.2 - /loupe@2.3.7: resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} dependencies: @@ -8819,7 +9153,6 @@ packages: /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - dev: true /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} @@ -9282,6 +9615,17 @@ packages: fsevents: 2.3.3 dev: true + /tsx@4.6.2: + resolution: {integrity: sha512-QPpBdJo+ZDtqZgAnq86iY/PD2KYCUPSUGIunHdGwyII99GKH+f3z3FZ8XNFLSGQIA4I365ui8wnQpl8OKLqcsg==} + engines: {node: '>=18.0.0'} + hasBin: true + dependencies: + esbuild: 0.18.20 + get-tsconfig: 4.7.2 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /tuf-js@2.1.0: resolution: {integrity: sha512-eD7YPPjVlMzdggrOeE8zwoegUaG/rt6Bt3jwoQPunRiNVzgcCE009UDFJKJjG+Gk9wFu6W/Vi+P5d/5QpdD9jA==} engines: {node: ^16.14.0 || >=18.0.0} diff --git a/vitest.config.js b/vitest.config.js index 7f30bfe8..04540e3b 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -14,6 +14,7 @@ export default defineConfig({ 'examples/**', 'testcases/**', 'packages/browserfs/**', + 'packages/cli/**', 'packages/ide/**', 'packages/playground/**', From 4fc3b221b9d96983fd51cdd1d2ab828ceb89d834 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Sun, 10 Dec 2023 21:50:14 +0800 Subject: [PATCH 02/19] feat!: deprecate `@wakaru/unminify` and `@wakaru/unpacker` CLI in favor of `@wakaru/cli` --- packages/unminify/package.json | 4 - packages/unminify/src/cli.ts | 234 +-------------------------------- packages/unpacker/package.json | 7 - packages/unpacker/src/cli.ts | 128 +----------------- pnpm-lock.yaml | 28 ---- 5 files changed, 2 insertions(+), 399 deletions(-) diff --git a/packages/unminify/package.json b/packages/unminify/package.json index 22817ef6..ac0a43b2 100644 --- a/packages/unminify/package.json +++ b/packages/unminify/package.json @@ -29,16 +29,12 @@ "@babel/helper-validator-identifier": "^7.22.20", "@babel/preset-env": "^7.23.3", "@babel/types": "^7.23.4", - "fs-extra": "^11.1.1", - "globby": "^11.1.0", "lebab": "^3.2.3", "picocolors": "^1.0.0", "prettier": "^2.8.8", - "yargs": "^17.7.2", "zod": "^3.22.4" }, "devDependencies": { - "@types/fs-extra": "^11.0.4", "@types/jscodeshift": "^0.11.11", "@types/prettier": "^2.7.3", "@types/yargs": "^17.0.32", diff --git a/packages/unminify/src/cli.ts b/packages/unminify/src/cli.ts index 0b784c39..503758ce 100644 --- a/packages/unminify/src/cli.ts +++ b/packages/unminify/src/cli.ts @@ -1,236 +1,4 @@ #!/usr/bin/env node /* eslint-disable no-console */ -import * as path from 'node:path' -import process, { hrtime } from 'node:process' -import fsa from 'fs-extra' -import * as globby from 'globby' -import c from 'picocolors' -import yargs from 'yargs' -import { hideBin } from 'yargs/helpers' -import { version } from '../package.json' -import { TransformationRule } from './transformations' -import { runTransformations, transformationRules } from '.' -import type { Transform } from 'jscodeshift' - -type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'silent' - -interface TimingStat { - filename: string - /** - * Timing measurement key - */ - key: string - /** - * Time in milliseconds - */ - time: number -} - -class Timing { - private collected: TimingStat[] = [] - - constructor(private enabled: boolean) { } - - /** - * Collect a timing measurement - */ - collect(filename: string, key: string, fn: () => T): T { - if (!this.enabled) return fn() - - const { result, time } = this.measureTime(fn) - this.collected.push({ filename, key, time }) - - return result - } - - /** - * Collect a timing measurement - */ - async collectAsync(filename: string, key: string, fn: () => T): Promise { - if (!this.enabled) return fn() - - const { result, time } = await this.measureTimeAsync(fn) - this.collected.push({ filename, key, time }) - - return result - } - - /** - * Measure the time it takes to execute a function - */ - measureTime(fn: () => T) { - const start = hrtime() - const result = fn() - const end = hrtime(start) - const time = end[0] * 1e3 + end[1] / 1e6 - - return { result, time } - } - - /** - * Measure the time it takes to execute a async function - */ - async measureTimeAsync(fn: () => T) { - const start = hrtime() - const result = await fn() - const end = hrtime(start) - const time = end[0] * 1e3 + end[1] / 1e6 - - return { result, time } - } -} - -// eslint-disable-next-line no-unused-expressions -yargs(hideBin(process.argv)) - .scriptName('@wakaru/unminify') - - .option('log-level', { - type: 'string', - default: 'info', - choices: ['error', 'warn', 'info', 'debug', 'silent'], - describe: 'change the level of logging for the CLI.', - }) - - .help() - .showHelpOnFail(true) - .alias('h', 'help') - - .version('version', version) - .alias('v', 'version') - - .usage('Usage: $0 [options]') - .command( - '* ', - 'Unminify your bundled code', - args => args - - .option('output', { - alias: 'o', - describe: 'specify the output directory (default: out/)', - type: 'string', - default: 'out/', - }) - .option('force', { - alias: 'f', - describe: 'force overwrite output directory', - type: 'boolean', - default: false, - }) - .option('perf', { - describe: 'enable performance statistics', - type: 'boolean', - default: false, - }) - .positional('files', { - describe: 'File paths to process (supports glob patterns)', - type: 'string', - array: true, - }) - .help(), - async (args) => { - await codemod( - args.files ?? [], - args.output, - args.force, - args.logLevel as LogLevel, - args.perf, - ) - }, - ) - .argv - -async function codemod( - paths: string[], - output: string, - force: boolean, - logLevel: LogLevel, - perf: boolean, -) { - const cwd = process.cwd() - const globbyPaths = paths - .map(p => path.normalize(p)) - .map(p => p.replace(/\\/g, '/')) - const resolvedPaths = await globby.default(globbyPaths, { - cwd, - absolute: true, - ignore: [path.join(cwd, '**/node_modules/**')], - }) - - // Check if any paths are outside of the current working directory - for (const p of resolvedPaths) { - if (!isPathInside(cwd, p)) { - throw new Error(`File path ${c.green(path.relative(cwd, p))} is outside of the current working directory. This is not allowed.`) - } - } - - const outputDir = path.resolve(cwd, output) - if (await fsa.exists(outputDir)) { - if (!force) { - throw new Error(`Output directory already exists at ${c.green(path.relative(cwd, outputDir))}. Pass ${c.yellow('--force')} to overwrite.`) - } - } - await fsa.ensureDir(outputDir) - - const commonBaseDir = findCommonBaseDir(resolvedPaths) - if (!commonBaseDir) throw new Error('Could not find common base directory') - - const timing = new Timing(perf) - - for (const p of resolvedPaths) { - const outputPath = path.join(outputDir, path.relative(commonBaseDir, p)) - await fsa.ensureDir(path.dirname(outputPath)) - - const filename = path.relative(cwd, outputPath) - const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) - const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) - - const { time: elapsed } = await timing.measureTimeAsync(async () => { - const source = await measureAsync('read file', () => fsa.readFile(p, 'utf-8')) - - const transformations = transformationRules.map((rule) => { - const { id, transform } = rule - return (...args: Parameters) => measure(id, () => transform(...args)) - }) - const result = measure('runDefaultTransformation', () => runTransformations({ path: p, source }, transformations)) - - await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) - }) - - if (logLevel !== 'silent') { - const formattedElapsed = (elapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) - console.log(`${c.dim('•')} Transforming ${c.green(path.relative(cwd, outputPath))} ${c.dim(`(${formattedElapsed}ms)`)}`) - } - } -} - -/** - * Check if base path contains target path - */ -function isPathInside(base: string, target: string): boolean { - const relative = path.relative(base, target) - return !relative.startsWith('..') && !path.isAbsolute(relative) -} - -function findCommonBaseDir(paths: string[]): string | null { - if (!paths.length) return null - - const absPaths = paths.map(p => path.resolve(p)) - let commonParts = absPaths[0].split(path.sep) - - for (let i = 1; i < absPaths.length; i++) { - const parts = absPaths[i].split(path.sep) - for (let j = 0; j < commonParts.length; j++) { - if (commonParts[j] !== parts[j]) { - commonParts = commonParts.slice(0, j) - break - } - } - } - - const commonPath = commonParts.join(path.sep) - // if path is not a directory, use its parent directory - return fsa.statSync(commonPath).isDirectory() - ? commonPath - : path.dirname(commonPath) -} +console.warn('@wakaru/unminify CLI is deprecated. Please use "@wakaru/cli" instead.') diff --git a/packages/unpacker/package.json b/packages/unpacker/package.json index 4ce33e9a..ec07ad1f 100644 --- a/packages/unpacker/package.json +++ b/packages/unpacker/package.json @@ -24,16 +24,9 @@ "lint": "eslint src", "lint:fix": "eslint src --fix" }, - "dependencies": { - "fs-extra": "^11.1.1", - "picocolors": "^1.0.0", - "yargs": "^17.7.2" - }, "devDependencies": { "@babel/types": "^7.23.4", - "@types/fs-extra": "^11.0.4", "@types/jscodeshift": "^0.11.11", - "@types/yargs": "^17.0.32", "@wakaru/ast-utils": "workspace:*", "@wakaru/test-utils": "workspace:*", "ast-types": "^0.16.1", diff --git a/packages/unpacker/src/cli.ts b/packages/unpacker/src/cli.ts index d52f43c4..b241aa2d 100644 --- a/packages/unpacker/src/cli.ts +++ b/packages/unpacker/src/cli.ts @@ -1,130 +1,4 @@ #!/usr/bin/env node /* eslint-disable no-console */ -import * as path from 'node:path' -import process, { hrtime } from 'node:process' -import fsa from 'fs-extra' -import * as globby from 'globby' -import c from 'picocolors' -import yargs from 'yargs' -import { hideBin } from 'yargs/helpers' -import { version } from '../package.json' -import { unpack } from './unpack' - -type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'silent' - -// eslint-disable-next-line no-unused-expressions -yargs(hideBin(process.argv)) - .scriptName('@wakaru/unpacker') - - .help() - .showHelpOnFail(true) - .alias('h', 'help') - - .version('version', version) - .alias('v', 'version') - - .option('log-level', { - type: 'string', - default: 'info', - choices: ['error', 'warn', 'info', 'debug', 'silent'], - describe: 'change the level of logging for the CLI.', - }) - - .usage('Usage: $0 [options]') - .command( - '* ', - 'Unminify your bundled code', - args => args - .option('output', { - alias: 'o', - describe: 'specify the output directory (default: out/)', - type: 'string', - default: 'out/', - }) - .option('force', { - alias: 'f', - describe: 'force overwrite output directory', - type: 'boolean', - default: false, - }) - .positional('files', { - describe: 'File paths to process (supports glob patterns)', - type: 'string', - array: true, - }) - .help(), - async (args) => { - await unpacker( - args.files ?? [], - args.output, - args.force, - args.logLevel as LogLevel, - ) - }, - ) - .argv - -async function unpacker( - paths: string[], - output: string, - force: boolean, - logLevel: LogLevel, -) { - const cwd = process.cwd() - const globbyPaths = paths - .map(p => path.normalize(p)) - .map(p => p.replace(/\\/g, '/')) - const resolvedPaths = await globby.default(globbyPaths, { - cwd, - absolute: true, - ignore: [path.join(cwd, '**/node_modules/**')], - }) - - // Check if any paths are outside of the current working directory - for (const p of resolvedPaths) { - if (!isPathInside(cwd, p)) { - throw new Error(`File path ${c.green(path.relative(cwd, p))} is outside of the current working directory. This is not allowed.`) - } - } - - const outputDir = path.resolve(cwd, output) - - if (await fsa.exists(outputDir)) { - if (!force) { - throw new Error(`Output directory already exists at ${c.green(path.relative(cwd, outputDir))}. Pass ${c.yellow('--force')} to overwrite.`) - } - } - await fsa.ensureDir(outputDir) - - for (const p of resolvedPaths) { - const start = hrtime() - - const source = await fsa.readFile(p, 'utf-8') - const { modules, moduleIdMapping } = unpack(source) - - const folder = resolvedPaths.length > 1 ? path.basename(p, path.extname(p)) : '' - const outputFolder = path.join(outputDir, folder) - for (const mod of modules) { - const filename = moduleIdMapping[mod.id] ?? `module-${mod.id}.js` - const outputPath = path.join(outputFolder, filename) - await fsa.ensureDir(path.dirname(outputPath)) - await fsa.writeFile(outputPath, mod.code, 'utf-8') - } - - if (logLevel !== 'silent') { - const end = hrtime(start) - const elapsed = end[0] * 1e9 + end[1] - const formattedElapsed = (elapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) - console.log(`Generated ${c.green(modules.length)} modules from ${c.green(path.relative(cwd, p))} to ${c.green(path.relative(cwd, outputFolder))} ${c.dim(`(${formattedElapsed}ms)`)}`) - } - } -} - -/** - * Check if base path contains target path - */ -function isPathInside(base: string, target: string): boolean { - const relative = path.relative(base, target) - return !relative.startsWith('..') && !path.isAbsolute(relative) -} +console.warn('@wakaru/unpacker CLI is deprecated. Please use "@wakaru/cli" instead.') diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a63a6cd..56883af6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -380,12 +380,6 @@ importers: '@babel/types': specifier: ^7.23.4 version: 7.23.4 - fs-extra: - specifier: ^11.1.1 - version: 11.1.1 - globby: - specifier: ^11.1.0 - version: 11.1.0 lebab: specifier: ^3.2.3 version: 3.2.3 @@ -395,16 +389,10 @@ importers: prettier: specifier: ^2.8.8 version: 2.8.8 - yargs: - specifier: ^17.7.2 - version: 17.7.2 zod: specifier: ^3.22.4 version: 3.22.4 devDependencies: - '@types/fs-extra': - specifier: ^11.0.4 - version: 11.0.4 '@types/jscodeshift': specifier: ^0.11.11 version: 0.11.11 @@ -437,29 +425,13 @@ importers: version: 5.3.2 packages/unpacker: - dependencies: - fs-extra: - specifier: ^11.1.1 - version: 11.1.1 - picocolors: - specifier: ^1.0.0 - version: 1.0.0 - yargs: - specifier: ^17.7.2 - version: 17.7.2 devDependencies: '@babel/types': specifier: ^7.23.4 version: 7.23.4 - '@types/fs-extra': - specifier: ^11.0.4 - version: 11.0.4 '@types/jscodeshift': specifier: ^0.11.11 version: 0.11.11 - '@types/yargs': - specifier: ^17.0.32 - version: 17.0.32 '@wakaru/ast-utils': specifier: workspace:* version: link:../ast-utils From 50472add79320743ea1f0b9c4b789db1d9c53413 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Sun, 10 Dec 2023 23:44:56 +0800 Subject: [PATCH 03/19] chore: pnpm dedupe --- pnpm-lock.yaml | 587 ++----------------------------------------------- 1 file changed, 23 insertions(+), 564 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 56883af6..bf97a722 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -87,7 +87,7 @@ importers: version: 0.16.1(patch_hash=lbcpk3ulhul2sxdbqn4xesbaem) jscodeshift: specifier: ^0.15.1 - version: 0.15.1 + version: 0.15.1(@babel/preset-env@7.23.3) tsup: specifier: ^7.3.0 version: 7.3.0(typescript@5.3.2) @@ -361,7 +361,7 @@ importers: version: 0.11.11 jscodeshift: specifier: ^0.15.1 - version: 0.15.1 + version: 0.15.1(@babel/preset-env@7.23.3) typescript: specifier: ^5.3.2 version: 5.3.2 @@ -443,7 +443,7 @@ importers: version: 0.16.1(patch_hash=lbcpk3ulhul2sxdbqn4xesbaem) jscodeshift: specifier: ^0.15.1 - version: 0.15.1 + version: 0.15.1(@babel/preset-env@7.23.3) tsup: specifier: ^7.3.0 version: 7.3.0(typescript@5.3.2) @@ -508,13 +508,6 @@ packages: fast-deep-equal: 3.1.3 dev: true - /@babel/code-frame@7.22.13: - resolution: {integrity: sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.22.13 - chalk: 2.4.2 - /@babel/code-frame@7.23.4: resolution: {integrity: sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA==} engines: {node: '>=6.9.0'} @@ -522,10 +515,6 @@ packages: '@babel/highlight': 7.23.4 chalk: 2.4.2 - /@babel/compat-data@7.22.20: - resolution: {integrity: sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==} - engines: {node: '>=6.9.0'} - /@babel/compat-data@7.23.3: resolution: {integrity: sha512-BmR4bWbDIoFJmJ9z2cZ8Gmm2MXgEDgjdWgpKmKWUt54UGFJdlj31ECtbaDvCG/qVdG3AQ1SfpZEs01lUFbzLOQ==} engines: {node: '>=6.9.0'} @@ -577,30 +566,12 @@ packages: resolution: {integrity: sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/compat-data': 7.22.20 + '@babel/compat-data': 7.23.3 '@babel/helper-validator-option': 7.22.15 browserslist: 4.22.1 lru-cache: 5.1.1 semver: 6.3.1 - /@babel/helper-create-class-features-plugin@7.22.11(@babel/core@7.23.3): - resolution: {integrity: sha512-y1grdYL4WzmUDBRGK0pDbIoFd7UZKoDurDzWEoNMYoj1EL+foGRQNyPWDcC+YyegN5y1DUsFFmzjGijB3nSVAQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-annotate-as-pure': 7.22.5 - '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-function-name': 7.23.0 - '@babel/helper-member-expression-to-functions': 7.22.5 - '@babel/helper-optimise-call-expression': 7.22.5 - '@babel/helper-replace-supers': 7.22.9(@babel/core@7.23.3) - '@babel/helper-skip-transparent-expression-wrappers': 7.22.5 - '@babel/helper-split-export-declaration': 7.22.6 - semver: 6.3.1 - dev: true - /@babel/helper-create-class-features-plugin@7.22.15(@babel/core@7.23.3): resolution: {integrity: sha512-jKkwA59IXcvSaiK2UN45kKwSC9o+KuoXsBDvHvU/7BecYIp8GQ2UwrVvFgJASUT+hBnwJx6MhvMCuMzwZZ7jlg==} engines: {node: '>=6.9.0'} @@ -613,7 +584,7 @@ packages: '@babel/helper-function-name': 7.23.0 '@babel/helper-member-expression-to-functions': 7.23.0 '@babel/helper-optimise-call-expression': 7.22.5 - '@babel/helper-replace-supers': 7.22.9(@babel/core@7.23.3) + '@babel/helper-replace-supers': 7.22.20(@babel/core@7.23.3) '@babel/helper-skip-transparent-expression-wrappers': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 semver: 6.3.1 @@ -629,17 +600,6 @@ packages: regexpu-core: 5.3.2 semver: 6.3.1 - /@babel/helper-create-regexp-features-plugin@7.22.9(@babel/core@7.23.3): - resolution: {integrity: sha512-+svjVa/tFwsNSG4NEy1h85+HQ5imbT92Q5/bgtS7P0GTQlP8WuFdqsiABmQouhiFGyV66oGxZFpeYHza1rNsKw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-annotate-as-pure': 7.22.5 - regexpu-core: 5.3.2 - semver: 6.3.1 - /@babel/helper-define-polyfill-provider@0.4.3(@babel/core@7.23.3): resolution: {integrity: sha512-WBrLmuPP47n7PNwsZ57pqam6G/RGo1vw/87b0Blc53tZNGZ4x7YvZ6HgQe2vo1W/FR20OgjeZuGXzudPiXHFug==} peerDependencies: @@ -671,12 +631,6 @@ packages: dependencies: '@babel/types': 7.23.4 - /@babel/helper-member-expression-to-functions@7.22.5: - resolution: {integrity: sha512-aBiH1NKMG0H2cGZqspNvsaBe6wNGjbJjuLy29aU+eDZjSbbN53BaxlpB02xm9v34pLTZ1nIQPFYn2qMZoa5BQQ==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.23.4 - /@babel/helper-member-expression-to-functions@7.23.0: resolution: {integrity: sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA==} engines: {node: '>=6.9.0'} @@ -734,17 +688,6 @@ packages: '@babel/helper-member-expression-to-functions': 7.23.0 '@babel/helper-optimise-call-expression': 7.22.5 - /@babel/helper-replace-supers@7.22.9(@babel/core@7.23.3): - resolution: {integrity: sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-member-expression-to-functions': 7.22.5 - '@babel/helper-optimise-call-expression': 7.22.5 - /@babel/helper-simple-access@7.22.5: resolution: {integrity: sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==} engines: {node: '>=6.9.0'} @@ -793,14 +736,6 @@ packages: transitivePeerDependencies: - supports-color - /@babel/highlight@7.22.13: - resolution: {integrity: sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.22.20 - chalk: 2.4.2 - js-tokens: 4.0.0 - /@babel/highlight@7.23.4: resolution: {integrity: sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==} engines: {node: '>=6.9.0'} @@ -809,14 +744,6 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/parser@7.23.0: - resolution: {integrity: sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==} - engines: {node: '>=6.0.0'} - hasBin: true - dependencies: - '@babel/types': 7.23.4 - dev: true - /@babel/parser@7.23.4: resolution: {integrity: sha512-vf3Xna6UEprW+7t6EtOmFpHNAuxw3xqPZghy+brsnusscJRW5BMUzzHZc5ICjULee81WeUV2jjakG09MDglJXQ==} engines: {node: '>=6.0.0'} @@ -1040,7 +967,7 @@ packages: '@babel/core': ^7.0.0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-create-regexp-features-plugin': 7.22.9(@babel/core@7.23.3) + '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) '@babel/helper-plugin-utils': 7.22.5 /@babel/plugin-transform-arrow-functions@7.23.3(@babel/core@7.23.3): @@ -1093,17 +1020,6 @@ packages: '@babel/core': 7.23.3 '@babel/helper-plugin-utils': 7.22.5 - /@babel/plugin-transform-class-properties@7.22.5(@babel/core@7.23.3): - resolution: {integrity: sha512-nDkQ0NfkOhPTq8YCLiWNxp1+f9fCobEjCb0n8WdbNUBc4IB5V7P1QnX9IjpSoquKrXF5SKojHleVNs2vGeHCHQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-create-class-features-plugin': 7.22.11(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 - dev: true - /@babel/plugin-transform-class-properties@7.23.3(@babel/core@7.23.3): resolution: {integrity: sha512-uM+AN8yCIjDPccsKGlw271xjJtGii+xQIF/uMPS8H15L12jZTsLfF4o5vNO7d/oUguOyfdikHGc/yi9ge4SGIg==} engines: {node: '>=6.9.0'} @@ -1329,7 +1245,7 @@ packages: '@babel/core': ^7.0.0 dependencies: '@babel/core': 7.23.3 - '@babel/helper-create-regexp-features-plugin': 7.22.9(@babel/core@7.23.3) + '@babel/helper-create-regexp-features-plugin': 7.22.15(@babel/core@7.23.3) '@babel/helper-plugin-utils': 7.22.5 /@babel/plugin-transform-new-target@7.23.3(@babel/core@7.23.3): @@ -1341,17 +1257,6 @@ packages: '@babel/core': 7.23.3 '@babel/helper-plugin-utils': 7.22.5 - /@babel/plugin-transform-nullish-coalescing-operator@7.22.11(@babel/core@7.23.3): - resolution: {integrity: sha512-YZWOw4HxXrotb5xsjMJUDlLgcDXSfO9eCmdl1bgW4+/lAGdkjaEvOnQ4p5WKKdUgSzO39dgPl0pTnfxm0OAXcg==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 - '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.23.3) - dev: true - /@babel/plugin-transform-nullish-coalescing-operator@7.23.4(@babel/core@7.23.3): resolution: {integrity: sha512-jHE9EVVqHKAQx+VePv5LLGHjmHSJR76vawFPTdlxR/LVJPfOEGxREQwQfjuZEOPTwG92X3LINSh3M40Rv4zpVA==} engines: {node: '>=6.9.0'} @@ -1425,17 +1330,6 @@ packages: '@babel/core': 7.23.3 '@babel/helper-plugin-utils': 7.22.5 - /@babel/plugin-transform-private-methods@7.22.5(@babel/core@7.23.3): - resolution: {integrity: sha512-PPjh4gyrQnGe97JTalgRGMuU4icsZFnWkzicB/fUtzlKUqvsWBKEpPPfr5a2JiyirZkHxnAqkQMO5Z5B2kK3fA==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-create-class-features-plugin': 7.22.11(@babel/core@7.23.3) - '@babel/helper-plugin-utils': 7.22.5 - dev: true - /@babel/plugin-transform-private-methods@7.23.3(@babel/core@7.23.3): resolution: {integrity: sha512-UzqRcRtWsDMTLrRWFvUBDwmw06tCQH9Rl1uAjfh6ijMSmGYQ+fpdB+cnqRC8EMh5tuuxSv0/TejGL+7vyj+50g==} engines: {node: '>=6.9.0'} @@ -1689,7 +1583,7 @@ packages: babel-plugin-polyfill-corejs2: 0.4.6(@babel/core@7.23.3) babel-plugin-polyfill-corejs3: 0.8.6(@babel/core@7.23.3) babel-plugin-polyfill-regenerator: 0.5.3(@babel/core@7.23.3) - core-js-compat: 3.31.1 + core-js-compat: 3.33.3 semver: 6.3.1 transitivePeerDependencies: - supports-color @@ -1757,7 +1651,7 @@ packages: resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/code-frame': 7.22.13 + '@babel/code-frame': 7.23.4 '@babel/parser': 7.23.4 '@babel/types': 7.23.4 @@ -1905,7 +1799,7 @@ packages: resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} dependencies: '@esbuild-kit/core-utils': 3.1.0 - get-tsconfig: 4.6.2 + get-tsconfig: 4.7.2 dev: true /@esbuild-kit/core-utils@3.1.0: @@ -1919,7 +1813,7 @@ packages: resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==} dependencies: '@esbuild-kit/core-utils': 3.1.0 - get-tsconfig: 4.6.2 + get-tsconfig: 4.7.2 dev: true /@esbuild/android-arm64@0.17.19: @@ -1931,15 +1825,6 @@ packages: dev: true optional: true - /@esbuild/android-arm64@0.18.15: - resolution: {integrity: sha512-NI/gnWcMl2kXt1HJKOn2H69SYn4YNheKo6NZt1hyfKWdMbaGadxjZIkcj4Gjk/WPxnbFXs9/3HjGHaknCqjrww==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - /@esbuild/android-arm64@0.18.20: resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} @@ -1966,15 +1851,6 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.18.15: - resolution: {integrity: sha512-wlkQBWb79/jeEEoRmrxt/yhn5T1lU236OCNpnfRzaCJHZ/5gf82uYx1qmADTBWE0AR/v7FiozE1auk2riyQd3w==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - /@esbuild/android-arm@0.18.20: resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} engines: {node: '>=12'} @@ -2001,15 +1877,6 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.18.15: - resolution: {integrity: sha512-FM9NQamSaEm/IZIhegF76aiLnng1kEsZl2eve/emxDeReVfRuRNmvT28l6hoFD9TsCxpK+i4v8LPpEj74T7yjA==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: true - optional: true - /@esbuild/android-x64@0.18.20: resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} engines: {node: '>=12'} @@ -2036,15 +1903,6 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.18.15: - resolution: {integrity: sha512-XmrFwEOYauKte9QjS6hz60FpOCnw4zaPAb7XV7O4lx1r39XjJhTN7ZpXqJh4sN6q60zbP6QwAVVA8N/wUyBH/w==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /@esbuild/darwin-arm64@0.18.20: resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} engines: {node: '>=12'} @@ -2071,15 +1929,6 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.18.15: - resolution: {integrity: sha512-bMqBmpw1e//7Fh5GLetSZaeo9zSC4/CMtrVFdj+bqKPGJuKyfNJ5Nf2m3LknKZTS+Q4oyPiON+v3eaJ59sLB5A==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /@esbuild/darwin-x64@0.18.20: resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} engines: {node: '>=12'} @@ -2106,15 +1955,6 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.18.15: - resolution: {integrity: sha512-LoTK5N3bOmNI9zVLCeTgnk5Rk0WdUTrr9dyDAQGVMrNTh9EAPuNwSTCgaKOKiDpverOa0htPcO9NwslSE5xuLA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/freebsd-arm64@0.18.20: resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} engines: {node: '>=12'} @@ -2141,15 +1981,6 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.18.15: - resolution: {integrity: sha512-62jX5n30VzgrjAjOk5orYeHFq6sqjvsIj1QesXvn5OZtdt5Gdj0vUNJy9NIpjfdNdqr76jjtzBJKf+h2uzYuTQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/freebsd-x64@0.18.20: resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} engines: {node: '>=12'} @@ -2176,15 +2007,6 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.18.15: - resolution: {integrity: sha512-BWncQeuWDgYv0jTNzJjaNgleduV4tMbQjmk/zpPh/lUdMcNEAxy+jvneDJ6RJkrqloG7tB9S9rCrtfk/kuplsQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-arm64@0.18.20: resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} engines: {node: '>=12'} @@ -2211,15 +2033,6 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.18.15: - resolution: {integrity: sha512-dT4URUv6ir45ZkBqhwZwyFV6cH61k8MttIwhThp2BGiVtagYvCToF+Bggyx2VI57RG4Fbt21f9TmXaYx0DeUJg==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-arm@0.18.20: resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} engines: {node: '>=12'} @@ -2246,15 +2059,6 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.18.15: - resolution: {integrity: sha512-JPXORvgHRHITqfms1dWT/GbEY89u848dC08o0yK3fNskhp0t2TuNUnsrrSgOdH28ceb1hJuwyr8R/1RnyPwocw==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-ia32@0.18.20: resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} engines: {node: '>=12'} @@ -2281,15 +2085,6 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.18.15: - resolution: {integrity: sha512-kArPI0DopjJCEplsVj/H+2Qgzz7vdFSacHNsgoAKpPS6W/Ndh8Oe24HRDQ5QCu4jHgN6XOtfFfLpRx3TXv/mEg==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-loong64@0.18.20: resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} engines: {node: '>=12'} @@ -2316,15 +2111,6 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.18.15: - resolution: {integrity: sha512-b/tmngUfO02E00c1XnNTw/0DmloKjb6XQeqxaYuzGwHe0fHVgx5/D6CWi+XH1DvkszjBUkK9BX7n1ARTOst59w==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-mips64el@0.18.20: resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} engines: {node: '>=12'} @@ -2351,15 +2137,6 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.18.15: - resolution: {integrity: sha512-KXPY69MWw79QJkyvUYb2ex/OgnN/8N/Aw5UDPlgoRtoEfcBqfeLodPr42UojV3NdkoO4u10NXQdamWm1YEzSKw==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-ppc64@0.18.20: resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} engines: {node: '>=12'} @@ -2386,15 +2163,6 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.18.15: - resolution: {integrity: sha512-komK3NEAeeGRnvFEjX1SfVg6EmkfIi5aKzevdvJqMydYr9N+pRQK0PGJXk+bhoPZwOUgLO4l99FZmLGk/L1jWg==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-riscv64@0.18.20: resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} engines: {node: '>=12'} @@ -2421,15 +2189,6 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.18.15: - resolution: {integrity: sha512-632T5Ts6gQ2WiMLWRRyeflPAm44u2E/s/TJvn+BP6M5mnHSk93cieaypj3VSMYO2ePTCRqAFXtuYi1yv8uZJNA==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-s390x@0.18.20: resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} engines: {node: '>=12'} @@ -2456,15 +2215,6 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.18.15: - resolution: {integrity: sha512-MsHtX0NgvRHsoOtYkuxyk4Vkmvk3PLRWfA4okK7c+6dT0Fu4SUqXAr9y4Q3d8vUf1VWWb6YutpL4XNe400iQ1g==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-x64@0.18.20: resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} engines: {node: '>=12'} @@ -2491,15 +2241,6 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.18.15: - resolution: {integrity: sha512-djST6s+jQiwxMIVQ5rlt24JFIAr4uwUnzceuFL7BQT4CbrRtqBPueS4GjXSiIpmwVri1Icj/9pFRJ7/aScvT+A==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/netbsd-x64@0.18.20: resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} engines: {node: '>=12'} @@ -2526,15 +2267,6 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.18.15: - resolution: {integrity: sha512-naeRhUIvhsgeounjkF5mvrNAVMGAm6EJWiabskeE5yOeBbLp7T89tAEw0j5Jm/CZAwyLe3c67zyCWH6fsBLCpw==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - /@esbuild/openbsd-x64@0.18.20: resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} engines: {node: '>=12'} @@ -2561,15 +2293,6 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.18.15: - resolution: {integrity: sha512-qkT2+WxyKbNIKV1AEhI8QiSIgTHMcRctzSaa/I3kVgMS5dl3fOeoqkb7pW76KwxHoriImhx7Mg3TwN/auMDsyQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - /@esbuild/sunos-x64@0.18.20: resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} engines: {node: '>=12'} @@ -2596,15 +2319,6 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.18.15: - resolution: {integrity: sha512-HC4/feP+pB2Vb+cMPUjAnFyERs+HJN7E6KaeBlFdBv799MhD+aPJlfi/yk36SED58J9TPwI8MAcVpJgej4ud0A==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@esbuild/win32-arm64@0.18.20: resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} engines: {node: '>=12'} @@ -2631,15 +2345,6 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.18.15: - resolution: {integrity: sha512-ovjwoRXI+gf52EVF60u9sSDj7myPixPxqzD5CmkEUmvs+W9Xd0iqISVBQn8xcx4ciIaIVlWCuTbYDOXOnOL44Q==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@esbuild/win32-ia32@0.18.20: resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} engines: {node: '>=12'} @@ -2666,15 +2371,6 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.18.15: - resolution: {integrity: sha512-imUxH9a3WJARyAvrG7srLyiK73XdX83NXQkjKvQ+7vPh3ZxoLrzvPkQKKw2DwZ+RV2ZB6vBfNHP8XScAmQC3aA==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@esbuild/win32-x64@0.18.20: resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} engines: {node: '>=12'} @@ -4206,14 +3902,6 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false - /@rollup/rollup-android-arm-eabi@4.1.4: - resolution: {integrity: sha512-WlzkuFvpKl6CLFdc3V6ESPt7gq5Vrimd2Yv9IzKXdOpgbH4cdDSS1JLiACX8toygihtH5OlxyQzhXOph7Ovlpw==} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-android-arm-eabi@4.5.2: resolution: {integrity: sha512-ee7BudTwwrglFYSc3UnqInDDjCLWHKrFmGNi4aK7jlEyg4CyPa1DCMrZfsN1O13YT76UFEqXz2CoN7BCGpUlJw==} cpu: [arm] @@ -4221,14 +3909,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-android-arm64@4.1.4: - resolution: {integrity: sha512-D1e+ABe56T9Pq2fD+R3ybe1ylCDzu3tY4Qm2Mj24R9wXNCq35+JbFbOpc2yrroO2/tGhTobmEl2Bm5xfE/n8RA==} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-android-arm64@4.5.2: resolution: {integrity: sha512-xOuhj9HHtn8128ir8veoQsBbAUBasDbHIBniYTEx02pAmu9EXL+ZjJqngnNEy6ZgZ4h1JwL33GMNu3yJL5Mzow==} cpu: [arm64] @@ -4236,14 +3916,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-darwin-arm64@4.1.4: - resolution: {integrity: sha512-7vTYrgEiOrjxnjsgdPB+4i7EMxbVp7XXtS+50GJYj695xYTTEMn3HZVEvgtwjOUkAP/Q4HDejm4fIAjLeAfhtg==} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-darwin-arm64@4.5.2: resolution: {integrity: sha512-NTGJWoL8bKyqyWFn9/RzSv4hQ4wTbaAv0lHHRwf4OnpiiP4P8W0jiXbm8Nc5BCXKmWAwuvJY82mcIU2TayC20g==} cpu: [arm64] @@ -4251,14 +3923,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-darwin-x64@4.1.4: - resolution: {integrity: sha512-eGJVZScKSLZkYjhTAESCtbyTBq9SXeW9+TX36ki5gVhDqJtnQ5k0f9F44jNK5RhAMgIj0Ht9+n6HAgH0gUUyWQ==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-darwin-x64@4.5.2: resolution: {integrity: sha512-hlKqj7bpPvU15sZo4za14u185lpMzdwWLMc9raMqPK4wywt0wR23y1CaVQ4oAFXat3b5/gmRntyfpwWTKl+vvA==} cpu: [x64] @@ -4266,14 +3930,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.1.4: - resolution: {integrity: sha512-HnigYSEg2hOdX1meROecbk++z1nVJDpEofw9V2oWKqOWzTJlJf1UXVbDE6Hg30CapJxZu5ga4fdAQc/gODDkKg==} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.5.2: resolution: {integrity: sha512-7ZIZx8c3u+pfI0ohQsft/GywrXez0uR6dUP0JhBuCK3sFO5TfdLn/YApnVkvPxuTv3+YKPIZend9Mt7Cz6sS3Q==} cpu: [arm] @@ -4281,14 +3937,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.1.4: - resolution: {integrity: sha512-TzJ+N2EoTLWkaClV2CUhBlj6ljXofaYzF/R9HXqQ3JCMnCHQZmQnbnZllw7yTDp0OG5whP4gIPozR4QiX+00MQ==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-arm64-gnu@4.5.2: resolution: {integrity: sha512-7Pk/5mO11JW/cH+a8lL/i0ZxmRGrbpYqN0VwO2DHhU+SJWWOH2zE1RAcPaj8KqiwC8DCDIJOSxjV9+9lLb6aeA==} cpu: [arm64] @@ -4296,14 +3944,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-arm64-musl@4.1.4: - resolution: {integrity: sha512-aVPmNMdp6Dlo2tWkAduAD/5TL/NT5uor290YvjvFvCv0Q3L7tVdlD8MOGDL+oRSw5XKXKAsDzHhUOPUNPRHVTQ==} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-arm64-musl@4.5.2: resolution: {integrity: sha512-KrRnuG5phJx756e62wxvWH2e+TK84MP2IVuPwfge+GBvWqIUfVzFRn09TKruuQBXzZp52Vyma7FjMDkwlA9xpg==} cpu: [arm64] @@ -4311,14 +3951,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-x64-gnu@4.1.4: - resolution: {integrity: sha512-77Fb79ayiDad0grvVsz4/OB55wJRyw9Ao+GdOBA9XywtHpuq5iRbVyHToGxWquYWlEf6WHFQQnFEttsAzboyKg==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-x64-gnu@4.5.2: resolution: {integrity: sha512-My+53GasPa2D2tU5dXiyHYwrELAUouSfkNlZ3bUKpI7btaztO5vpALEs3mvFjM7aKTvEbc7GQckuXeXIDKQ0fg==} cpu: [x64] @@ -4326,14 +3958,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-linux-x64-musl@4.1.4: - resolution: {integrity: sha512-/t6C6niEQTqmQTVTD9TDwUzxG91Mlk69/v0qodIPUnjjB3wR4UA3klg+orR2SU3Ux2Cgf2pWPL9utK80/1ek8g==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-linux-x64-musl@4.5.2: resolution: {integrity: sha512-/f0Q6Sc+Vw54Ws6N8fxaEe4R7at3b8pFyv+O/F2VaQ4hODUJcRUcCBJh6zuqtgQQt7w845VTkGLFgWZkP3tUoQ==} cpu: [x64] @@ -4341,14 +3965,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.1.4: - resolution: {integrity: sha512-ZY5BHHrOPkMbCuGWFNpJH0t18D2LU6GMYKGaqaWTQ3CQOL57Fem4zE941/Ek5pIsVt70HyDXssVEFQXlITI5Gg==} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-win32-arm64-msvc@4.5.2: resolution: {integrity: sha512-NCKuuZWLht6zj7s6EIFef4BxCRX1GMr83S2W4HPCA0RnJ4iHE4FS1695q6Ewoa6A9nFjJe1//yUu0kgBU07Edw==} cpu: [arm64] @@ -4356,14 +3972,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.1.4: - resolution: {integrity: sha512-XG2mcRfFrJvYyYaQmvCIvgfkaGinfXrpkBuIbJrTl9SaIQ8HumheWTIwkNz2mktCKwZfXHQNpO7RgXLIGQ7HXA==} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-win32-ia32-msvc@4.5.2: resolution: {integrity: sha512-J5zL3riR4AOyU/J3M/i4k/zZ8eP1yT+nTmAKztCXJtnI36jYH0eepvob22mAQ/kLwfsK2TB6dbyVY1F8c/0H5A==} cpu: [ia32] @@ -4371,14 +3979,6 @@ packages: requiresBuild: true optional: true - /@rollup/rollup-win32-x64-msvc@4.1.4: - resolution: {integrity: sha512-ANFqWYPwkhIqPmXw8vm0GpBEHiPpqcm99jiiAp71DbCSqLDhrtr019C5vhD0Bw4My+LmMvciZq6IsWHqQpl2ZQ==} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@rollup/rollup-win32-x64-msvc@4.5.2: resolution: {integrity: sha512-pL0RXRHuuGLhvs7ayX/SAHph1hrDPXOM5anyYUQXWJEENxw3nfHkzv8FfVlEVcLyKPAEgDRkd6RKZq2SMqS/yg==} cpu: [x64] @@ -4486,7 +4086,7 @@ packages: /@types/babel__core@7.20.5: resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} dependencies: - '@babel/parser': 7.23.0 + '@babel/parser': 7.23.4 '@babel/types': 7.23.4 '@types/babel__generator': 7.6.6 '@types/babel__template': 7.4.3 @@ -4772,9 +4372,9 @@ packages: istanbul-lib-report: 3.0.1 istanbul-lib-source-maps: 4.0.1 istanbul-reports: 3.1.6 - magic-string: 0.30.2 + magic-string: 0.30.5 picocolors: 1.0.0 - std-env: 3.3.3 + std-env: 3.5.0 test-exclude: 6.0.0 v8-to-istanbul: 9.1.3 vitest: 1.0.0-beta.5(@types/node@18.18.13)(@vitest/ui@1.0.1) @@ -5681,11 +5281,6 @@ packages: /convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} - /core-js-compat@3.31.1: - resolution: {integrity: sha512-wIDWd2s5/5aJSdpOJHfSibxNODxoGoWOBHt8JSPB41NOE94M7kuTPZCYLOlTtuoXTsBPKobpJ6T+y0SSy5L9SA==} - dependencies: - browserslist: 4.22.1 - /core-js-compat@3.33.3: resolution: {integrity: sha512-cNzGqFsh3Ot+529GIXacjTJ7kegdt5fPXxCBVS1G0iaZpuo/tBz399ymceLJveQhFFZ8qThHiP3fzuoQjKN2ow==} dependencies: @@ -5981,36 +5576,6 @@ packages: '@esbuild/win32-x64': 0.17.19 dev: true - /esbuild@0.18.15: - resolution: {integrity: sha512-3WOOLhrvuTGPRzQPU6waSDWrDTnQriia72McWcn6UCi43GhCHrXH4S59hKMeez+IITmdUuUyvbU9JIp+t3xlPQ==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - optionalDependencies: - '@esbuild/android-arm': 0.18.15 - '@esbuild/android-arm64': 0.18.15 - '@esbuild/android-x64': 0.18.15 - '@esbuild/darwin-arm64': 0.18.15 - '@esbuild/darwin-x64': 0.18.15 - '@esbuild/freebsd-arm64': 0.18.15 - '@esbuild/freebsd-x64': 0.18.15 - '@esbuild/linux-arm': 0.18.15 - '@esbuild/linux-arm64': 0.18.15 - '@esbuild/linux-ia32': 0.18.15 - '@esbuild/linux-loong64': 0.18.15 - '@esbuild/linux-mips64el': 0.18.15 - '@esbuild/linux-ppc64': 0.18.15 - '@esbuild/linux-riscv64': 0.18.15 - '@esbuild/linux-s390x': 0.18.15 - '@esbuild/linux-x64': 0.18.15 - '@esbuild/netbsd-x64': 0.18.15 - '@esbuild/openbsd-x64': 0.18.15 - '@esbuild/sunos-x64': 0.18.15 - '@esbuild/win32-arm64': 0.18.15 - '@esbuild/win32-ia32': 0.18.15 - '@esbuild/win32-x64': 0.18.15 - dev: true - /esbuild@0.18.20: resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} engines: {node: '>=12'} @@ -6550,17 +6115,6 @@ packages: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true - /fast-glob@3.3.0: - resolution: {integrity: sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==} - engines: {node: '>=8.6.0'} - dependencies: - '@nodelib/fs.stat': 2.0.5 - '@nodelib/fs.walk': 1.2.8 - glob-parent: 5.1.2 - merge2: 1.4.1 - micromatch: 4.0.5 - dev: true - /fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} @@ -6636,14 +6190,10 @@ packages: resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==} engines: {node: ^10.12.0 || >=12.0.0} dependencies: - flatted: 3.2.7 + flatted: 3.2.9 rimraf: 3.0.2 dev: true - /flatted@3.2.7: - resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} - dev: true - /flatted@3.2.9: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} @@ -6783,12 +6333,6 @@ packages: get-intrinsic: 1.2.1 dev: true - /get-tsconfig@4.6.2: - resolution: {integrity: sha512-E5XrT4CbbXcXWy+1jChlZmrmCwd5KGx502kDCXJJ7y898TtWW9FwoG5HfOLVRKmlmDGkWN2HM9Ho+/Y8F0sJDg==} - dependencies: - resolve-pkg-maps: 1.0.0 - dev: true - /get-tsconfig@4.7.2: resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} dependencies: @@ -6816,7 +6360,7 @@ packages: foreground-child: 3.1.1 jackspeak: 2.3.1 minimatch: 9.0.3 - minipass: 7.0.2 + minipass: 7.0.4 path-scurry: 1.10.1 /glob@7.1.6: @@ -7420,39 +6964,6 @@ packages: argparse: 2.0.1 dev: true - /jscodeshift@0.15.1: - resolution: {integrity: sha512-hIJfxUy8Rt4HkJn/zZPU9ChKfKZM1342waJ1QC2e2YsPcWhM+3BJ4dcfQCzArTrk1jJeNLB341H+qOcEHRxJZg==} - hasBin: true - peerDependencies: - '@babel/preset-env': ^7.1.6 - peerDependenciesMeta: - '@babel/preset-env': - optional: true - dependencies: - '@babel/core': 7.23.3 - '@babel/parser': 7.23.0 - '@babel/plugin-transform-class-properties': 7.22.5(@babel/core@7.23.3) - '@babel/plugin-transform-modules-commonjs': 7.23.3(@babel/core@7.23.3) - '@babel/plugin-transform-nullish-coalescing-operator': 7.22.11(@babel/core@7.23.3) - '@babel/plugin-transform-optional-chaining': 7.23.4(@babel/core@7.23.3) - '@babel/plugin-transform-private-methods': 7.22.5(@babel/core@7.23.3) - '@babel/preset-flow': 7.23.3(@babel/core@7.23.3) - '@babel/preset-typescript': 7.23.3(@babel/core@7.23.3) - '@babel/register': 7.22.15(@babel/core@7.23.3) - babel-core: 7.0.0-bridge.0(@babel/core@7.23.3) - chalk: 4.1.2 - flow-parser: 0.212.0 - graceful-fs: 4.2.11 - micromatch: 4.0.5 - neo-async: 2.6.2 - node-dir: 0.1.17 - recast: 0.23.4 - temp: 0.8.4 - write-file-atomic: 2.4.3 - transitivePeerDependencies: - - supports-color - dev: true - /jscodeshift@0.15.1(@babel/preset-env@7.23.3): resolution: {integrity: sha512-hIJfxUy8Rt4HkJn/zZPU9ChKfKZM1342waJ1QC2e2YsPcWhM+3BJ4dcfQCzArTrk1jJeNLB341H+qOcEHRxJZg==} hasBin: true @@ -7695,14 +7206,9 @@ packages: dependencies: get-func-name: 2.0.2 - /lru-cache@10.0.0: - resolution: {integrity: sha512-svTf/fzsKHffP42sujkO/Rjs37BCIsQVRCeNYIm9WN8rgT7ffoUnRtZCqU+6BqcSBdv8gwJeTz8knJpgACeQMw==} - engines: {node: 14 || >=16.14} - /lru-cache@10.0.1: resolution: {integrity: sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==} engines: {node: 14 || >=16.14} - dev: true /lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -7727,13 +7233,6 @@ packages: sourcemap-codec: 1.4.8 dev: true - /magic-string@0.30.2: - resolution: {integrity: sha512-lNZdu7pewtq/ZvWUp9Wpf/x7WzMTsR26TWV03BRZrXFsv+BI6dy8RAiKgm1uM/kyR0rCfUcqvOlXKG66KhIGug==} - engines: {node: '>=12'} - dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 - dev: true - /magic-string@0.30.5: resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==} engines: {node: '>=12'} @@ -7920,14 +7419,9 @@ packages: engines: {node: '>=8'} dev: true - /minipass@7.0.2: - resolution: {integrity: sha512-eL79dXrE1q9dBbDCLg7xfn/vl7MS4F1gvJAgjJrQli/jbQWdUttuVawphqpffoIYfRdq78LHx6GP4bU/EQ2ATA==} - engines: {node: '>=16 || 14 >=14.17'} - /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} engines: {node: '>=16 || 14 >=14.17'} - dev: true /minizlib@2.1.2: resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} @@ -7947,14 +7441,6 @@ packages: hasBin: true dev: true - /mlly@1.4.0: - resolution: {integrity: sha512-ua8PAThnTwpprIaU47EPeZ/bPUVp2QYBbWMphUQpVdBI3Lgqzm5KZQ45Agm3YJedHXaIHl6pBGabaLSUPPSptg==} - dependencies: - acorn: 8.10.0 - pathe: 1.1.1 - pkg-types: 1.0.3 - ufo: 1.1.2 - /mlly@1.4.2: resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} dependencies: @@ -8392,7 +7878,7 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} dependencies: - '@babel/code-frame': 7.22.13 + '@babel/code-frame': 7.23.4 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -8432,8 +7918,8 @@ packages: resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==} engines: {node: '>=16 || 14 >=14.17'} dependencies: - lru-cache: 10.0.0 - minipass: 7.0.2 + lru-cache: 10.0.1 + minipass: 7.0.4 /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} @@ -8478,7 +7964,7 @@ packages: resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} dependencies: jsonc-parser: 3.2.0 - mlly: 1.4.0 + mlly: 1.4.2 pathe: 1.1.1 /platform@1.3.6: @@ -8953,26 +8439,6 @@ packages: fsevents: 2.3.3 dev: true - /rollup@4.1.4: - resolution: {integrity: sha512-U8Yk1lQRKqCkDBip/pMYT+IKaN7b7UesK3fLSTuHBoBJacCE+oBqo/dfG/gkUdQNNB2OBmRP98cn2C2bkYZkyw==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.1.4 - '@rollup/rollup-android-arm64': 4.1.4 - '@rollup/rollup-darwin-arm64': 4.1.4 - '@rollup/rollup-darwin-x64': 4.1.4 - '@rollup/rollup-linux-arm-gnueabihf': 4.1.4 - '@rollup/rollup-linux-arm64-gnu': 4.1.4 - '@rollup/rollup-linux-arm64-musl': 4.1.4 - '@rollup/rollup-linux-x64-gnu': 4.1.4 - '@rollup/rollup-linux-x64-musl': 4.1.4 - '@rollup/rollup-win32-arm64-msvc': 4.1.4 - '@rollup/rollup-win32-ia32-msvc': 4.1.4 - '@rollup/rollup-win32-x64-msvc': 4.1.4 - fsevents: 2.3.3 - dev: true - /rollup@4.5.2: resolution: {integrity: sha512-CRK1uoROBfkcqrZKyaFcqCcZWNsvJ6yVYZkqTlRocZhO2s5yER6Z3f/QaYtO8RGyloPnmhwgzuPQpNGeK210xQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -9245,10 +8711,6 @@ packages: resolution: {integrity: sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==} dev: false - /std-env@3.3.3: - resolution: {integrity: sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==} - dev: true - /std-env@3.5.0: resolution: {integrity: sha512-JGUEaALvL0Mf6JCfYnJOTcobY+Nc7sG/TemDRBqCA0wEr4DER7zDchaaixTlmOxAjG1uRJmX82EQcxwTQTkqVA==} @@ -9400,7 +8862,7 @@ packages: chokidar: 3.5.3 didyoumean: 1.2.2 dlv: 1.1.3 - fast-glob: 3.3.0 + fast-glob: 3.3.2 glob-parent: 6.0.2 is-glob: 4.0.3 jiti: 1.20.0 @@ -9566,7 +9028,7 @@ packages: joycon: 3.1.1 postcss-load-config: 4.0.1(postcss@8.4.31) resolve-from: 5.0.0 - rollup: 4.1.4 + rollup: 4.5.2 source-map: 0.8.0-beta.0 sucrase: 3.34.0 tree-kill: 1.2.2 @@ -9743,9 +9205,6 @@ packages: engines: {node: '>=14.17'} hasBin: true - /ufo@1.1.2: - resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} - /ufo@1.3.1: resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} @@ -9945,7 +9404,7 @@ packages: optional: true dependencies: '@types/node': 18.18.13 - esbuild: 0.18.15 + esbuild: 0.18.20 postcss: 8.4.31 rollup: 3.28.0 optionalDependencies: From beaf422dc890f6d51073f1b32a401a7b4167f17a Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Tue, 12 Dec 2023 02:10:17 +0800 Subject: [PATCH 04/19] feat: support non-interative mode --- README.md | 92 +++++++-- packages/cli/src/cli.ts | 445 +++++++++++++++++++++++++++++++++------- 2 files changed, 442 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 6bd9f101..53584f99 100644 --- a/README.md +++ b/README.md @@ -45,35 +45,89 @@ Test the tool and see it in action at [Playground][Playground]. ## 🖥 Using the CLI -``` -npx @wakaru/unpacker [options] -# or -pnpm dlx @wakaru/unpacker [options] -``` +### Interactive mode -For example: +By default, the CLI will run in interactive mode and guide you through the process.\ +You can also pass options to skip some steps in the interactive mode. -``` -npx @wakaru/unpacker input.js # unpack bundled code into multiple files -cd ./out # go to the output directory -npx @wakaru/unminify ./ # unminify all files in the directory +```sh +npx @wakaru/cli +# or +pnpm dlx @wakaru/cli ``` -Files can also be specified as glob patterns. For example: +
+ Expand to see the example output ```sh -npx @wakaru/unminify ./src/**/*.js +┌ Wakaru CLI +│ +◇ Select features to use (Use to select, to submit) +│ Unpacker, Unminify +│ +└ Selected features: Unpacker, Unminify + +┌ Unpacker +│ +◇ Input file path (Supports glob patterns) +│ ./input.js +│ +◇ Output directory path ( to accept default) +│ ./out +│ +◇ Unpacking... +│ +◇ Finished +│ +◆ Successfully generated 33 modules (0ms) +│ +└ Output directory: .\out\unpack + +┌ Unminify +│ +◇ Unminifying... +│ +◇ Finished +│ +◆ Successfully unminified 33 files +│ +└ Output directory: .\out\unminify ``` +
+ ### Options -| Option | Default | Description | -| ---------- | ------- | -------------------------------- | -| `--output` | `./out` | Output directory | -| `--force` | `false` | Force overwrite output directory | -| `--log-level` | `info` | Log level (`error`, `warn`, `info`, `debug`, `silent`) | +Run `npx @wakaru/cli --help` to see the full list of options. + +| Option | Default | Description | +| --------------- | ------- | ---------------------------------- | +| `--output` | `"out"` | Output directory | +| `--force` | `false` | Force overwrite output directory | +| `--concurrency` | `1` | Maximum number of concurrent tasks | +| `--perf` | `false` | Show performance metrics | + +### Non-interactive mode + +If you want to run the CLI in non-interactive mode, you can specify the feature by passing the feature name as the first argument. + +`unpacker` and `unminify` will run only the corresponding feature.\ +`all` will run both `unpacker` and `unminify` sequentially. + +``` +npx @wakaru/cli all [options] +npx @wakaru/cli unpacker [options] +npx @wakaru/cli unminify [options] +``` + +These options are **only** available in `all` mode. + +| Option | Default | Description | +| ------------------- | -------------- | ---------------------------------- | +| `--unpacker-output` | `"out/unpack"` | Override unpacker output directory | +| `--unminify-output` | `"out/unminify"` | Override unminify output directory | -Note: Currently, the log level is not very accurate. It might still print some logs even if `silent` is specified. This will be improved in the future release. +When running a single feature (either `unpacker` or `unminify`), the CLI will only uses the path specified in the `--output` option. This means that, unlike in the `all` mode where subdirectories (`out/unpack` and `out/unminify`) are automatically created within the output directory, in single feature mode, the output files are placed directly in the specified `--output` directory without any additional subdirectories. ## 📦 Using the API @@ -121,7 +175,7 @@ You can check all the rules at [/unminify/src/transformations/index.ts](https:// Please aware that this project is still in early development. The API might change in the future. -And the bundle size of these packages are huge. It might be reduced in the future. Use with caution on the browser (Yes, like the playground, it can run on the browser). +And the bundle size of these packages are huge. It might be reduced in the future. Use with caution on the browser (Yes, like the playground, it can run on the browser ✨). ## Legal Disclaimer diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index db36aae8..60047a94 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -16,6 +16,8 @@ import { } from '@clack/prompts' import fsa from 'fs-extra' import c from 'picocolors' +import yargs from 'yargs' +import { hideBin } from 'yargs/helpers' import { version } from '../package.json' import { Concurrency } from './concurrency' import { findCommonBaseDir, getRelativePath, isPathInside, resolveGlob } from './path' @@ -27,17 +29,153 @@ enum Feature { Unminify = 'Unminify', } -async function main() { - const cwd = process.cwd() +const defaultOutputBase = './out/' +const defaultUnpackerOutputFolder = 'unpack' +const defaultUnminifyOutputFolder = 'unminify' + +// eslint-disable-next-line no-unused-expressions +yargs(hideBin(process.argv)) + .scriptName('@wakaru/cli') + + .help() + .showHelpOnFail(true) + .alias('h', 'help') + .version('version', version) + .alias('v', 'version') + + .option('output', { + alias: 'o', + describe: 'Specify the output directory (default: out/)', + type: 'string', + }) + .option('unpacker-output', { + describe: 'Override the output directory for unpacker (default: out/unpack/)', + type: 'string', + }) + .option('unminify-output', { + describe: 'Override the output directory for unminify (default: out/unminify/)', + type: 'string', + }) + .option('force', { + alias: 'f', + describe: 'Force overwrite output directory', + type: 'boolean', + }) + .option('concurrency', { + describe: 'Maximum number of concurrent tasks (default: CPU cores)', + type: 'number', + }) + .option('perf', { + describe: 'Show performance statistics', + type: 'boolean', + }) + .positional('inputs', { + describe: 'File paths to process (supports glob patterns)', + type: 'string', + array: true, + demandOption: false, + }) + + .usage('Usage: $0 [inputs...] [options]') + .command( + '$0 [inputs...]', + 'Interactive mode', + args => args, + async (args) => { + await interactive(args).catch(err => console.error(err)) + }, + ) + .command( + 'all [inputs...]', + 'Process bundled code with all features', + args => args, + async (args) => { + await nonInteractive([Feature.Unpacker, Feature.Unminify], args).catch(err => console.error(err)) + }, + ) + .command( + ['unpacker [inputs...]', 'unpack [inputs...]'], + 'Unpack bundled code into separated modules', + args => args, + async (args) => { + await nonInteractive([Feature.Unpacker], args).catch(err => console.error(err)) + }, + ) + .command( + 'unminify [inputs...]', + 'Unminify the code into its readable form', + args => args, + async (args) => { + await nonInteractive([Feature.Unminify], args).catch(err => console.error(err)) + }, + ) + .argv + +async function interactive({ + inputs: _inputs, + output: _output, + force: _force = false, + concurrency = 1, + // perf, +}: { + inputs: string[] | undefined + output: string | undefined + force: boolean | undefined + concurrency: number | undefined + perf: boolean | undefined +}) { console.log() - intro(c.cyan(c.inverse(` Wakaru v${version} `))) + intro(c.cyan(c.inverse(` Wakaru CLI v${version} `))) + + /** + * Input validation + */ + const cwd = process.cwd() + + let _inputPaths: string[] = [] + let outputBase: string | null = null + let unminifyInputPaths: string[] = [] + let _overwrite = _force + + if (_inputs) { + if (_inputs.some(p => !isPathInside(cwd, p))) { + log.error('Input files must be inside the current working directory') + return process.exit(1) + } + + _inputPaths = _inputs.map(p => resolveGlob(p)).flat() + if (_inputPaths.length === 0) { + log.error('No input files matched') + return process.exit(1) + } + } + + if (_output) { + if (!isPathInside(cwd, _output)) { + log.error('Output directory must be inside the current working directory') + return process.exit(1) + } + + outputBase = _output + } + + if (concurrency !== undefined) { + if (concurrency < 1) concurrency = 1 + + const cpus = os.cpus().length + if (concurrency > cpus) { + log.warning(`Concurrency is more than CPU cores (${concurrency} > ${cpus})`) + } + } + + log.message(`${c.dim('Run "wakaru --help" for usage options')}`) const features = await multiselect({ message: `Select features to use ${c.dim('(Use to select, to submit)')}`, options: [ { label: 'Unpacker - Unpacks bundled code into separated modules', value: Feature.Unpacker }, - { label: 'Unminify - Converts minified code into its readable form', value: Feature.Unminify }, + { label: 'Unminify - Unminify the code into its readable form', value: Feature.Unminify }, ], initialValues: [Feature.Unpacker], }) @@ -49,58 +187,68 @@ async function main() { outro(`Selected features: ${c.green(features.join(', '))}`) - let unminifyInputPaths: string[] = [] + const singleFeature = features.length === 1 if (features.includes(Feature.Unpacker)) { intro(`${c.green(c.inverse(' Unpacker '))}`) - const rawInputPath = await text({ - message: `Input file path ${c.dim('(Supports only single file)')}`, - placeholder: './input.js', - validate(value) { - if (!value) return 'Please enter a file path' + let inputPaths = _inputPaths + if (_inputPaths.length === 0) { + const rawInputPath = await text({ + message: `Input file path ${c.dim('(Supports glob patterns)')}`, + placeholder: './input.js', + validate(value) { + if (!value) return 'Please enter a file path' + + const inputPath = path.resolve(value) + if (!fsa.existsSync(inputPath)) return 'Input does not exist' + if (!fsa.statSync(inputPath).isFile()) return 'Input is not a file' + if (!isPathInside(cwd, inputPath)) return 'Input is outside of the current working directory' - const inputPath = path.resolve(value) - if (!fsa.existsSync(inputPath)) return 'Input does not exist' - if (!fsa.statSync(inputPath).isFile()) return 'Input is not a file' + return undefined + }, + }) - return undefined - }, - }) + if (isCancel(rawInputPath)) { + cancel('Cancelled') + return process.exit(0) + } - if (isCancel(rawInputPath)) { - cancel('Cancelled') - return process.exit(0) + inputPaths = resolveGlob(rawInputPath) } - const inputPath = path.resolve(rawInputPath) - const outputPathPlaceholder = './out' + let outputPath = outputBase + ? singleFeature ? outputBase : path.join(outputBase, defaultUnpackerOutputFolder) + : '' + if (!outputBase) { + const rawOutputBase = await text({ + message: `Output directory path ${c.dim('( to accept default)')}`, + placeholder: defaultOutputBase, + validate(value) { + if (!value) return undefined // default value - const rawOutputPath = await text({ - message: `Output directory path ${c.dim('( to accept default)')}`, - placeholder: outputPathPlaceholder, - validate(value) { - if (!value) return undefined // default value + const outputPath = path.resolve(value) + if (!fsa.statSync(outputPath).isDirectory()) return 'Output is not a directory' + if (!isPathInside(cwd, outputPath)) return 'Output is outside of the current working directory' - const outputPath = path.resolve(value) - if (!fsa.statSync(outputPath).isDirectory()) return 'Output is not a directory' - if (!isPathInside(cwd, outputPath)) return 'Output is outside of the current working directory' + return undefined + }, + }) - return undefined - }, - }) + if (isCancel(rawOutputBase)) { + cancel('Cancelled') + return process.exit(0) + } - if (isCancel(rawOutputPath)) { - cancel('Cancelled') - return process.exit(0) + outputBase = path.resolve(rawOutputBase ?? defaultOutputBase) + outputPath = singleFeature + ? outputBase + : path.join(outputBase, defaultUnpackerOutputFolder) } - const outputPath = path.resolve(rawOutputPath || outputPathPlaceholder) - const relativeOutputPath = getRelativePath(cwd, outputPath) - - if (fsa.existsSync(outputPath)) { + if (!_overwrite && fsa.existsSync(outputBase)) { const overwrite = await confirm({ - message: `Output directory already exists at ${c.green(relativeOutputPath)}. Overwrite?`, + message: `Output directory already exists at ${c.green(getRelativePath(cwd, outputBase))}. Overwrite?`, initialValue: true, }) @@ -114,19 +262,21 @@ async function main() { return process.exit(1) } } + _overwrite = true log.step('Unpacking...') const s = spinner() s.start('...') - const items = await unpacker([inputPath], outputPath) + const items = await unpacker(inputPaths, outputPath) s.stop('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) const formattedElapsed = (totalElapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) - outro(`Output directory: ${c.green(relativeOutputPath)}`) + + outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) unminifyInputPaths = items.flatMap(item => item.files) } @@ -137,11 +287,15 @@ async function main() { const unpacked = features.includes(Feature.Unpacker) if (unpacked && unminifyInputPaths.length === 0) { - // No need to continue if there are no unpacked files + log.warning('No unpacked files found. This is not your fault, but a bug in Wakaru. Please report this issue.') return process.exit(0) } if (!unpacked) { + unminifyInputPaths = _inputPaths ?? [] + } + + if (unminifyInputPaths.length === 0) { const rawInputPath = await text({ message: `Input file path ${c.dim('(Supports glob patterns)')}`, placeholder: './*.js', @@ -150,6 +304,7 @@ async function main() { const resolvedPaths = resolveGlob(value) if (resolvedPaths.length === 0) return 'No files matched' + if (!isPathInside(cwd, value)) return 'Input is outside of the current working directory' return undefined }, @@ -162,47 +317,45 @@ async function main() { unminifyInputPaths = resolveGlob(rawInputPath) } - else { - log.success('Input file path') - log.message(c.dim('Skipped')) - } const commonBaseDir = findCommonBaseDir(unminifyInputPaths) if (!commonBaseDir) { - log.error(`Could not find common base directory with input paths ${c.green(unminifyInputPaths.join(', '))}`) + log.error('Could not find common base directory with input paths') return process.exit(1) } - let outputPathPlaceholder = './out' - if (unpacked) { - outputPathPlaceholder = getRelativePath(cwd, path.join(commonBaseDir, outputPathPlaceholder)) - } + let outputPath = outputBase + ? singleFeature ? outputBase : path.join(outputBase, defaultUnminifyOutputFolder) + : '' + if (!outputBase) { + const rawOutputBase = await text({ + message: `Output directory path ${c.dim('( to accept default)')}`, + placeholder: defaultOutputBase, + validate(value) { + if (!value) return undefined // default value - const rawOutputPath = await text({ - message: `Output directory path ${c.dim('( to accept default)')}`, - placeholder: outputPathPlaceholder, - validate(value) { - if (!value) return undefined // default value + const outputPath = path.resolve(value) + if (fsa.existsSync(outputPath) && !fsa.statSync(outputPath).isDirectory()) return 'Output path is not a directory' + if (!isPathInside(cwd, outputPath)) return 'Output path is outside of the current working directory' - const outputPath = path.resolve(value) - if (fsa.existsSync(outputPath) && !fsa.statSync(outputPath).isDirectory()) return 'Output path is not a directory' - if (!isPathInside(cwd, outputPath)) return 'Output path is outside of the current working directory' + return undefined + }, + }) - return undefined - }, - }) + if (isCancel(rawOutputBase)) { + cancel('Cancelled') + return process.exit(0) + } - if (isCancel(rawOutputPath)) { - cancel('Cancelled') - return process.exit(0) + outputBase = path.resolve(rawOutputBase ?? defaultOutputBase) + outputPath = singleFeature + ? outputBase + : path.join(outputBase, defaultUnminifyOutputFolder) } - const outputPath = path.resolve(rawOutputPath || outputPathPlaceholder) - const relativeOutputPath = getRelativePath(cwd, outputPath) - - if (fsa.existsSync(outputPath)) { + if (!_overwrite && fsa.existsSync(outputBase)) { const overwrite = await confirm({ - message: `Output directory already exists at ${c.green(relativeOutputPath)}. Overwrite?`, + message: `Output directory already exists at ${c.green(getRelativePath(cwd, outputBase))}. Overwrite?`, initialValue: true, }) @@ -217,13 +370,11 @@ async function main() { } } - const concurrency = Math.min(os.cpus().length, 2) // TODO: Make this configurable - const concurrencyManager = new Concurrency({ concurrency }) - log.step('Unminifying...') const s = spinner() s.start('...') + const concurrencyManager = new Concurrency({ concurrency }) await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { await unminify([p], commonBaseDir, outputPath, true) @@ -234,7 +385,7 @@ async function main() { log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files`) - outro(`Output directory: ${c.green(relativeOutputPath)}`) + outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) } console.log() @@ -242,4 +393,146 @@ async function main() { console.log() } -main().catch(err => console.error(err)) +async function nonInteractive(features: Feature[], { + inputs: _inputs, + output: _output, + 'unpacker-output': _unpackerOutput, + 'unminify-output': _unminifyOutput, + force = false, + concurrency = 1, + // perf, +}: { + inputs: string[] | undefined + output: string | undefined + 'unpacker-output': string | undefined + 'unminify-output': string | undefined + force: boolean | undefined + concurrency: number | undefined + perf: boolean | undefined +}) { + console.log() + intro(c.cyan(c.inverse(` Wakaru CLI v${version} `))) + + /** + * Input validation + */ + const cwd = process.cwd() + + if (_inputs === undefined) { + log.error('No input files specified') + return process.exit(1) + } + + if (_inputs.some(p => !isPathInside(cwd, p))) { + log.error('Input files must be inside the current working directory') + return process.exit(1) + } + + const inputPaths = _inputs.map(p => resolveGlob(p)).flat() + if (inputPaths.length === 0) { + log.error('No input files matched') + return process.exit(1) + } + + const output = _output ?? defaultOutputBase + const singleFeature = features.length === 1 + const unpackerOutput = _unpackerOutput ?? (singleFeature ? output : path.join(output, defaultUnpackerOutputFolder)) + const unminifyOutput = _unminifyOutput ?? (singleFeature ? output : path.join(output, defaultUnminifyOutputFolder)) + + if (!isPathInside(cwd, output)) { + log.error('Output directory must be inside the current working directory') + return process.exit(1) + } + + if (!force) { + if (fsa.existsSync(output)) { + log.error(`Output directory already exists at ${c.green(output)}. Pass ${c.green('--force')} to overwrite`) + return process.exit(1) + } + + if (features.includes(Feature.Unpacker) && fsa.existsSync(unpackerOutput)) { + log.error(`Output directory already exists at ${c.green(unpackerOutput)}. Pass ${c.green('--force')} to overwrite`) + return process.exit(1) + } + + if (features.includes(Feature.Unminify) && fsa.existsSync(unminifyOutput)) { + log.error(`Output directory already exists at ${c.green(unminifyOutput)}. Pass ${c.green('--force')} to overwrite`) + return process.exit(1) + } + } + + if (concurrency !== undefined) { + if (concurrency < 1) concurrency = 1 + + const cpus = os.cpus().length + if (concurrency > cpus) { + log.warning(`Concurrency is more than CPU cores (${concurrency} > ${cpus})`) + } + } + + outro(`Selected features: ${c.green(features.join(', '))}`) + + let unminifyInputPaths: string[] = [] + + if (features.includes(Feature.Unpacker)) { + intro(`${c.green(c.inverse(' Unpacker '))}`) + + const outputPath = path.resolve(unpackerOutput) + const relativeOutputPath = getRelativePath(cwd, outputPath) + + log.step('Unpacking...') + + const s = spinner() + s.start('...') + const items = await unpacker(inputPaths, outputPath) + s.stop('Finished') + + const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) + const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) + const formattedElapsed = (totalElapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) + log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) + outro(`Output directory: ${c.green(relativeOutputPath)}`) + + unminifyInputPaths = items.flatMap(item => item.files) + } + + if (features.includes(Feature.Unminify)) { + intro(`${c.green(c.inverse(' Unminify '))}`) + + const unpacked = features.includes(Feature.Unpacker) + if (unpacked && unminifyInputPaths.length === 0) { + log.warning('No unpacked files found. This is not your fault, but a bug in Wakaru. Please report this issue.') + return process.exit(0) + } + + if (!unpacked) { + unminifyInputPaths = inputPaths + } + + const commonBaseDir = findCommonBaseDir(unminifyInputPaths) + if (!commonBaseDir) { + log.error('Could not find common base directory with input paths') + return process.exit(1) + } + + const outputPath = path.resolve(unminifyOutput) + const relativeOutputPath = getRelativePath(cwd, outputPath) + + log.step('Unminifying...') + + const s = spinner() + s.start('...') + const concurrencyManager = new Concurrency({ concurrency }) + await Promise.all( + unminifyInputPaths.map(p => concurrencyManager.add(async () => { + await unminify([p], commonBaseDir, outputPath, true) + s.message(`${c.green(path.relative(cwd, p))}`) + })), + ) + s.stop('Finished') + + log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files`) + + outro(`Output directory: ${c.green(relativeOutputPath)}`) + } +} From 3137222abee4eab7c35a7f88e066613a8091fbb9 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Tue, 12 Dec 2023 02:47:58 +0800 Subject: [PATCH 05/19] fix: passing module meta and module mapping to unminify --- packages/cli/src/cli.ts | 40 ++++++++++++++++++++++++++++++++++-- packages/cli/src/unminify.ts | 7 ++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 60047a94..7ed10438 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -23,6 +23,8 @@ import { Concurrency } from './concurrency' import { findCommonBaseDir, getRelativePath, isPathInside, resolveGlob } from './path' import { unminify } from './unminify' import { unpacker } from './unpacker' +import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' +import type { Module } from '@wakaru/unpacker' enum Feature { Unpacker = 'Unpacker', @@ -136,6 +138,8 @@ async function interactive({ let _inputPaths: string[] = [] let outputBase: string | null = null let unminifyInputPaths: string[] = [] + let moduleMeta: ModuleMeta = {} + let moduleMapping: ModuleMapping = {} let _overwrite = _force if (_inputs) { @@ -279,6 +283,19 @@ async function interactive({ outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) unminifyInputPaths = items.flatMap(item => item.files) + const modules = items.flatMap(item => item.modules) + moduleMeta = modules.reduce((acc, mod) => { + acc[mod.id] = { + import: mod.import, + export: mod.export, + tags: mod.tags, + } + return acc + }, {}) + moduleMapping = modules.reduce((acc, mod) => { + acc[mod.id] = getDepName(mod) + return acc + }, {}) } if (features.includes(Feature.Unminify)) { @@ -377,7 +394,7 @@ async function interactive({ const concurrencyManager = new Concurrency({ concurrency }) await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - await unminify([p], commonBaseDir, outputPath, true) + await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) s.message(`${c.green(path.relative(cwd, p))}`) })), ) @@ -473,6 +490,8 @@ async function nonInteractive(features: Feature[], { outro(`Selected features: ${c.green(features.join(', '))}`) let unminifyInputPaths: string[] = [] + let moduleMeta: ModuleMeta = {} + let moduleMapping: ModuleMapping = {} if (features.includes(Feature.Unpacker)) { intro(`${c.green(c.inverse(' Unpacker '))}`) @@ -494,6 +513,19 @@ async function nonInteractive(features: Feature[], { outro(`Output directory: ${c.green(relativeOutputPath)}`) unminifyInputPaths = items.flatMap(item => item.files) + const modules = items.flatMap(item => item.modules) + moduleMeta = modules.reduce((acc, mod) => { + acc[mod.id] = { + import: mod.import, + export: mod.export, + tags: mod.tags, + } + return acc + }, {}) + moduleMapping = modules.reduce((acc, mod) => { + acc[mod.id] = getDepName(mod) + return acc + }, {}) } if (features.includes(Feature.Unminify)) { @@ -525,7 +557,7 @@ async function nonInteractive(features: Feature[], { const concurrencyManager = new Concurrency({ concurrency }) await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - await unminify([p], commonBaseDir, outputPath, true) + await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) s.message(`${c.green(path.relative(cwd, p))}`) })), ) @@ -536,3 +568,7 @@ async function nonInteractive(features: Feature[], { outro(`Output directory: ${c.green(relativeOutputPath)}`) } } + +function getDepName(dep: Module) { + return dep.isEntry ? `entry-${dep.id}.js` : `module-${dep.id}.js` +} diff --git a/packages/cli/src/unminify.ts b/packages/cli/src/unminify.ts index 9558c3e5..2634a809 100644 --- a/packages/cli/src/unminify.ts +++ b/packages/cli/src/unminify.ts @@ -4,10 +4,13 @@ import process from 'node:process' import { runTransformations, transformationRules } from '@wakaru/unminify' import fsa from 'fs-extra' import { Timing } from './perf' +import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' import type { Transform } from 'jscodeshift' export async function unminify( paths: string[], + moduleMapping: ModuleMapping, + moduleMeta: ModuleMeta, baseDir: string, outputDir: string, perf: boolean, @@ -23,6 +26,8 @@ export async function unminify( const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) + const params = { moduleMapping, moduleMeta } + await timing.measureTimeAsync(async () => { const source = await measureAsync('read file', () => fsa.readFile(p, 'utf-8')) @@ -30,7 +35,7 @@ export async function unminify( const { id, transform } = rule return (...args: Parameters) => measure(id, () => transform(...args)) }) - const result = measure('runDefaultTransformation', () => runTransformations({ path: p, source }, transformations)) + const result = measure('runDefaultTransformation', () => runTransformations({ path: p, source }, transformations, params)) await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) }) From 3ff5b8ae39a2bc4f06191f3f3e76f3b7f1ebb34c Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Tue, 12 Dec 2023 03:13:12 +0800 Subject: [PATCH 06/19] fix: fix elapsed time --- packages/cli/src/cli.ts | 24 ++++++++++++++++-------- packages/cli/src/unminify.ts | 14 +++++++++++++- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 7ed10438..92893269 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -277,7 +277,7 @@ async function interactive({ const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) - const formattedElapsed = (totalElapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) + const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) @@ -392,15 +392,19 @@ async function interactive({ const s = spinner() s.start('...') const concurrencyManager = new Concurrency({ concurrency }) - await Promise.all( + const items = await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) + const result = await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) s.message(`${c.green(path.relative(cwd, p))}`) + return result })), ) s.stop('Finished') - log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files`) + const totalElapsed = items.flat().reduce((acc, item) => acc + item.elapsed, 0) + const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) + + log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) } @@ -508,7 +512,7 @@ async function nonInteractive(features: Feature[], { const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) - const formattedElapsed = (totalElapsed / 1e6).toLocaleString('en-US', { maximumFractionDigits: 1 }) + const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) outro(`Output directory: ${c.green(relativeOutputPath)}`) @@ -555,15 +559,19 @@ async function nonInteractive(features: Feature[], { const s = spinner() s.start('...') const concurrencyManager = new Concurrency({ concurrency }) - await Promise.all( + const items = await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) + const result = await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) s.message(`${c.green(path.relative(cwd, p))}`) + return result })), ) s.stop('Finished') - log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files`) + const totalElapsed = items.flat().reduce((acc, item) => acc + item.elapsed, 0) + const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) + + log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) outro(`Output directory: ${c.green(relativeOutputPath)}`) } diff --git a/packages/cli/src/unminify.ts b/packages/cli/src/unminify.ts index 2634a809..f74678dc 100644 --- a/packages/cli/src/unminify.ts +++ b/packages/cli/src/unminify.ts @@ -7,6 +7,10 @@ import { Timing } from './perf' import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' import type { Transform } from 'jscodeshift' +export interface UnminifyItem { + elapsed: number +} + export async function unminify( paths: string[], moduleMapping: ModuleMapping, @@ -20,6 +24,8 @@ export async function unminify( const cwd = process.cwd() const timing = new Timing(perf) + const result: UnminifyItem[] = [] + for (const p of paths) { const outputPath = path.join(outputDir, path.relative(baseDir, p)) const filename = path.relative(cwd, outputPath) @@ -28,7 +34,7 @@ export async function unminify( const params = { moduleMapping, moduleMeta } - await timing.measureTimeAsync(async () => { + const { time: elapsed } = await timing.measureTimeAsync(async () => { const source = await measureAsync('read file', () => fsa.readFile(p, 'utf-8')) const transformations = transformationRules.map((rule) => { @@ -39,5 +45,11 @@ export async function unminify( await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) }) + + result.push({ + elapsed, + }) } + + return result } From 5a4ab933b3237315b06cc420f11cde4be9099261 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Tue, 12 Dec 2023 03:21:32 +0800 Subject: [PATCH 07/19] refactor: simplify unminify path --- packages/cli/src/cli.ts | 8 ++++---- packages/cli/src/unminify.ts | 40 +++++++++++++++--------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 92893269..b5dfbc53 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -394,14 +394,14 @@ async function interactive({ const concurrencyManager = new Concurrency({ concurrency }) const items = await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - const result = await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) + const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath, true) s.message(`${c.green(path.relative(cwd, p))}`) return result })), ) s.stop('Finished') - const totalElapsed = items.flat().reduce((acc, item) => acc + item.elapsed, 0) + const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) @@ -561,14 +561,14 @@ async function nonInteractive(features: Feature[], { const concurrencyManager = new Concurrency({ concurrency }) const items = await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - const result = await unminify([p], moduleMapping, moduleMeta, commonBaseDir, outputPath, true) + const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath, true) s.message(`${c.green(path.relative(cwd, p))}`) return result })), ) s.stop('Finished') - const totalElapsed = items.flat().reduce((acc, item) => acc + item.elapsed, 0) + const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) diff --git a/packages/cli/src/unminify.ts b/packages/cli/src/unminify.ts index f74678dc..ecb54f48 100644 --- a/packages/cli/src/unminify.ts +++ b/packages/cli/src/unminify.ts @@ -12,7 +12,7 @@ export interface UnminifyItem { } export async function unminify( - paths: string[], + filePath: string, moduleMapping: ModuleMapping, moduleMeta: ModuleMeta, baseDir: string, @@ -24,32 +24,26 @@ export async function unminify( const cwd = process.cwd() const timing = new Timing(perf) - const result: UnminifyItem[] = [] + const outputPath = path.join(outputDir, path.relative(baseDir, filePath)) + const filename = path.relative(cwd, outputPath) + const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) + const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) - for (const p of paths) { - const outputPath = path.join(outputDir, path.relative(baseDir, p)) - const filename = path.relative(cwd, outputPath) - const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) - const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) + const params = { moduleMapping, moduleMeta } - const params = { moduleMapping, moduleMeta } + const { time: elapsed } = await timing.measureTimeAsync(async () => { + const source = await measureAsync('read file', () => fsa.readFile(filePath, 'utf-8')) - const { time: elapsed } = await timing.measureTimeAsync(async () => { - const source = await measureAsync('read file', () => fsa.readFile(p, 'utf-8')) - - const transformations = transformationRules.map((rule) => { - const { id, transform } = rule - return (...args: Parameters) => measure(id, () => transform(...args)) - }) - const result = measure('runDefaultTransformation', () => runTransformations({ path: p, source }, transformations, params)) - - await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) + const transformations = transformationRules.map((rule) => { + const { id, transform } = rule + return (...args: Parameters) => measure(id, () => transform(...args)) }) + const result = measure('runDefaultTransformation', () => runTransformations({ path: filePath, source }, transformations, params)) - result.push({ - elapsed, - }) - } + await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) + }) - return result + return { + elapsed, + } } From f9ac473b9e9adbd69e6714c4b52f2b59d1c02279 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Wed, 13 Dec 2023 00:43:27 +0800 Subject: [PATCH 08/19] feat!: bump Node.js to >= 18 --- package.json | 2 +- packages/ast-utils/package.json | 2 +- packages/browserfs/package.json | 2 +- packages/ds/package.json | 2 +- packages/test-utils/package.json | 2 +- packages/unminify/package.json | 2 +- packages/unpacker/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 95dd7676..23c75fad 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "license": "MIT", "homepage": "https://github.com/pionxzh/wakaru", "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "build": "turbo run build", diff --git a/packages/ast-utils/package.json b/packages/ast-utils/package.json index 72872032..2cf82aeb 100644 --- a/packages/ast-utils/package.json +++ b/packages/ast-utils/package.json @@ -30,7 +30,7 @@ "package.json" ], "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "build": "tsup src/index.ts --format cjs,esm --dts --sourcemap --clean", diff --git a/packages/browserfs/package.json b/packages/browserfs/package.json index cfe4b10f..42a8bc9b 100644 --- a/packages/browserfs/package.json +++ b/packages/browserfs/package.json @@ -14,7 +14,7 @@ } }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { } diff --git a/packages/ds/package.json b/packages/ds/package.json index 329f7c7e..857fb9a0 100644 --- a/packages/ds/package.json +++ b/packages/ds/package.json @@ -12,7 +12,7 @@ "package.json" ], "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "test:type": "tsc --noEmit", diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 2884abd8..01000ca0 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -12,7 +12,7 @@ "package.json" ], "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "test:type": "tsc --noEmit", diff --git a/packages/unminify/package.json b/packages/unminify/package.json index ac0a43b2..b4d77e6c 100644 --- a/packages/unminify/package.json +++ b/packages/unminify/package.json @@ -13,7 +13,7 @@ "package.json" ], "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "build": "tsup", diff --git a/packages/unpacker/package.json b/packages/unpacker/package.json index ec07ad1f..08cceeb6 100644 --- a/packages/unpacker/package.json +++ b/packages/unpacker/package.json @@ -13,7 +13,7 @@ "package.json" ], "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "build": "tsup", From 15eaaa8c4dd79017244cef4479f81b5685a8f8e5 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Wed, 13 Dec 2023 01:29:12 +0800 Subject: [PATCH 09/19] feat(cli): run unminify in worker --- packages/cli/README.md | 25 +++++++++++++++ packages/cli/bin/run.cmd | 2 +- packages/cli/bin/run.sh | 3 ++ packages/cli/bin/run.ts | 3 -- packages/cli/package.json | 5 ++- packages/cli/src/cli.ts | 5 +-- packages/cli/src/types.ts | 8 +++++ packages/cli/src/unminify.ts | 48 ++++++++++++++++------------- packages/cli/src/unminify.worker.ts | 35 +++++++++++++++++++++ packages/cli/tsup.config.ts | 9 ++++-- pnpm-lock.yaml | 14 --------- 11 files changed, 109 insertions(+), 48 deletions(-) create mode 100644 packages/cli/README.md create mode 100644 packages/cli/bin/run.sh delete mode 100644 packages/cli/bin/run.ts create mode 100644 packages/cli/src/types.ts create mode 100644 packages/cli/src/unminify.worker.ts diff --git a/packages/cli/README.md b/packages/cli/README.md new file mode 100644 index 00000000..90a2e7d3 --- /dev/null +++ b/packages/cli/README.md @@ -0,0 +1,25 @@ +# `@wakaru/cli` + +## Development + +To run the CLI in development mode, use the following command: + +### MacOS / Linux + +```bash +.\bin\run.sh all .\input.js --force +``` + +### Windows + +```bash +.\bin\run.cmd all .\input.js --force +``` + +### Script + +```bash +pnpm run dev-cli -- -- all .\iput.js --force +``` + +Please aware that double `--` is required to pass arguments to the script. diff --git a/packages/cli/bin/run.cmd b/packages/cli/bin/run.cmd index 1a09379f..4559950f 100644 --- a/packages/cli/bin/run.cmd +++ b/packages/cli/bin/run.cmd @@ -1,3 +1,3 @@ @echo off -pnpm exec tsx "%~dp0\run" %* +pnpm exec tsup --silent --onSuccess "node %~dp0\..\dist\cli.cjs %*" diff --git a/packages/cli/bin/run.sh b/packages/cli/bin/run.sh new file mode 100644 index 00000000..c856c29c --- /dev/null +++ b/packages/cli/bin/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pnpm exec tsup --silent --onSuccess "node $(dirname "$0")/../dist/cli.cjs $*" diff --git a/packages/cli/bin/run.ts b/packages/cli/bin/run.ts deleted file mode 100644 index f4117a50..00000000 --- a/packages/cli/bin/run.ts +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env -S node --import tsx --no-warnings=ExperimentalWarning - -import '../src/cli.ts' diff --git a/packages/cli/package.json b/packages/cli/package.json index 7f35b421..12d52b8e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -11,11 +11,11 @@ "package.json" ], "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "build": "tsup", - "dev-cli": "tsx src/cli.ts", + "dev-cli": "pnpm exec tsup --silent --onSuccess \"node ./dist/cli.cjs $npm_package_main\"", "test": "vitest run --globals", "test:update": "vitest run --update --globals", "test:watch": "vitest watch --globals", @@ -40,7 +40,6 @@ "@wakaru/unminify": "workspace:*", "@wakaru/unpacker": "workspace:*", "tsup": "^7.3.0", - "tsx": "^4.6.2", "typescript": "^5.3.2" }, "publishConfig": { diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index b5dfbc53..19781932 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node + /* eslint-disable no-console */ import os from 'node:os' import path from 'node:path' @@ -394,7 +395,7 @@ async function interactive({ const concurrencyManager = new Concurrency({ concurrency }) const items = await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath, true) + const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath) s.message(`${c.green(path.relative(cwd, p))}`) return result })), @@ -561,7 +562,7 @@ async function nonInteractive(features: Feature[], { const concurrencyManager = new Concurrency({ concurrency }) const items = await Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { - const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath, true) + const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath) s.message(`${c.green(path.relative(cwd, p))}`) return result })), diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts new file mode 100644 index 00000000..e1f7d56e --- /dev/null +++ b/packages/cli/src/types.ts @@ -0,0 +1,8 @@ +import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' + +export interface UnminifyWorkerParams { + inputPath: string + outputPath: string + moduleMapping: ModuleMapping + moduleMeta: ModuleMeta +} diff --git a/packages/cli/src/unminify.ts b/packages/cli/src/unminify.ts index ecb54f48..f49cf92d 100644 --- a/packages/cli/src/unminify.ts +++ b/packages/cli/src/unminify.ts @@ -1,11 +1,10 @@ /* eslint-disable no-console */ -import * as path from 'node:path' -import process from 'node:process' -import { runTransformations, transformationRules } from '@wakaru/unminify' +import path from 'node:path' +import { Worker } from 'node:worker_threads' import fsa from 'fs-extra' import { Timing } from './perf' +import type { UnminifyWorkerParams } from './types' import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' -import type { Transform } from 'jscodeshift' export interface UnminifyItem { elapsed: number @@ -17,33 +16,38 @@ export async function unminify( moduleMeta: ModuleMeta, baseDir: string, outputDir: string, - perf: boolean, ) { await fsa.ensureDir(outputDir) - const cwd = process.cwd() - const timing = new Timing(perf) - - const outputPath = path.join(outputDir, path.relative(baseDir, filePath)) - const filename = path.relative(cwd, outputPath) - const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) - const measureAsync = (key: string, fn: () => Promise) => timing.collectAsync(filename, key, fn) - - const params = { moduleMapping, moduleMeta } + const timing = new Timing() const { time: elapsed } = await timing.measureTimeAsync(async () => { - const source = await measureAsync('read file', () => fsa.readFile(filePath, 'utf-8')) - - const transformations = transformationRules.map((rule) => { - const { id, transform } = rule - return (...args: Parameters) => measure(id, () => transform(...args)) + return runUnminifyInWorker({ + inputPath: filePath, + outputPath: path.join(outputDir, path.relative(baseDir, filePath)), + moduleMeta, + moduleMapping, }) - const result = measure('runDefaultTransformation', () => runTransformations({ path: filePath, source }, transformations, params)) - - await measureAsync('write file', () => fsa.writeFile(outputPath, result.code, 'utf-8')) }) return { elapsed, } } + +function runUnminifyInWorker(params: UnminifyWorkerParams) { + return new Promise((resolve, reject) => { + const worker = new Worker( + new URL('./unminify.worker.cjs', import.meta.url), + { workerData: params }, + ) + + worker.on('message', resolve) + worker.on('error', reject) + worker.on('exit', (code) => { + if (code !== 0) { + reject(new Error(`Worker stopped with exit code ${code}`)) + } + }) + }) +} diff --git a/packages/cli/src/unminify.worker.ts b/packages/cli/src/unminify.worker.ts new file mode 100644 index 00000000..9cbdb09e --- /dev/null +++ b/packages/cli/src/unminify.worker.ts @@ -0,0 +1,35 @@ +import path from 'node:path' +import process from 'node:process' +import { parentPort, workerData } from 'node:worker_threads' +import { runTransformations, transformationRules } from '@wakaru/unminify' +import fsa from 'fs-extra' +import { Timing } from './perf' +import type { UnminifyWorkerParams } from './types' +import type { Transform } from 'jscodeshift' + +try { + const { inputPath, outputPath, moduleMeta, moduleMapping } = workerData as UnminifyWorkerParams + + const timing = new Timing() + const cwd = process.cwd() + const filename = path.relative(cwd, inputPath) + const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) + + const source = fsa.readFileSync(inputPath, 'utf-8') + const fileInfo = { path: inputPath, source } + + const transformations = transformationRules.map((rule) => { + const { id, transform } = rule + return (...args: Parameters) => measure(id, () => transform(...args)) + }) + + const { code } = runTransformations(fileInfo, transformations, { moduleMeta, moduleMapping }) + fsa.writeFileSync(outputPath, code, 'utf-8') + + parentPort?.postMessage(code) +} +catch (e) { + // We print the error here because it will lose the stack trace after being sent to the main thread + console.error(e) + throw e +} diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts index 4bdf389f..34c9cc5f 100644 --- a/packages/cli/tsup.config.ts +++ b/packages/cli/tsup.config.ts @@ -1,9 +1,12 @@ import { defineConfig } from 'tsup' export default defineConfig({ - entry: ['src/cli.ts'], - format: ['cjs', 'esm'], - dts: true, + entry: ['src/cli.ts', 'src/unminify.worker.ts'], + format: ['cjs'], + platform: 'node', + target: 'node18', + shims: true, + dts: false, splitting: true, sourcemap: true, clean: true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf97a722..f864b2c3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -142,9 +142,6 @@ importers: tsup: specifier: ^7.3.0 version: 7.3.0(typescript@5.3.2) - tsx: - specifier: ^4.6.2 - version: 4.6.2 typescript: specifier: ^5.3.2 version: 5.3.2 @@ -9049,17 +9046,6 @@ packages: fsevents: 2.3.3 dev: true - /tsx@4.6.2: - resolution: {integrity: sha512-QPpBdJo+ZDtqZgAnq86iY/PD2KYCUPSUGIunHdGwyII99GKH+f3z3FZ8XNFLSGQIA4I365ui8wnQpl8OKLqcsg==} - engines: {node: '>=18.0.0'} - hasBin: true - dependencies: - esbuild: 0.18.20 - get-tsconfig: 4.7.2 - optionalDependencies: - fsevents: 2.3.3 - dev: true - /tuf-js@2.1.0: resolution: {integrity: sha512-eD7YPPjVlMzdggrOeE8zwoegUaG/rt6Bt3jwoQPunRiNVzgcCE009UDFJKJjG+Gk9wFu6W/Vi+P5d/5QpdD9jA==} engines: {node: ^16.14.0 || >=18.0.0} From 5863917c808d927e68264741daf328d343d9946e Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Wed, 13 Dec 2023 02:17:38 +0800 Subject: [PATCH 10/19] fix(cli): move out the timing measure --- packages/cli/src/cli.ts | 37 ++++++++++++++++++----------- packages/cli/src/unminify.worker.ts | 2 ++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 19781932..c602d484 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -22,6 +22,7 @@ import { hideBin } from 'yargs/helpers' import { version } from '../package.json' import { Concurrency } from './concurrency' import { findCommonBaseDir, getRelativePath, isPathInside, resolveGlob } from './path' +import { Timing } from './perf' import { unminify } from './unminify' import { unpacker } from './unpacker' import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' @@ -273,12 +274,14 @@ async function interactive({ const s = spinner() s.start('...') - const items = await unpacker(inputPaths, outputPath) + + const timing = new Timing() + const { result: items, time: elapsed } = await timing.measureTimeAsync(() => unpacker(inputPaths, outputPath)) + s.stop('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) - const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) - const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) + const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) @@ -392,18 +395,20 @@ async function interactive({ const s = spinner() s.start('...') + + const timing = new Timing() const concurrencyManager = new Concurrency({ concurrency }) - const items = await Promise.all( + const { time: elapsed } = await timing.measureTimeAsync(() => Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath) s.message(`${c.green(path.relative(cwd, p))}`) return result })), - ) + )) + s.stop('Finished') - const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) - const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) + const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) @@ -508,12 +513,14 @@ async function nonInteractive(features: Feature[], { const s = spinner() s.start('...') - const items = await unpacker(inputPaths, outputPath) + + const timing = new Timing() + const { result: items, time: elapsed } = await timing.measureTimeAsync(() => unpacker(inputPaths, outputPath)) + s.stop('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) - const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) - const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) + const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) outro(`Output directory: ${c.green(relativeOutputPath)}`) @@ -559,18 +566,20 @@ async function nonInteractive(features: Feature[], { const s = spinner() s.start('...') + + const timing = new Timing() const concurrencyManager = new Concurrency({ concurrency }) - const items = await Promise.all( + const { time: elapsed } = await timing.measureTimeAsync(() => Promise.all( unminifyInputPaths.map(p => concurrencyManager.add(async () => { const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath) s.message(`${c.green(path.relative(cwd, p))}`) return result })), - ) + )) + s.stop('Finished') - const totalElapsed = items.reduce((acc, item) => acc + item.elapsed, 0) - const formattedElapsed = totalElapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) + const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) diff --git a/packages/cli/src/unminify.worker.ts b/packages/cli/src/unminify.worker.ts index 9cbdb09e..84f3ceff 100644 --- a/packages/cli/src/unminify.worker.ts +++ b/packages/cli/src/unminify.worker.ts @@ -27,6 +27,8 @@ try { fsa.writeFileSync(outputPath, code, 'utf-8') parentPort?.postMessage(code) + + process.exit(0) } catch (e) { // We print the error here because it will lose the stack trace after being sent to the main thread From 76565ff5db0112f8cb37c616892d35dd8203f21b Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Wed, 13 Dec 2023 23:52:18 +0800 Subject: [PATCH 11/19] feat: use poolifier to manage worker --- .vscode/settings.json | 1 + packages/cli/package.json | 1 + packages/cli/src/cli.ts | 97 +++++++++++++++++------------ packages/cli/src/concurrency.ts | 51 --------------- packages/cli/src/unminify.ts | 53 ---------------- packages/cli/src/unminify.worker.ts | 49 ++++++++------- packages/cli/src/unpacker.ts | 2 +- pnpm-lock.yaml | 9 +++ 8 files changed, 95 insertions(+), 168 deletions(-) delete mode 100644 packages/cli/src/concurrency.ts delete mode 100644 packages/cli/src/unminify.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 616bc4f6..db948378 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -43,6 +43,7 @@ "outro", "Paneview", "picocolors", + "poolifier", "preact", "quux", "splitpanes", diff --git a/packages/cli/package.json b/packages/cli/package.json index 12d52b8e..b66a1810 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -29,6 +29,7 @@ "fs-extra": "^11.1.1", "globby": "^11.1.0", "picocolors": "^1.0.0", + "poolifier": "^3.0.14", "yargs": "^17.7.2" }, "devDependencies": { diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index c602d484..415234d4 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -1,9 +1,10 @@ #!/usr/bin/env node /* eslint-disable no-console */ -import os from 'node:os' +import { availableParallelism } from 'node:os' import path from 'node:path' import process from 'node:process' +import { fileURLToPath } from 'node:url' import { cancel, confirm, @@ -17,14 +18,14 @@ import { } from '@clack/prompts' import fsa from 'fs-extra' import c from 'picocolors' +import { FixedThreadPool } from 'poolifier' import yargs from 'yargs' import { hideBin } from 'yargs/helpers' import { version } from '../package.json' -import { Concurrency } from './concurrency' import { findCommonBaseDir, getRelativePath, isPathInside, resolveGlob } from './path' import { Timing } from './perf' -import { unminify } from './unminify' import { unpacker } from './unpacker' +import type { UnminifyWorkerParams } from './types' import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' import type { Module } from '@wakaru/unpacker' @@ -37,6 +38,11 @@ const defaultOutputBase = './out/' const defaultUnpackerOutputFolder = 'unpack' const defaultUnminifyOutputFolder = 'unminify' +const unminifyWorkerFile = path.join( + path.dirname(fileURLToPath(import.meta.url)), + `unminify.worker${path.extname(fileURLToPath(import.meta.url))}`, +) + // eslint-disable-next-line no-unused-expressions yargs(hideBin(process.argv)) .scriptName('@wakaru/cli') @@ -67,7 +73,7 @@ yargs(hideBin(process.argv)) type: 'boolean', }) .option('concurrency', { - describe: 'Maximum number of concurrent tasks (default: CPU cores)', + describe: 'Maximum number of concurrent tasks (default: 1)', type: 'number', }) .option('perf', { @@ -166,14 +172,9 @@ async function interactive({ outputBase = _output } - if (concurrency !== undefined) { - if (concurrency < 1) concurrency = 1 - - const cpus = os.cpus().length - if (concurrency > cpus) { - log.warning(`Concurrency is more than CPU cores (${concurrency} > ${cpus})`) - } - } + const minConcurrency = 1 + const maxConcurrency = availableParallelism() + concurrency = Math.min(maxConcurrency, Math.max(minConcurrency, concurrency)) log.message(`${c.dim('Run "wakaru --help" for usage options')}`) @@ -345,7 +346,7 @@ async function interactive({ return process.exit(1) } - let outputPath = outputBase + let outputDir = outputBase ? singleFeature ? outputBase : path.join(outputBase, defaultUnminifyOutputFolder) : '' if (!outputBase) { @@ -369,7 +370,7 @@ async function interactive({ } outputBase = path.resolve(rawOutputBase ?? defaultOutputBase) - outputPath = singleFeature + outputDir = singleFeature ? outputBase : path.join(outputBase, defaultUnminifyOutputFolder) } @@ -391,19 +392,28 @@ async function interactive({ } } - log.step('Unminifying...') + log.step(`Unminifying... ${c.dim(`(concurrency: ${concurrency})`)}`) const s = spinner() s.start('...') const timing = new Timing() - const concurrencyManager = new Concurrency({ concurrency }) + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { + errorHandler: e => console.error(e), + }) + const execute = async (inputPath: string) => { + const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) + const result = await pool.execute({ + inputPath, + outputPath, + moduleMeta, + moduleMapping, + }) + s.message(`${c.green(path.relative(cwd, inputPath))}`) + return result + } const { time: elapsed } = await timing.measureTimeAsync(() => Promise.all( - unminifyInputPaths.map(p => concurrencyManager.add(async () => { - const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath) - s.message(`${c.green(path.relative(cwd, p))}`) - return result - })), + unminifyInputPaths.map(p => execute(p)), )) s.stop('Finished') @@ -412,7 +422,7 @@ async function interactive({ log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) - outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) + outro(`Output directory: ${c.green(getRelativePath(cwd, outputDir))}`) } console.log() @@ -488,14 +498,9 @@ async function nonInteractive(features: Feature[], { } } - if (concurrency !== undefined) { - if (concurrency < 1) concurrency = 1 - - const cpus = os.cpus().length - if (concurrency > cpus) { - log.warning(`Concurrency is more than CPU cores (${concurrency} > ${cpus})`) - } - } + const minConcurrency = 1 + const maxConcurrency = availableParallelism() + concurrency = Math.min(maxConcurrency, Math.max(minConcurrency, concurrency)) outro(`Selected features: ${c.green(features.join(', '))}`) @@ -509,8 +514,6 @@ async function nonInteractive(features: Feature[], { const outputPath = path.resolve(unpackerOutput) const relativeOutputPath = getRelativePath(cwd, outputPath) - log.step('Unpacking...') - const s = spinner() s.start('...') @@ -559,24 +562,36 @@ async function nonInteractive(features: Feature[], { return process.exit(1) } - const outputPath = path.resolve(unminifyOutput) - const relativeOutputPath = getRelativePath(cwd, outputPath) + const outputDir = path.resolve(unminifyOutput) + const relativeOutputPath = getRelativePath(cwd, outputDir) - log.step('Unminifying...') + log.step(`Unminifying... ${c.dim(`(concurrency: ${concurrency})`)}`) const s = spinner() s.start('...') const timing = new Timing() - const concurrencyManager = new Concurrency({ concurrency }) + + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { + errorHandler: e => console.error(e), + }) + const execute = async (inputPath: string) => { + const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) + const result = await pool.execute({ + inputPath, + outputPath, + moduleMeta, + moduleMapping, + }) + s.message(`${c.green(path.relative(cwd, inputPath))}`) + return result + } const { time: elapsed } = await timing.measureTimeAsync(() => Promise.all( - unminifyInputPaths.map(p => concurrencyManager.add(async () => { - const result = await unminify(p, moduleMapping, moduleMeta, commonBaseDir, outputPath) - s.message(`${c.green(path.relative(cwd, p))}`) - return result - })), + unminifyInputPaths.map(p => execute(p)), )) + pool.destroy() + s.stop('Finished') const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) diff --git a/packages/cli/src/concurrency.ts b/packages/cli/src/concurrency.ts deleted file mode 100644 index d254c816..00000000 --- a/packages/cli/src/concurrency.ts +++ /dev/null @@ -1,51 +0,0 @@ -// From https://github.com/fabiospampinato/promise-concurrency-limiter -// with MIT license -export class Concurrency { - private concurrency: number - private count: number - private queue: Set<() => void> - - constructor(options: { concurrency: number }) { - this.concurrency = options.concurrency - this.count = 0 - this.queue = new Set() - } - - public add(fn: () => Promise): Promise { - if (this.count < this.concurrency) { - return this.run(fn) - } - - return new Promise((resolve) => { - const callback = (): void => resolve(this.run(fn)) - - this.queue.add(callback) - }) - } - - private flush(): void { - for (const callback of this.queue) { - if (this.count >= this.concurrency) break - - this.queue.delete(callback) - - callback() - } - } - - private run(fn: () => Promise): Promise { - this.count++ - - const promise = fn() - - const cleanup = (): void => { - this.count-- - - this.flush() - } - - promise.then(cleanup, cleanup) - - return promise - } -} diff --git a/packages/cli/src/unminify.ts b/packages/cli/src/unminify.ts deleted file mode 100644 index f49cf92d..00000000 --- a/packages/cli/src/unminify.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* eslint-disable no-console */ -import path from 'node:path' -import { Worker } from 'node:worker_threads' -import fsa from 'fs-extra' -import { Timing } from './perf' -import type { UnminifyWorkerParams } from './types' -import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' - -export interface UnminifyItem { - elapsed: number -} - -export async function unminify( - filePath: string, - moduleMapping: ModuleMapping, - moduleMeta: ModuleMeta, - baseDir: string, - outputDir: string, -) { - await fsa.ensureDir(outputDir) - - const timing = new Timing() - - const { time: elapsed } = await timing.measureTimeAsync(async () => { - return runUnminifyInWorker({ - inputPath: filePath, - outputPath: path.join(outputDir, path.relative(baseDir, filePath)), - moduleMeta, - moduleMapping, - }) - }) - - return { - elapsed, - } -} - -function runUnminifyInWorker(params: UnminifyWorkerParams) { - return new Promise((resolve, reject) => { - const worker = new Worker( - new URL('./unminify.worker.cjs', import.meta.url), - { workerData: params }, - ) - - worker.on('message', resolve) - worker.on('error', reject) - worker.on('exit', (code) => { - if (code !== 0) { - reject(new Error(`Worker stopped with exit code ${code}`)) - } - }) - }) -} diff --git a/packages/cli/src/unminify.worker.ts b/packages/cli/src/unminify.worker.ts index 84f3ceff..00dea277 100644 --- a/packages/cli/src/unminify.worker.ts +++ b/packages/cli/src/unminify.worker.ts @@ -1,37 +1,42 @@ import path from 'node:path' import process from 'node:process' -import { parentPort, workerData } from 'node:worker_threads' import { runTransformations, transformationRules } from '@wakaru/unminify' import fsa from 'fs-extra' +import { ThreadWorker } from 'poolifier' import { Timing } from './perf' import type { UnminifyWorkerParams } from './types' import type { Transform } from 'jscodeshift' -try { - const { inputPath, outputPath, moduleMeta, moduleMapping } = workerData as UnminifyWorkerParams +export function unminify(data?: UnminifyWorkerParams) { + if (!data) throw new Error('No data received') - const timing = new Timing() - const cwd = process.cwd() - const filename = path.relative(cwd, inputPath) - const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) + try { + const { inputPath, outputPath, moduleMeta, moduleMapping } = data - const source = fsa.readFileSync(inputPath, 'utf-8') - const fileInfo = { path: inputPath, source } + const timing = new Timing() + const cwd = process.cwd() + const filename = path.relative(cwd, inputPath) + const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) - const transformations = transformationRules.map((rule) => { - const { id, transform } = rule - return (...args: Parameters) => measure(id, () => transform(...args)) - }) + const source = fsa.readFileSync(inputPath, 'utf-8') + const fileInfo = { path: inputPath, source } - const { code } = runTransformations(fileInfo, transformations, { moduleMeta, moduleMapping }) - fsa.writeFileSync(outputPath, code, 'utf-8') + const transformations = transformationRules.map((rule) => { + const { id, transform } = rule + return (...args: Parameters) => measure(id, () => transform(...args)) + }) - parentPort?.postMessage(code) + const { code } = runTransformations(fileInfo, transformations, { moduleMeta, moduleMapping }) + fsa.ensureFileSync(outputPath) + fsa.writeFileSync(outputPath, code, 'utf-8') - process.exit(0) -} -catch (e) { - // We print the error here because it will lose the stack trace after being sent to the main thread - console.error(e) - throw e + return code + } + catch (e) { + // We print the error here because it will lose the stack trace after being sent to the main thread + console.error(e) + throw e + } } + +export default new ThreadWorker(unminify) diff --git a/packages/cli/src/unpacker.ts b/packages/cli/src/unpacker.ts index 70449b4c..544af96a 100644 --- a/packages/cli/src/unpacker.ts +++ b/packages/cli/src/unpacker.ts @@ -30,7 +30,7 @@ export async function unpacker( for (const mod of modules) { const filename = moduleIdMapping[mod.id] ?? `module-${mod.id}.js` const outputPath = path.join(outputDir, filename) - await fsa.ensureDir(path.dirname(outputPath)) + await fsa.ensureFile(outputPath) await fsa.writeFile(outputPath, mod.code, 'utf-8') files.push(outputPath) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f864b2c3..6e8b0ef6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: picocolors: specifier: ^1.0.0 version: 1.0.0 + poolifier: + specifier: ^3.0.14 + version: 3.0.14 yargs: specifier: ^17.7.2 version: 17.7.2 @@ -7973,6 +7976,12 @@ packages: engines: {node: '>=4'} dev: true + /poolifier@3.0.14: + resolution: {integrity: sha512-bER0wR3NADyvQpexHY6fbVd+rikk4hxt1tzIhKkwOcoJcqkoD+eAtN+2sVbAIUYFqwhNdeaZQwmpxcDlZ2jv3Q==} + engines: {node: '>=18.0.0', pnpm: '>=8.6.0'} + requiresBuild: true + dev: false + /postcss-import@15.1.0(postcss@8.4.31): resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==} engines: {node: '>=14.0.0'} From 64548dac4371bc0071152dcbd17a261eb0b1bbec Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Thu, 14 Dec 2023 00:42:55 +0800 Subject: [PATCH 12/19] docs: update README.md --- README.md | 60 ++++++++++--------------------------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 53584f99..14f82038 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Test the tool and see it in action at [Playground][Playground]. ### Interactive mode By default, the CLI will run in interactive mode and guide you through the process.\ -You can also pass options to skip some steps in the interactive mode. +You can also pass [options](#options) to skip some steps in the interactive mode. ```sh npx @wakaru/cli @@ -56,56 +56,18 @@ npx @wakaru/cli pnpm dlx @wakaru/cli ``` -
- Expand to see the example output - -```sh -┌ Wakaru CLI -│ -◇ Select features to use (Use to select, to submit) -│ Unpacker, Unminify -│ -└ Selected features: Unpacker, Unminify - -┌ Unpacker -│ -◇ Input file path (Supports glob patterns) -│ ./input.js -│ -◇ Output directory path ( to accept default) -│ ./out -│ -◇ Unpacking... -│ -◇ Finished -│ -◆ Successfully generated 33 modules (0ms) -│ -└ Output directory: .\out\unpack - -┌ Unminify -│ -◇ Unminifying... -│ -◇ Finished -│ -◆ Successfully unminified 33 files -│ -└ Output directory: .\out\unminify -``` - -
- ### Options Run `npx @wakaru/cli --help` to see the full list of options. -| Option | Default | Description | -| --------------- | ------- | ---------------------------------- | -| `--output` | `"out"` | Output directory | -| `--force` | `false` | Force overwrite output directory | -| `--concurrency` | `1` | Maximum number of concurrent tasks | -| `--perf` | `false` | Show performance metrics | +| Option | Default | Description | +| --------------- | ------- | --------------------------------------- | +| `--output` | `"out"` | Output directory | +| `--force` | `false` | Force overwrite output directory | +| `--concurrency` | `1` | Specific the number of concurrent tasks | +| `--perf` | `false` | Show performance metrics | + +`--concurrency` can be used to speed up the process. But please aware that the process might OOM if the input file is too large. ### Non-interactive mode @@ -122,8 +84,8 @@ npx @wakaru/cli unminify [options] These options are **only** available in `all` mode. -| Option | Default | Description | -| ------------------- | -------------- | ---------------------------------- | +| Option | Default | Description | +| ------------------- | ---------------- | ---------------------------------- | | `--unpacker-output` | `"out/unpack"` | Override unpacker output directory | | `--unminify-output` | `"out/unminify"` | Override unminify output directory | From 5d15f378bda18965a20a7f15d631e11b880641c0 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Thu, 14 Dec 2023 00:53:44 +0800 Subject: [PATCH 13/19] refactor(cli): simplify unminify worker --- packages/cli/src/cli.ts | 4 ++-- packages/cli/src/unminify.worker.ts | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 415234d4..563f4fb9 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -398,7 +398,7 @@ async function interactive({ s.start('...') const timing = new Timing() - const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { errorHandler: e => console.error(e), }) const execute = async (inputPath: string) => { @@ -572,7 +572,7 @@ async function nonInteractive(features: Feature[], { const timing = new Timing() - const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { errorHandler: e => console.error(e), }) const execute = async (inputPath: string) => { diff --git a/packages/cli/src/unminify.worker.ts b/packages/cli/src/unminify.worker.ts index 00dea277..35916032 100644 --- a/packages/cli/src/unminify.worker.ts +++ b/packages/cli/src/unminify.worker.ts @@ -7,30 +7,26 @@ import { Timing } from './perf' import type { UnminifyWorkerParams } from './types' import type { Transform } from 'jscodeshift' -export function unminify(data?: UnminifyWorkerParams) { +export async function unminify(data?: UnminifyWorkerParams) { if (!data) throw new Error('No data received') try { const { inputPath, outputPath, moduleMeta, moduleMapping } = data - const timing = new Timing() const cwd = process.cwd() const filename = path.relative(cwd, inputPath) - const measure = (key: string, fn: () => T) => timing.collect(filename, key, fn) - - const source = fsa.readFileSync(inputPath, 'utf-8') + const source = await fsa.readFile(inputPath, 'utf-8') const fileInfo = { path: inputPath, source } + const timing = new Timing() const transformations = transformationRules.map((rule) => { const { id, transform } = rule - return (...args: Parameters) => measure(id, () => transform(...args)) + return (...args: Parameters) => timing.collect(filename, id, () => transform(...args)) }) const { code } = runTransformations(fileInfo, transformations, { moduleMeta, moduleMapping }) - fsa.ensureFileSync(outputPath) - fsa.writeFileSync(outputPath, code, 'utf-8') - - return code + await fsa.ensureFile(outputPath) + await fsa.writeFile(outputPath, code, 'utf-8') } catch (e) { // We print the error here because it will lose the stack trace after being sent to the main thread @@ -39,4 +35,4 @@ export function unminify(data?: UnminifyWorkerParams) { } } -export default new ThreadWorker(unminify) +export default new ThreadWorker(unminify) From fd89c1e051b61a68a31dbbe76bfbc64a39dc30e6 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Thu, 14 Dec 2023 01:04:07 +0800 Subject: [PATCH 14/19] fix: update clack patch and remove spinner for unpacking --- .vscode/settings.json | 4 +- package.json | 3 +- packages/cli/src/cli.ts | 10 +- patches/@clack__core@0.3.3.patch | 8 +- patches/@clack__prompts@0.7.0.patch | 367 ---------------------------- pnpm-lock.yaml | 16 +- 6 files changed, 16 insertions(+), 392 deletions(-) delete mode 100644 patches/@clack__prompts@0.7.0.patch diff --git a/.vscode/settings.json b/.vscode/settings.json index db948378..d764d28b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,8 +2,8 @@ "eslint.experimental.useFlatConfig": true, "editor.codeActionsOnSave": { "source.fixAll": "explicit", - "source.fixAll.eslint": true, // this allows ESLint to auto fix on save - "source.organizeImports": false + "source.fixAll.eslint": "explicit", + "source.organizeImports": "never" }, "editor.formatOnSave": false, "eslint.validate": [ diff --git a/package.json b/package.json index 23c75fad..8bb67f1d 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,7 @@ "pnpm": { "patchedDependencies": { "ast-types@0.16.1": "patches/ast-types@0.16.1.patch", - "@clack/core@0.3.3": "patches/@clack__core@0.3.3.patch", - "@clack/prompts@0.7.0": "patches/@clack__prompts@0.7.0.patch" + "@clack/core@0.3.3": "patches/@clack__core@0.3.3.patch" } }, "resolutions": { diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 563f4fb9..acf5823c 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -273,13 +273,10 @@ async function interactive({ log.step('Unpacking...') - const s = spinner() - s.start('...') - const timing = new Timing() const { result: items, time: elapsed } = await timing.measureTimeAsync(() => unpacker(inputPaths, outputPath)) - s.stop('Finished') + log.step('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) @@ -514,13 +511,12 @@ async function nonInteractive(features: Feature[], { const outputPath = path.resolve(unpackerOutput) const relativeOutputPath = getRelativePath(cwd, outputPath) - const s = spinner() - s.start('...') + log.step('Unpacking...') const timing = new Timing() const { result: items, time: elapsed } = await timing.measureTimeAsync(() => unpacker(inputPaths, outputPath)) - s.stop('Finished') + log.step('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) diff --git a/patches/@clack__core@0.3.3.patch b/patches/@clack__core@0.3.3.patch index 6fb443c5..3c48aa4e 100644 --- a/patches/@clack__core@0.3.3.patch +++ b/patches/@clack__core@0.3.3.patch @@ -1,5 +1,5 @@ diff --git a/dist/index.cjs b/dist/index.cjs -index 5f3b334a0dd9e92f77b37be07a74b713bb928b20..67b1440224b59338b1c261f8ecafbbd6a444768a 100644 +index 5f3b334a0dd9e92f77b37be07a74b713bb928b20..b4ac243bdeb17048d69d5fb56bfa84ea0a5f5d74 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -1,14 +1,15 @@ @@ -29,7 +29,7 @@ index 5f3b334a0dd9e92f77b37be07a74b713bb928b20..67b1440224b59338b1c261f8ecafbbd6 +`).length-1;this.output.write(sisteransi.cursor.move(-999,F*-1))}render(){const F=wrapAnsi(this._render(this)??"",process.stdout.columns,{hard:!0});if(F!==this._prevFrame){if(this.state==="initial")this.output.write(sisteransi.cursor.hide);else{const t=g(this._prevFrame,F);if(this.restoreCursor(),t&&t?.length===1){const E=t[0];this.output.write(sisteransi.cursor.move(0,E)),this.output.write(sisteransi.erase.lines(1));const x=F.split(` +`);this.output.write(x[E]),this._prevFrame=F,this.output.write(sisteransi.cursor.move(0,x.length-E-1));return}else if(t&&t?.length>1){const E=t[0];this.output.write(sisteransi.cursor.move(0,E)),this.output.write(sisteransi.erase.down());const x=F.split(` +`).slice(E);this.output.write(x.join(` -+`)),this._prevFrame=F;return}this.output.write(sisteransi.erase.down())}this.output.write(F),this.state==="initial"&&(this.state="active"),this._prevFrame=F}}}class s extends _{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(F){super(F,!1),this.value=!!F.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(sisteransi.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var a=Object.defineProperty,n$3=(C,F,t)=>F in C?a(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,l$3=(C,F,t)=>(n$3(C,typeof F!="symbol"?F+"":F,t),t);class p extends _{constructor(F){super(F,!1),l$3(this,"options"),l$3(this,"cursor",0);const{options:t}=F;this.options=Object.entries(t).flatMap(([E,x])=>[{value:E,group:!0,label:E},...x.map(B=>({...B,group:E}))]),this.value=[...F.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:E})=>E===F.cursorAt),0),this.on("cursor",E=>{switch(E){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(F){return this.options.filter(t=>t.group===F)}isGroupSelected(F){return this.getGroupItems(F).every(t=>this.value.includes(t.value))}toggleValue(){const F=this.options[this.cursor];if(F.group===!0){const t=F.value,E=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(x=>E.findIndex(B=>B.value===x)===-1):this.value=[...this.value,...E.map(x=>x.value)],this.value=Array.from(new Set(this.value))}else{const t=this.value.includes(F.value);this.value=t?this.value.filter(E=>E!==F.value):[...this.value,F.value]}}}var o$2=Object.defineProperty,r$1=(C,F,t)=>F in C?o$2(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,l$2=(C,F,t)=>(r$1(C,typeof F!="symbol"?F+"":F,t),t);let u$3=class extends _{constructor(F){super(F,!1),l$2(this,"options"),l$2(this,"cursor",0),this.options=F.options,this.value=[...F.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===F.cursorAt),0),this.on("key",t=>{t==="a"&&this.toggleAll()}),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const F=this.value.length===this.options.length;this.value=F?[]:this.options.map(t=>t.value)}toggleValue(){const F=this.value.includes(this._value);this.value=F?this.value.filter(t=>t!==this._value):[...this.value,this._value]}};var u$2=Object.defineProperty,n$2=(C,F,t)=>F in C?u$2(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,e=(C,F,t)=>(n$2(C,typeof F!="symbol"?F+"":F,t),t);class m extends _{constructor({mask:F,...t}){super(t),e(this,"valueWithCursor",""),e(this,"_mask","\u2022"),this._mask=F??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${i__default.inverse(i__default.hidden("_"))}`;else{const E=this.masked.slice(0,this.cursor),x=this.masked.slice(this.cursor);this.valueWithCursor=`${E}${i__default.inverse(x[0])}${x.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}var o$1=Object.defineProperty,n$1=(C,F,t)=>F in C?o$1(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,r=(C,F,t)=>(n$1(C,typeof F!="symbol"?F+"":F,t),t);let u$1=class extends _{constructor(F){super(F,!1),r(this,"options"),r(this,"cursor",0),this.options=F.options,this.cursor=this.options.findIndex(({value:t})=>t===F.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var u=Object.defineProperty,l$1=(C,F,t)=>F in C?u(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,i=(C,F,t)=>(l$1(C,typeof F!="symbol"?F+"":F,t),t);class c extends _{constructor(F){super(F,!1),i(this,"options"),i(this,"cursor",0),this.options=F.options;const t=this.options.map(({value:[E]})=>E?.toLowerCase());this.cursor=Math.max(t.indexOf(F.initialValue),0),this.on("key",E=>{if(!t.includes(E))return;const x=this.options.find(({value:[B]})=>B?.toLowerCase()===E);x&&(this.value=x.value,this.state="submit",this.emit("submit"))})}}var l=Object.defineProperty,h=(C,F,t)=>F in C?l(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,o=(C,F,t)=>(h(C,typeof F!="symbol"?F+"":F,t),t);class n extends _{constructor(F){super(F),o(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=F.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${i__default.inverse(i__default.hidden("_"))}`;else{const t=this.value.slice(0,this.cursor),E=this.value.slice(this.cursor);this.valueWithCursor=`${t}${i__default.inverse(E[0])}${E.slice(1)}`}})}get cursor(){return this._cursor}}function block({input:C=node_process.stdin,output:F=node_process.stdout,overwrite:t=!0,hideCursor:E=!0}={}){const x=r__namespace.createInterface({input:C,output:F,prompt:"",tabSize:1});r__namespace.emitKeypressEvents(C,x),C.isTTY&&C.setRawMode(!0);const B=(D,{name:A})=>{if(String(D)===""&&process.exit(0),!t)return;let w=A==="return"?0:-1,v=A==="return"?-1:0;r__namespace.moveCursor(F,w,v,()=>{r__namespace.clearLine(F,1,()=>{C.once("keypress",B)})})};return E&&process.stdout.write(sisteransi.cursor.hide),C.once("keypress",B),()=>{C.off("keypress",B),E&&process.stdout.write(sisteransi.cursor.show),x.terminal=!1,x.close()}}exports.ConfirmPrompt=s,exports.GroupMultiSelectPrompt=p,exports.MultiSelectPrompt=u$3,exports.PasswordPrompt=m,exports.Prompt=_,exports.SelectKeyPrompt=c,exports.SelectPrompt=u$1,exports.TextPrompt=n,exports.block=block,exports.isCancel=isCancel; ++`)),this._prevFrame=F;return}this.output.write(sisteransi.erase.down())}this.output.write(F),this.state==="initial"&&(this.state="active"),this._prevFrame=F}}}class s extends _{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(F){super(F,!1),this.value=!!F.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",t=>{this.output.write(sisteransi.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var a=Object.defineProperty,n$3=(C,F,t)=>F in C?a(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,l$3=(C,F,t)=>(n$3(C,typeof F!="symbol"?F+"":F,t),t);class p extends _{constructor(F){super(F,!1),l$3(this,"options"),l$3(this,"cursor",0);const{options:t}=F;this.options=Object.entries(t).flatMap(([E,x])=>[{value:E,group:!0,label:E},...x.map(B=>({...B,group:E}))]),this.value=[...F.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:E})=>E===F.cursorAt),0),this.on("cursor",E=>{switch(E){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(F){return this.options.filter(t=>t.group===F)}isGroupSelected(F){return this.getGroupItems(F).every(t=>this.value.includes(t.value))}toggleValue(){const F=this.options[this.cursor];if(F.group===!0){const t=F.value,E=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(x=>E.findIndex(B=>B.value===x)===-1):this.value=[...this.value,...E.map(x=>x.value)],this.value=Array.from(new Set(this.value))}else{const t=this.value.includes(F.value);this.value=t?this.value.filter(E=>E!==F.value):[...this.value,F.value]}}}var o$2=Object.defineProperty,r$1=(C,F,t)=>F in C?o$2(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,l$2=(C,F,t)=>(r$1(C,typeof F!="symbol"?F+"":F,t),t);let u$3=class extends _{constructor(F){super(F,!1),l$2(this,"options"),l$2(this,"cursor",0),this.options=F.options,this.value=[...F.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===F.cursorAt),0),this.on("key",t=>{t==="a"&&this.toggleAll()}),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const F=this.value.length===this.options.length;this.value=F?[]:this.options.map(t=>t.value)}toggleValue(){const F=this.value.includes(this._value);this.value=F?this.value.filter(t=>t!==this._value):[...this.value,this._value]}};var u$2=Object.defineProperty,n$2=(C,F,t)=>F in C?u$2(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,e=(C,F,t)=>(n$2(C,typeof F!="symbol"?F+"":F,t),t);class m extends _{constructor({mask:F,...t}){super(t),e(this,"valueWithCursor",""),e(this,"_mask","\u2022"),this._mask=F??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${i__default.inverse(i__default.hidden("_"))}`;else{const E=this.masked.slice(0,this.cursor),x=this.masked.slice(this.cursor);this.valueWithCursor=`${E}${i__default.inverse(x[0])}${x.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}var o$1=Object.defineProperty,n$1=(C,F,t)=>F in C?o$1(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,r=(C,F,t)=>(n$1(C,typeof F!="symbol"?F+"":F,t),t);let u$1=class extends _{constructor(F){super(F,!1),r(this,"options"),r(this,"cursor",0),this.options=F.options,this.cursor=this.options.findIndex(({value:t})=>t===F.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",t=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var u=Object.defineProperty,l$1=(C,F,t)=>F in C?u(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,i=(C,F,t)=>(l$1(C,typeof F!="symbol"?F+"":F,t),t);class c extends _{constructor(F){super(F,!1),i(this,"options"),i(this,"cursor",0),this.options=F.options;const t=this.options.map(({value:[E]})=>E?.toLowerCase());this.cursor=Math.max(t.indexOf(F.initialValue),0),this.on("key",E=>{if(!t.includes(E))return;const x=this.options.find(({value:[B]})=>B?.toLowerCase()===E);x&&(this.value=x.value,this.state="submit",this.emit("submit"))})}}var l=Object.defineProperty,h=(C,F,t)=>F in C?l(C,F,{enumerable:!0,configurable:!0,writable:!0,value:t}):C[F]=t,o=(C,F,t)=>(h(C,typeof F!="symbol"?F+"":F,t),t);class n extends _{constructor(F){super(F),o(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=F.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${i__default.inverse(i__default.hidden("_"))}`;else{const t=this.value.slice(0,this.cursor),E=this.value.slice(this.cursor);this.valueWithCursor=`${t}${i__default.inverse(E[0])}${E.slice(1)}`}})}get cursor(){return this._cursor}}function block({input:C=node_process.stdin,output:F=node_process.stdout,overwrite:t=!0,hideCursor:E=!0}={}){const x=r__namespace.createInterface({input:C,output:F,prompt:"",tabSize:1});r__namespace.emitKeypressEvents(C,x),C.isTTY&&C.setRawMode(!0);const B=(D,{name:A})=>{if(String(D)===""&&process.exit(0),!t)return;let w=A==="return"?0:-1,v=A==="return"?-1:0;r__namespace.moveCursor(F,w,v,()=>{r__namespace.clearLine(F,1,()=>{C.once("keypress",B)})})};return E&&process.stdout.write(sisteransi.cursor.hide),C.once("keypress",B),()=>{C.off("keypress",B),E&&process.stdout.write(sisteransi.cursor.show),C.isTTY&&C.setRawMode(!1),x.terminal=!1,x.close()}}exports.ConfirmPrompt=s,exports.GroupMultiSelectPrompt=p,exports.MultiSelectPrompt=u$3,exports.PasswordPrompt=m,exports.Prompt=_,exports.SelectKeyPrompt=c,exports.SelectPrompt=u$1,exports.TextPrompt=n,exports.block=block,exports.isCancel=isCancel; +//# sourceMappingURL=index.cjs.map diff --git a/dist/index.d.ts b/dist/index.d.ts index c86606801795decb5a2a61c858e7c4c1c9606510..1f9534c831ffbf563bae8a01cc6935a89eb0d362 100644 @@ -50,7 +50,7 @@ index c86606801795decb5a2a61c858e7c4c1c9606510..1f9534c831ffbf563bae8a01cc6935a8 -export { ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, State, TextPrompt, block, isCancel }; +export { ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, PasswordPrompt, Prompt, SelectKeyPrompt, SelectPrompt, type State, TextPrompt, block, isCancel }; diff --git a/dist/index.mjs b/dist/index.mjs -index a9acb4cff1f5a6cd587eb30a846ce0f6009765e9..af702caf101666267d662f0888c33da363c5fbc7 100644 +index a9acb4cff1f5a6cd587eb30a846ce0f6009765e9..ffd485c9eefbc462bfacc5dd6a3aa0b839de7e71 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -1,14 +1,15 @@ @@ -79,5 +79,5 @@ index a9acb4cff1f5a6cd587eb30a846ce0f6009765e9..af702caf101666267d662f0888c33da3 +`).length-1;this.output.write(l.move(-999,u*-1))}render(){const u=R(this._render(this)??"",process.stdout.columns,{hard:!0});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(l.hide);else{const F=aD(this._prevFrame,u);if(this.restoreCursor(),F&&F?.length===1){const e=F[0];this.output.write(l.move(0,e)),this.output.write(m.lines(1));const s=u.split(` +`);this.output.write(s[e]),this._prevFrame=u,this.output.write(l.move(0,s.length-e-1));return}else if(F&&F?.length>1){const e=F[0];this.output.write(l.move(0,e)),this.output.write(m.down());const s=u.split(` +`).slice(e);this.output.write(s.join(` -+`)),this._prevFrame=u;return}this.output.write(m.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}class xD extends x{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",F=>{this.output.write(l.move(0,-1)),this.value=F,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var BD=Object.defineProperty,cD=(t,u,F)=>u in t?BD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,G=(t,u,F)=>(cD(t,typeof u!="symbol"?u+"":u,F),F);class AD extends x{constructor(u){super(u,!1),G(this,"options"),G(this,"cursor",0);const{options:F}=u;this.options=Object.entries(F).flatMap(([e,s])=>[{value:e,group:!0,label:e},...s.map(C=>({...C,group:e}))]),this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===u.cursorAt),0),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(u){return this.options.filter(F=>F.group===u)}isGroupSelected(u){return this.getGroupItems(u).every(F=>this.value.includes(F.value))}toggleValue(){const u=this.options[this.cursor];if(u.group===!0){const F=u.value,e=this.getGroupItems(F);this.isGroupSelected(F)?this.value=this.value.filter(s=>e.findIndex(C=>C.value===s)===-1):this.value=[...this.value,...e.map(s=>s.value)],this.value=Array.from(new Set(this.value))}else{const F=this.value.includes(u.value);this.value=F?this.value.filter(e=>e!==u.value):[...this.value,u.value]}}}var pD=Object.defineProperty,fD=(t,u,F)=>u in t?pD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,K=(t,u,F)=>(fD(t,typeof u!="symbol"?u+"":u,F),F);let gD=class extends x{constructor(u){super(u,!1),K(this,"options"),K(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===u.cursorAt),0),this.on("key",F=>{F==="a"&&this.toggleAll()}),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(F=>F.value)}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(F=>F!==this._value):[...this.value,this._value]}};var vD=Object.defineProperty,mD=(t,u,F)=>u in t?vD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,Y=(t,u,F)=>(mD(t,typeof u!="symbol"?u+"":u,F),F);class dD extends x{constructor({mask:u,...F}){super(F),Y(this,"valueWithCursor",""),Y(this,"_mask","\u2022"),this._mask=u??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${c.inverse(c.hidden("_"))}`;else{const e=this.masked.slice(0,this.cursor),s=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${c.inverse(s[0])}${s.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}var bD=Object.defineProperty,wD=(t,u,F)=>u in t?bD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,Z=(t,u,F)=>(wD(t,typeof u!="symbol"?u+"":u,F),F);let yD=class extends x{constructor(u){super(u,!1),Z(this,"options"),Z(this,"cursor",0),this.options=u.options,this.cursor=this.options.findIndex(({value:F})=>F===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var $D=Object.defineProperty,kD=(t,u,F)=>u in t?$D(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,H=(t,u,F)=>(kD(t,typeof u!="symbol"?u+"":u,F),F);class _D extends x{constructor(u){super(u,!1),H(this,"options"),H(this,"cursor",0),this.options=u.options;const F=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(F.indexOf(u.initialValue),0),this.on("key",e=>{if(!F.includes(e))return;const s=this.options.find(({value:[C]})=>C?.toLowerCase()===e);s&&(this.value=s.value,this.state="submit",this.emit("submit"))})}}var SD=Object.defineProperty,jD=(t,u,F)=>u in t?SD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,MD=(t,u,F)=>(jD(t,typeof u!="symbol"?u+"":u,F),F);class PD extends x{constructor(u){super(u),MD(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=u.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${c.inverse(c.hidden("_"))}`;else{const F=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${F}${c.inverse(e[0])}${e.slice(1)}`}})}get cursor(){return this._cursor}}function TD({input:t=$,output:u=k,overwrite:F=!0,hideCursor:e=!0}={}){const s=f.createInterface({input:t,output:u,prompt:"",tabSize:1});f.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);const C=(D,{name:i})=>{if(String(D)===""&&process.exit(0),!F)return;let n=i==="return"?0:-1,E=i==="return"?-1:0;f.moveCursor(u,n,E,()=>{f.clearLine(u,1,()=>{t.once("keypress",C)})})};return e&&process.stdout.write(l.hide),t.once("keypress",C),()=>{t.off("keypress",C),e&&process.stdout.write(l.show),s.terminal=!1,s.close()}}export{xD as ConfirmPrompt,AD as GroupMultiSelectPrompt,gD as MultiSelectPrompt,dD as PasswordPrompt,x as Prompt,_D as SelectKeyPrompt,yD as SelectPrompt,PD as TextPrompt,TD as block,hD as isCancel}; ++`)),this._prevFrame=u;return}this.output.write(m.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}class xD extends x{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",F=>{this.output.write(l.move(0,-1)),this.value=F,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var BD=Object.defineProperty,cD=(t,u,F)=>u in t?BD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,G=(t,u,F)=>(cD(t,typeof u!="symbol"?u+"":u,F),F);class AD extends x{constructor(u){super(u,!1),G(this,"options"),G(this,"cursor",0);const{options:F}=u;this.options=Object.entries(F).flatMap(([e,s])=>[{value:e,group:!0,label:e},...s.map(C=>({...C,group:e}))]),this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===u.cursorAt),0),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(u){return this.options.filter(F=>F.group===u)}isGroupSelected(u){return this.getGroupItems(u).every(F=>this.value.includes(F.value))}toggleValue(){const u=this.options[this.cursor];if(u.group===!0){const F=u.value,e=this.getGroupItems(F);this.isGroupSelected(F)?this.value=this.value.filter(s=>e.findIndex(C=>C.value===s)===-1):this.value=[...this.value,...e.map(s=>s.value)],this.value=Array.from(new Set(this.value))}else{const F=this.value.includes(u.value);this.value=F?this.value.filter(e=>e!==u.value):[...this.value,u.value]}}}var pD=Object.defineProperty,fD=(t,u,F)=>u in t?pD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,K=(t,u,F)=>(fD(t,typeof u!="symbol"?u+"":u,F),F);let gD=class extends x{constructor(u){super(u,!1),K(this,"options"),K(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===u.cursorAt),0),this.on("key",F=>{F==="a"&&this.toggleAll()}),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(F=>F.value)}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(F=>F!==this._value):[...this.value,this._value]}};var vD=Object.defineProperty,mD=(t,u,F)=>u in t?vD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,Y=(t,u,F)=>(mD(t,typeof u!="symbol"?u+"":u,F),F);class dD extends x{constructor({mask:u,...F}){super(F),Y(this,"valueWithCursor",""),Y(this,"_mask","\u2022"),this._mask=u??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${c.inverse(c.hidden("_"))}`;else{const e=this.masked.slice(0,this.cursor),s=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${c.inverse(s[0])}${s.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}}var bD=Object.defineProperty,wD=(t,u,F)=>u in t?bD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,Z=(t,u,F)=>(wD(t,typeof u!="symbol"?u+"":u,F),F);let yD=class extends x{constructor(u){super(u,!1),Z(this,"options"),Z(this,"cursor",0),this.options=u.options,this.cursor=this.options.findIndex(({value:F})=>F===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",F=>{switch(F){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var $D=Object.defineProperty,kD=(t,u,F)=>u in t?$D(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,H=(t,u,F)=>(kD(t,typeof u!="symbol"?u+"":u,F),F);class _D extends x{constructor(u){super(u,!1),H(this,"options"),H(this,"cursor",0),this.options=u.options;const F=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(F.indexOf(u.initialValue),0),this.on("key",e=>{if(!F.includes(e))return;const s=this.options.find(({value:[C]})=>C?.toLowerCase()===e);s&&(this.value=s.value,this.state="submit",this.emit("submit"))})}}var SD=Object.defineProperty,jD=(t,u,F)=>u in t?SD(t,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):t[u]=F,MD=(t,u,F)=>(jD(t,typeof u!="symbol"?u+"":u,F),F);class PD extends x{constructor(u){super(u),MD(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=u.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${c.inverse(c.hidden("_"))}`;else{const F=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor);this.valueWithCursor=`${F}${c.inverse(e[0])}${e.slice(1)}`}})}get cursor(){return this._cursor}}function TD({input:t=$,output:u=k,overwrite:F=!0,hideCursor:e=!0}={}){const s=f.createInterface({input:t,output:u,prompt:"",tabSize:1});f.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);const C=(D,{name:i})=>{if(String(D)===""&&process.exit(0),!F)return;let n=i==="return"?0:-1,E=i==="return"?-1:0;f.moveCursor(u,n,E,()=>{f.clearLine(u,1,()=>{t.once("keypress",C)})})};return e&&process.stdout.write(l.hide),t.once("keypress",C),()=>{t.off("keypress",C),e&&process.stdout.write(l.show),t.isTTY&&t.setRawMode(!1),s.terminal=!1,s.close()}}export{xD as ConfirmPrompt,AD as GroupMultiSelectPrompt,gD as MultiSelectPrompt,dD as PasswordPrompt,x as Prompt,_D as SelectKeyPrompt,yD as SelectPrompt,PD as TextPrompt,TD as block,hD as isCancel}; +//# sourceMappingURL=index.mjs.map diff --git a/patches/@clack__prompts@0.7.0.patch b/patches/@clack__prompts@0.7.0.patch deleted file mode 100644 index a6ef0459..00000000 --- a/patches/@clack__prompts@0.7.0.patch +++ /dev/null @@ -1,367 +0,0 @@ -diff --git a/dist/index.cjs b/dist/index.cjs -index 84256fcf4d4e0f84f398779edfdca2be11d10918..799e582560eae9e65c6eae98c514f723f27eab03 100644 ---- a/dist/index.cjs -+++ b/dist/index.cjs -@@ -1,77 +1,78 @@ --"use strict";const core=require("@clack/core"),process$1=require("node:process"),color=require("picocolors"),sisteransi=require("sisteransi");function isUnicodeSupported(){return process$1.platform!=="win32"?process$1.env.TERM!=="linux":Boolean(process$1.env.CI)||Boolean(process$1.env.WT_SESSION)||Boolean(process$1.env.TERMINUS_SUBLIME)||process$1.env.ConEmuTask==="{cmd::Cmder}"||process$1.env.TERM_PROGRAM==="Terminus-Sublime"||process$1.env.TERM_PROGRAM==="vscode"||process$1.env.TERM==="xterm-256color"||process$1.env.TERM==="alacritty"||process$1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const unicode=isUnicodeSupported(),s=(t,n)=>unicode?t:n,S_STEP_ACTIVE=s("\u25C6","*"),S_STEP_CANCEL=s("\u25A0","x"),S_STEP_ERROR=s("\u25B2","x"),S_STEP_SUBMIT=s("\u25C7","o"),S_BAR_START=s("\u250C","T"),S_BAR=s("\u2502","|"),S_BAR_END=s("\u2514","\u2014"),S_RADIO_ACTIVE=s("\u25CF",">"),S_RADIO_INACTIVE=s("\u25CB"," "),S_CHECKBOX_ACTIVE=s("\u25FB","[\u2022]"),S_CHECKBOX_SELECTED=s("\u25FC","[+]"),S_CHECKBOX_INACTIVE=s("\u25FB","[ ]"),S_PASSWORD_MASK=s("\u25AA","\u2022"),S_BAR_H=s("\u2500","-"),S_CORNER_TOP_RIGHT=s("\u256E","+"),S_CONNECT_LEFT=s("\u251C","+"),S_CORNER_BOTTOM_RIGHT=s("\u256F","+"),S_INFO=s("\u25CF","\u2022"),S_SUCCESS=s("\u25C6","*"),S_WARN=s("\u25B2","!"),S_ERROR=s("\u25A0","x"),symbol=t=>{switch(t){case"initial":case"active":return color.cyan(S_STEP_ACTIVE);case"cancel":return color.red(S_STEP_CANCEL);case"error":return color.yellow(S_STEP_ERROR);case"submit":return color.green(S_STEP_SUBMIT)}},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`,i=t.placeholder?color.inverse(t.placeholder[0])+color.dim(t.placeholder.slice(1)):color.inverse(color.hidden("_")),e=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()} --${color.yellow(S_BAR)} ${e} --${color.yellow(S_BAR_END)} ${color.yellow(this.error)} --`;case"submit":return`${n}${color.gray(S_BAR)} ${color.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${color.gray(S_BAR)} ${color.strikethrough(color.dim(this.value??""))}${this.value?.trim()?` --`+color.gray(S_BAR):""}`;default:return`${n}${color.cyan(S_BAR)} ${e} --${color.cyan(S_BAR_END)} --`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??S_PASSWORD_MASK,render(){const n=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`,i=this.valueWithCursor,e=this.masked;switch(this.state){case"error":return`${n.trim()} --${color.yellow(S_BAR)} ${e} --${color.yellow(S_BAR_END)} ${color.yellow(this.error)} --`;case"submit":return`${n}${color.gray(S_BAR)} ${color.dim(e)}`;case"cancel":return`${n}${color.gray(S_BAR)} ${color.strikethrough(color.dim(e??""))}${e?` --`+color.gray(S_BAR):""}`;default:return`${n}${color.cyan(S_BAR)} ${i} --${color.cyan(S_BAR_END)} --`}}}).prompt(),confirm=t=>{const n=t.active??"Yes",i=t.inactive??"No";return new core.ConfirmPrompt({active:n,inactive:i,initialValue:t.initialValue??!0,render(){const e=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`,r=this.value?n:i;switch(this.state){case"submit":return`${e}${color.gray(S_BAR)} ${color.dim(r)}`;case"cancel":return`${e}${color.gray(S_BAR)} ${color.strikethrough(color.dim(r))} --${color.gray(S_BAR)}`;default:return`${e}${color.cyan(S_BAR)} ${this.value?`${color.green(S_RADIO_ACTIVE)} ${n}`:`${color.dim(S_RADIO_INACTIVE)} ${color.dim(n)}`} ${color.dim("/")} ${this.value?`${color.dim(S_RADIO_INACTIVE)} ${color.dim(i)}`:`${color.green(S_RADIO_ACTIVE)} ${i}`} --${color.cyan(S_BAR_END)} --`}}}).prompt()},select=t=>{const n=(e,r)=>{const c=e.label??String(e.value);return r==="active"?`${color.green(S_RADIO_ACTIVE)} ${c} ${e.hint?color.dim(`(${e.hint})`):""}`:r==="selected"?`${color.dim(c)}`:r==="cancelled"?`${color.strikethrough(color.dim(c))}`:`${color.dim(S_RADIO_INACTIVE)} ${color.dim(c)}`};let i=0;return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const e=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`;switch(this.state){case"submit":return`${e}${color.gray(S_BAR)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${e}${color.gray(S_BAR)} ${n(this.options[this.cursor],"cancelled")} --${color.gray(S_BAR)}`;default:{const r=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+r-3?i=Math.max(Math.min(this.cursor-r+3,this.options.length-r),0):this.cursor0,a=ro===0&&c||o===u.length-1&&a?color.dim("..."):n(l,o+i===this.cursor?"active":"inactive")).join(` --${color.cyan(S_BAR)} `)} --${color.cyan(S_BAR_END)} --`}}}}).prompt()},selectKey=t=>{const n=(i,e="inactive")=>{const r=i.label??String(i.value);return e==="selected"?`${color.dim(r)}`:e==="cancelled"?`${color.strikethrough(color.dim(r))}`:e==="active"?`${color.bgCyan(color.gray(` ${i.value} `))} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:`${color.gray(color.bgWhite(color.inverse(` ${i.value} `)))} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const i=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${n(this.options.find(e=>e.value===this.value),"selected")}`;case"cancel":return`${i}${color.gray(S_BAR)} ${n(this.options[0],"cancelled")} --${color.gray(S_BAR)}`;default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r)=>n(e,r===this.cursor?"active":"inactive")).join(` --${color.cyan(S_BAR)} `)} --${color.cyan(S_BAR_END)} --`}}}).prompt()},multiselect=t=>{const n=(i,e)=>{const r=i.label??String(i.value);return e==="active"?`${color.cyan(S_CHECKBOX_ACTIVE)} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="selected"?`${color.green(S_CHECKBOX_SELECTED)} ${color.dim(r)}`:e==="cancelled"?`${color.strikethrough(color.dim(r))}`:e==="active-selected"?`${color.green(S_CHECKBOX_SELECTED)} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="submitted"?`${color.dim(r)}`:`${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(r)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. --${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`},render(){let i=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,"submitted")).join(color.dim(", "))||color.dim("none")}`;case"cancel":{const e=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(color.dim(", "));return`${i}${color.gray(S_BAR)} ${e.trim()?`${e} --${color.gray(S_BAR)}`:""}`}case"error":{const e=this.error.split(` --`).map((r,c)=>c===0?`${color.yellow(S_BAR_END)} ${color.yellow(r)}`:` ${r}`).join(` --`);return i+color.yellow(S_BAR)+" "+this.options.map((r,c)=>{const a=this.value.includes(r.value),l=c===this.cursor;return l&&a?n(r,"active-selected"):a?n(r,"selected"):n(r,l?"active":"inactive")}).join(` --${color.yellow(S_BAR)} `)+` --`+e+` --`}default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r)=>{const c=this.value.includes(e.value),a=r===this.cursor;return a&&c?n(e,"active-selected"):c?n(e,"selected"):n(e,a?"active":"inactive")}).join(` --${color.cyan(S_BAR)} `)} --${color.cyan(S_BAR_END)} --`}}}).prompt()},groupMultiselect=t=>{const n=(i,e,r=[])=>{const c=i.label??String(i.value),a=typeof i.group=="string",l=a&&(r[r.indexOf(i)+1]??{group:!0}),o=a&&l.group===!0,u=a?`${o?S_BAR_END:S_BAR} `:"";return e==="active"?`${color.dim(u)}${color.cyan(S_CHECKBOX_ACTIVE)} ${c} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="group-active"?`${u}${color.cyan(S_CHECKBOX_ACTIVE)} ${color.dim(c)}`:e==="group-active-selected"?`${u}${color.green(S_CHECKBOX_SELECTED)} ${color.dim(c)}`:e==="selected"?`${color.dim(u)}${color.green(S_CHECKBOX_SELECTED)} ${color.dim(c)}`:e==="cancelled"?`${color.strikethrough(color.dim(c))}`:e==="active-selected"?`${color.dim(u)}${color.green(S_CHECKBOX_SELECTED)} ${c} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="submitted"?`${color.dim(c)}`:`${color.dim(u)}${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(c)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. --${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`},render(){let i=`${color.gray(S_BAR)} --${symbol(this.state)} ${t.message} --`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,"submitted")).join(color.dim(", "))}`;case"cancel":{const e=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(color.dim(", "));return`${i}${color.gray(S_BAR)} ${e.trim()?`${e} --${color.gray(S_BAR)}`:""}`}case"error":{const e=this.error.split(` --`).map((r,c)=>c===0?`${color.yellow(S_BAR_END)} ${color.yellow(r)}`:` ${r}`).join(` --`);return`${i}${color.yellow(S_BAR)} ${this.options.map((r,c,a)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),o=c===this.cursor;return!o&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,l?"group-active-selected":"group-active",a):o&&l?n(r,"active-selected",a):l?n(r,"selected",a):n(r,o?"active":"inactive",a)}).join(` --${color.yellow(S_BAR)} `)} --${e} --`}default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r,c)=>{const a=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),l=r===this.cursor;return!l&&typeof e.group=="string"&&this.options[this.cursor].value===e.group?n(e,a?"group-active-selected":"group-active",c):l&&a?n(e,"active-selected",c):a?n(e,"selected",c):n(e,l?"active":"inactive",c)}).join(` --${color.cyan(S_BAR)} `)} --${color.cyan(S_BAR_END)} --`}}}).prompt()},strip=t=>t.replace(ansiRegex(),""),note=(t="",n="")=>{const i=` -+"use strict";const core=require("@clack/core"),process$1=require("node:process"),e=require("picocolors"),sisteransi=require("sisteransi");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const process__default=_interopDefaultCompat(process$1),e__default=_interopDefaultCompat(e);function isUnicodeSupported(){return process__default.platform!=="win32"?process__default.env.TERM!=="linux":!!process__default.env.CI||!!process__default.env.WT_SESSION||!!process__default.env.TERMINUS_SUBLIME||process__default.env.ConEmuTask==="{cmd::Cmder}"||process__default.env.TERM_PROGRAM==="Terminus-Sublime"||process__default.env.TERM_PROGRAM==="vscode"||process__default.env.TERM==="xterm-256color"||process__default.env.TERM==="alacritty"||process__default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var u$1=Object.defineProperty,i=(t,c,r)=>c in t?u$1(t,c,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[c]=r,n=(t,c,r)=>(i(t,typeof c!="symbol"?c+"":c,r),r);class Concurrency{constructor(c){n(this,"concurrency"),n(this,"count"),n(this,"queue"),this.concurrency=c.concurrency,this.count=0,this.queue=new Set}add(c){return this.count{const o=()=>r(this.run(c));this.queue.add(o)})}flush(){for(const c of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(c),c()}}run(c){this.count++;const r=c(),o=()=>{this.count--,this.flush()};return r.then(o,o),r}}const S=isUnicodeSupported(),u=(t,c)=>S?t:c,U=u("\u25C6","*"),R=u("\u25A0","x"),E=u("\u25B2","x"),b=u("\u25C7","o"),X=u("\u250C","T"),a=u("\u2502","|"),m=u("\u2514","\u2014"),V=u("\u25CF",">"),P=u("\u25CB"," "),T=u("\u25FB","[\u2022]"),v=u("\u25FC","[+]"),C=u("\u25FB","[ ]"),F=u("\u25AA","\u2022"),k=u("\u2500","-"),J=u("\u256E","+"),Y=u("\u251C","+"),Q=u("\u256F","+"),ee=u("\u25CF","\u2022"),te=u("\u25C6","*"),re=u("\u25B2","!"),se=u("\u25A0","x"),h=t=>{switch(t){case"initial":case"active":return e__default.cyan(U);case"cancel":return e__default.red(R);case"error":return e__default.yellow(E);case"submit":return e__default.green(b)}},O=t=>{const{cursor:c,options:r,style:o}=t,s=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);let l=0;c>=l+s-3?l=Math.max(Math.min(c-s+3,r.length-s),0):c0,d=s{const I=g===0&&$,x=g===M.length-1&&d;return I||x?e__default.dim("..."):o(p,g+l===c)})},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const c=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`,r=t.placeholder?e__default.inverse(t.placeholder[0])+e__default.dim(t.placeholder.slice(1)):e__default.inverse(e__default.hidden("_")),o=this.value?this.valueWithCursor:r;switch(this.state){case"error":return`${c.trim()} -+${e__default.yellow(a)} ${o} -+${e__default.yellow(m)} ${e__default.yellow(this.error)} -+`;case"submit":return`${c}${e__default.gray(a)} ${e__default.dim(this.value||t.placeholder)}`;case"cancel":return`${c}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(this.value??""))}${this.value?.trim()?` -+`+e__default.gray(a):""}`;default:return`${c}${e__default.cyan(a)} ${o} -+${e__default.cyan(m)} -+`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??F,render(){const c=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`,r=this.valueWithCursor,o=this.masked;switch(this.state){case"error":return`${c.trim()} -+${e__default.yellow(a)} ${o} -+${e__default.yellow(m)} ${e__default.yellow(this.error)} -+`;case"submit":return`${c}${e__default.gray(a)} ${e__default.dim(o)}`;case"cancel":return`${c}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(o??""))}${o?` -+`+e__default.gray(a):""}`;default:return`${c}${e__default.cyan(a)} ${r} -+${e__default.cyan(m)} -+`}}}).prompt(),confirm=t=>{const c=t.active??"Yes",r=t.inactive??"No";return new core.ConfirmPrompt({active:c,inactive:r,initialValue:t.initialValue??!0,render(){const o=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`,s=this.value?c:r;switch(this.state){case"submit":return`${o}${e__default.gray(a)} ${e__default.dim(s)}`;case"cancel":return`${o}${e__default.gray(a)} ${e__default.strikethrough(e__default.dim(s))} -+${e__default.gray(a)}`;default:return`${o}${e__default.cyan(a)} ${this.value?`${e__default.green(V)} ${c}`:`${e__default.dim(P)} ${e__default.dim(c)}`} ${e__default.dim("/")} ${this.value?`${e__default.dim(P)} ${e__default.dim(r)}`:`${e__default.green(V)} ${r}`} -+${e__default.cyan(m)} -+`}}}).prompt()},select=t=>{const c=(r,o)=>{const s=r.label??String(r.value);switch(o){case"selected":return`${e__default.dim(s)}`;case"active":return`${e__default.green(V)} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`;case"cancelled":return`${e__default.strikethrough(e__default.dim(s))}`;default:return`${e__default.dim(P)} ${e__default.dim(s)}`}};return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const r=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`;switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${c(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${e__default.gray(a)} ${c(this.options[this.cursor],"cancelled")} -+${e__default.gray(a)}`;default:return`${r}${e__default.cyan(a)} ${O({cursor:this.cursor,options:this.options,maxItems:t.maxItems,style:(o,s)=>c(o,s?"active":"inactive")}).join(` -+${e__default.cyan(a)} `)} -+${e__default.cyan(m)} -+`}}}).prompt()},selectKey=t=>{const c=(r,o="inactive")=>{const s=r.label??String(r.value);return o==="selected"?`${e__default.dim(s)}`:o==="cancelled"?`${e__default.strikethrough(e__default.dim(s))}`:o==="active"?`${e__default.bgCyan(e__default.gray(` ${r.value} `))} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`:`${e__default.gray(e__default.bgWhite(e__default.inverse(` ${r.value} `)))} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const r=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`;switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${c(this.options.find(o=>o.value===this.value),"selected")}`;case"cancel":return`${r}${e__default.gray(a)} ${c(this.options[0],"cancelled")} -+${e__default.gray(a)}`;default:return`${r}${e__default.cyan(a)} ${this.options.map((o,s)=>c(o,s===this.cursor?"active":"inactive")).join(` -+${e__default.cyan(a)} `)} -+${e__default.cyan(m)} -+`}}}).prompt()},multiselect=t=>{const c=(r,o)=>{const s=r.label??String(r.value);return o==="active"?`${e__default.cyan(T)} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="selected"?`${e__default.green(v)} ${e__default.dim(s)}`:o==="cancelled"?`${e__default.strikethrough(e__default.dim(s))}`:o==="active-selected"?`${e__default.green(v)} ${s} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="submitted"?`${e__default.dim(s)}`:`${e__default.dim(C)} ${e__default.dim(s)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option. -+${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){let r=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`;const o=(s,l)=>{const $=this.value.includes(s.value);return l&&$?c(s,"active-selected"):$?c(s,"selected"):c(s,l?"active":"inactive")};switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>c(s,"submitted")).join(e__default.dim(", "))||e__default.dim("none")}`;case"cancel":{const s=this.options.filter(({value:l})=>this.value.includes(l)).map(l=>c(l,"cancelled")).join(e__default.dim(", "));return`${r}${e__default.gray(a)} ${s.trim()?`${s} -+${e__default.gray(a)}`:""}`}case"error":{const s=this.error.split(` -+`).map((l,$)=>$===0?`${e__default.yellow(m)} ${e__default.yellow(l)}`:` ${l}`).join(` -+`);return r+e__default.yellow(a)+" "+O({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(` -+${e__default.yellow(a)} `)+` -+`+s+` -+`}default:return`${r}${e__default.cyan(a)} ${O({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(` -+${e__default.cyan(a)} `)} -+${e__default.cyan(m)} -+`}}}).prompt()},groupMultiselect=t=>{const c=(r,o,s=[])=>{const l=r.label??String(r.value),$=typeof r.group=="string",d=$&&(s[s.indexOf(r)+1]??{group:!0}),p=$&&d.group===!0,g=$?`${p?m:a} `:"";return o==="active"?`${e__default.dim(g)}${e__default.cyan(T)} ${l} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="group-active"?`${g}${e__default.cyan(T)} ${e__default.dim(l)}`:o==="group-active-selected"?`${g}${e__default.green(v)} ${e__default.dim(l)}`:o==="selected"?`${e__default.dim(g)}${e__default.green(v)} ${e__default.dim(l)}`:o==="cancelled"?`${e__default.strikethrough(e__default.dim(l))}`:o==="active-selected"?`${e__default.dim(g)}${e__default.green(v)} ${l} ${r.hint?e__default.dim(`(${r.hint})`):""}`:o==="submitted"?`${e__default.dim(l)}`:`${e__default.dim(g)}${e__default.dim(C)} ${e__default.dim(l)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option. -+${e__default.reset(e__default.dim(`Press ${e__default.gray(e__default.bgWhite(e__default.inverse(" space ")))} to select, ${e__default.gray(e__default.bgWhite(e__default.inverse(" enter ")))} to submit`))}`},render(){let r=`${e__default.gray(a)} -+${h(this.state)} ${t.message} -+`;switch(this.state){case"submit":return`${r}${e__default.gray(a)} ${this.options.filter(({value:o})=>this.value.includes(o)).map(o=>c(o,"submitted")).join(e__default.dim(", "))}`;case"cancel":{const o=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>c(s,"cancelled")).join(e__default.dim(", "));return`${r}${e__default.gray(a)} ${o.trim()?`${o} -+${e__default.gray(a)}`:""}`}case"error":{const o=this.error.split(` -+`).map((s,l)=>l===0?`${e__default.yellow(m)} ${e__default.yellow(s)}`:` ${s}`).join(` -+`);return`${r}${e__default.yellow(a)} ${this.options.map((s,l,$)=>{const d=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),p=l===this.cursor;return!p&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?c(s,d?"group-active-selected":"group-active",$):p&&d?c(s,"active-selected",$):d?c(s,"selected",$):c(s,p?"active":"inactive",$)}).join(` -+${e__default.yellow(a)} `)} -+${o} -+`}default:return`${r}${e__default.cyan(a)} ${this.options.map((o,s,l)=>{const $=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),d=s===this.cursor;return!d&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?c(o,$?"group-active-selected":"group-active",l):d&&$?c(o,"active-selected",l):$?c(o,"selected",l):c(o,d?"active":"inactive",l)}).join(` -+${e__default.cyan(a)} `)} -+${e__default.cyan(m)} -+`}}}).prompt()},_=t=>t.replace(ne(),""),note=(t="",c="")=>{const r=` - ${t} - `.split(` --`),e=strip(n).length,r=Math.max(i.reduce((a,l)=>(l=strip(l),l.length>a?l.length:a),0),e)+2,c=i.map(a=>`${color.gray(S_BAR)} ${color.dim(a)}${" ".repeat(r-strip(a).length)}${color.gray(S_BAR)}`).join(` --`);process.stdout.write(`${color.gray(S_BAR)} --${color.green(S_STEP_SUBMIT)} ${color.reset(n)} ${color.gray(S_BAR_H.repeat(Math.max(r-e-1,1))+S_CORNER_TOP_RIGHT)} --${c} --${color.gray(S_CONNECT_LEFT+S_BAR_H.repeat(r+2)+S_CORNER_BOTTOM_RIGHT)} --`)},cancel=(t="")=>{process.stdout.write(`${color.gray(S_BAR_END)} ${color.red(t)} -+`),o=_(c).length,s=Math.max(r.reduce(($,d)=>(d=_(d),d.length>$?d.length:$),0),o)+2,l=r.map($=>`${e__default.gray(a)} ${e__default.dim($)}${" ".repeat(s-_($).length)}${e__default.gray(a)}`).join(` -+`);process.stdout.write(`${e__default.gray(a)} -+${e__default.green(b)} ${e__default.reset(c)} ${e__default.gray(k.repeat(Math.max(s-o-1,1))+J)} -+${l} -+${e__default.gray(Y+k.repeat(s+2)+Q)} -+`)},cancel=(t="")=>{process.stdout.write(`${e__default.gray(m)} ${e__default.red(t)} - --`)},intro=(t="")=>{process.stdout.write(`${color.gray(S_BAR_START)} ${t} --`)},outro=(t="")=>{process.stdout.write(`${color.gray(S_BAR)} --${color.gray(S_BAR_END)} ${t} -+`)},intro=(t="")=>{process.stdout.write(`${e__default.gray(X)} ${t} -+`)},outro=(t="")=>{process.stdout.write(`${e__default.gray(a)} -+${e__default.gray(m)} ${t} - --`)},log={message:(t="",{symbol:n=color.gray(S_BAR)}={})=>{const i=[`${color.gray(S_BAR)}`];if(t){const[e,...r]=t.split(` --`);i.push(`${n} ${e}`,...r.map(c=>`${color.gray(S_BAR)} ${c}`))}process.stdout.write(`${i.join(` -+`)},log={message:(t="",{symbol:c=e__default.gray(a)}={})=>{const r=[`${e__default.gray(a)}`];if(t){const[o,...s]=t.split(` -+`);r.push(`${c} ${o}`,...s.map(l=>`${e__default.gray(a)} ${l}`))}process.stdout.write(`${r.join(` - `)} --`)},info:t=>{log.message(t,{symbol:color.blue(S_INFO)})},success:t=>{log.message(t,{symbol:color.green(S_SUCCESS)})},step:t=>{log.message(t,{symbol:color.green(S_STEP_SUBMIT)})},warn:t=>{log.message(t,{symbol:color.yellow(S_WARN)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:color.red(S_ERROR)})}},spinner=()=>{const t=unicode?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=unicode?80:120;let i,e,r=!1,c="";const a=(d="")=>{r=!0,i=core.block(),c=d.replace(/\.+$/,""),process.stdout.write(`${color.gray(S_BAR)} --`);let $=0,m=0;e=setInterval(()=>{const h=color.magenta(t[$]),g=".".repeat(Math.floor(m)).slice(0,3);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${h} ${c}${g}`),$=$+1{c=d??c,r=!1,clearInterval(e);const m=$===0?color.green(S_STEP_SUBMIT):$===1?color.red(S_STEP_CANCEL):color.red(S_STEP_ERROR);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${m} ${c} --`),i()},o=(d="")=>{c=d??c},u=d=>{const $=d>1?"Something went wrong":"Canceled";r&&l($,d)};return process.on("uncaughtExceptionMonitor",()=>u(2)),process.on("unhandledRejection",()=>u(2)),process.on("SIGINT",()=>u(1)),process.on("SIGTERM",()=>u(1)),process.on("exit",u),{start:a,stop:l,message:o}};function ansiRegex(){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}const group=async(t,n)=>{const i={},e=Object.keys(t);for(const r of e){const c=t[r],a=await c({results:i})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&core.isCancel(a)){i[r]="canceled",n.onCancel({results:i});continue}i[r]=a}return i};exports.isCancel=core.isCancel,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.text=text; -+`)},info:t=>{log.message(t,{symbol:e__default.blue(ee)})},success:t=>{log.message(t,{symbol:e__default.green(te)})},step:t=>{log.message(t,{symbol:e__default.green(b)})},warn:t=>{log.message(t,{symbol:e__default.yellow(re)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:e__default.red(se)})}},spinner=()=>{const t=S?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],c=S?80:120;let r,o,s=!1,l="";const $=w=>{const y=w>1?"Something went wrong":"Canceled";s&&x(y,w)},d=()=>$(2),p=()=>$(1),g=()=>{process.on("uncaughtExceptionMonitor",d),process.on("unhandledRejection",d),process.on("SIGINT",p),process.on("SIGTERM",p),process.on("exit",$)},M=()=>{process.removeListener("uncaughtExceptionMonitor",d),process.removeListener("unhandledRejection",d),process.removeListener("SIGINT",p),process.removeListener("SIGTERM",p),process.removeListener("exit",$)},I=(w="")=>{s=!0,r=core.block(),l=w.replace(/\.+$/,""),process.stdout.write(`${e__default.gray(a)} -+`);let y=0,f=0;g(),o=setInterval(()=>{const j=e__default.magenta(t[y]),q=".".repeat(Math.floor(f)).slice(0,3);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${j} ${l}${q}`),y=y+1{l=w??l,s=!1,clearInterval(o);const f=y===0?e__default.green(b):y===1?e__default.red(R):e__default.red(E);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${f} ${l} -+`),M(),r()};return{start:I,stop:x,message:(w="")=>{l=w??l}}};function ne(){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}const group=async(t,c)=>{const r={},o=Object.keys(t);for(const s of o){const l=t[s],$=await l({results:r})?.catch(d=>{throw d});if(typeof c?.onCancel=="function"&&core.isCancel($)){r[s]="canceled",c.onCancel({results:r});continue}r[s]=$}return r},tasks=async(t,c=1/0)=>{const r=new Concurrency({concurrency:c});await Promise.all(t.filter(o=>o.enabled!==!1).map(o=>r.add(async()=>{const s=spinner();s.start(o.title);const l=await o.task(s.message);s.stop(l||o.title)})))};exports.isCancel=core.isCancel,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.tasks=tasks,exports.text=text; -+//# sourceMappingURL=index.cjs.map -diff --git a/dist/index.d.ts b/dist/index.d.ts -index e03f8d08dfa029db261d15e71d18dd33df0783fa..1221899971f61fdc08e28c132dd9ee7b3efc1528 100644 ---- a/dist/index.d.ts -+++ b/dist/index.d.ts -@@ -31,30 +31,31 @@ type Option = Value extends Primitive ? { - label: string; - hint?: string; - }; --interface SelectOptions[], Value> { -+interface SelectOptions { - message: string; -- options: Options; -+ options: Option[]; - initialValue?: Value; - maxItems?: number; - } --declare const select: [], Value>(opts: SelectOptions) => Promise; --declare const selectKey: [], Value extends string>(opts: SelectOptions) => Promise; --interface MultiSelectOptions[], Value> { -+declare const select: (opts: SelectOptions) => Promise; -+declare const selectKey: (opts: SelectOptions) => Promise; -+interface MultiSelectOptions { - message: string; -- options: Options; -+ options: Option[]; - initialValues?: Value[]; -+ maxItems?: number; - required?: boolean; - cursorAt?: Value; - } --declare const multiselect: [], Value>(opts: MultiSelectOptions) => Promise; --interface GroupMultiSelectOptions[], Value> { -+declare const multiselect: (opts: MultiSelectOptions) => Promise; -+interface GroupMultiSelectOptions { - message: string; -- options: Record; -+ options: Record[]>; - initialValues?: Value[]; - required?: boolean; - cursorAt?: Value; - } --declare const groupMultiselect: [], Value>(opts: GroupMultiSelectOptions) => Promise; -+declare const groupMultiselect: (opts: GroupMultiSelectOptions) => Promise; - declare const note: (message?: string, title?: string) => void; - declare const cancel: (message?: string) => void; - declare const intro: (title?: string) => void; -@@ -101,6 +102,24 @@ type PromptGroup = { - * Define a group of prompts to be displayed - * and return a results of objects within the group - */ --declare const group: (prompts: PromptGroup, opts?: PromptGroupOptions | undefined) => Promise extends infer T_1 ? { [P in keyof T_1]: PromptGroupAwaitedReturn[P]; } : never>; -+declare const group: (prompts: PromptGroup, opts?: PromptGroupOptions | undefined) => Promise<{ [P in keyof PromptGroupAwaitedReturn]: PromptGroupAwaitedReturn[P]; }>; -+type Task = { -+ /** -+ * Task title -+ */ -+ title: string; -+ /** -+ * Task function -+ */ -+ task: (message: (string: string) => void) => string | Promise | void | Promise; -+ /** -+ * If enabled === false the task will be skipped -+ */ -+ enabled?: boolean; -+}; -+/** -+ * Define a group of tasks to be executed -+ */ -+declare const tasks: (tasks: Task[], concurrency?: number) => Promise; - --export { ConfirmOptions, GroupMultiSelectOptions, LogMessageOptions, MultiSelectOptions, PasswordOptions, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, SelectOptions, TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, text }; -+export { type ConfirmOptions, type GroupMultiSelectOptions, type LogMessageOptions, type MultiSelectOptions, type PasswordOptions, type PromptGroup, type PromptGroupAwaitedReturn, type PromptGroupOptions, type SelectOptions, type Task, type TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, tasks, text }; -diff --git a/dist/index.mjs b/dist/index.mjs -index f9c08c661777a51a0f186d0009022a3f0c94c22a..c19b18c330407622d412d3e4bf4c6f0fee498afa 100644 ---- a/dist/index.mjs -+++ b/dist/index.mjs -@@ -1,77 +1,78 @@ --import{TextPrompt as V,PasswordPrompt as j,ConfirmPrompt as N,SelectPrompt as k,SelectKeyPrompt as W,MultiSelectPrompt as D,GroupMultiSelectPrompt as L,isCancel as G,block as F}from"@clack/core";export{isCancel}from"@clack/core";import h from"node:process";import e from"picocolors";import{cursor as T,erase as A}from"sisteransi";function q(){return h.platform!=="win32"?h.env.TERM!=="linux":Boolean(h.env.CI)||Boolean(h.env.WT_SESSION)||Boolean(h.env.TERMINUS_SUBLIME)||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const _=q(),o=(r,n)=>_?r:n,H=o("\u25C6","*"),I=o("\u25A0","x"),x=o("\u25B2","x"),S=o("\u25C7","o"),K=o("\u250C","T"),a=o("\u2502","|"),d=o("\u2514","\u2014"),b=o("\u25CF",">"),E=o("\u25CB"," "),C=o("\u25FB","[\u2022]"),w=o("\u25FC","[+]"),M=o("\u25FB","[ ]"),U=o("\u25AA","\u2022"),B=o("\u2500","-"),Z=o("\u256E","+"),z=o("\u251C","+"),X=o("\u256F","+"),J=o("\u25CF","\u2022"),Y=o("\u25C6","*"),Q=o("\u25B2","!"),ee=o("\u25A0","x"),y=r=>{switch(r){case"initial":case"active":return e.cyan(H);case"cancel":return e.red(I);case"error":return e.yellow(x);case"submit":return e.green(S)}},te=r=>new V({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){const n=`${e.gray(a)} -+import{TextPrompt as W,PasswordPrompt as F,ConfirmPrompt as N,SelectPrompt as U,SelectKeyPrompt as D,MultiSelectPrompt as Z,GroupMultiSelectPrompt as z,isCancel as J,block as K}from"@clack/core";export{isCancel}from"@clack/core";import h from"node:process";import e from"picocolors";import{cursor as k,erase as A}from"sisteransi";function Y(){return h.platform!=="win32"?h.env.TERM!=="linux":!!h.env.CI||!!h.env.WT_SESSION||!!h.env.TERMINUS_SUBLIME||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Q=Object.defineProperty,X=(r,n,t)=>n in r?Q(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t,C=(r,n,t)=>(X(r,typeof n!="symbol"?n+"":n,t),t);class H{constructor(n){C(this,"concurrency"),C(this,"count"),C(this,"queue"),this.concurrency=n.concurrency,this.count=0,this.queue=new Set}add(n){return this.count{const i=()=>t(this.run(n));this.queue.add(i)})}flush(){for(const n of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(n),n()}}run(n){this.count++;const t=n(),i=()=>{this.count--,this.flush()};return t.then(i,i),t}}const I=Y(),l=(r,n)=>I?r:n,ee=l("\u25C6","*"),V=l("\u25A0","x"),q=l("\u25B2","x"),x=l("\u25C7","o"),te=l("\u250C","T"),a=l("\u2502","|"),$=l("\u2514","\u2014"),T=l("\u25CF",">"),j=l("\u25CB"," "),P=l("\u25FB","[\u2022]"),f=l("\u25FC","[+]"),B=l("\u25FB","[ ]"),re=l("\u25AA","\u2022"),G=l("\u2500","-"),se=l("\u256E","+"),ie=l("\u251C","+"),ne=l("\u256F","+"),ae=l("\u25CF","\u2022"),oe=l("\u25C6","*"),ce=l("\u25B2","!"),ue=l("\u25A0","x"),y=r=>{switch(r){case"initial":case"active":return e.cyan(ee);case"cancel":return e.red(V);case"error":return e.yellow(q);case"submit":return e.green(x)}},R=r=>{const{cursor:n,options:t,style:i}=r,s=r.maxItems===void 0?1/0:Math.max(r.maxItems,5);let o=0;n>=o+s-3?o=Math.max(Math.min(n-s+3,t.length-s),0):n0,u=s{const S=m===0&&c,b=m===M.length-1&&u;return S||b?e.dim("..."):i(d,m+o===n)})},le=r=>new W({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){const n=`${e.gray(a)} - ${y(this.state)} ${r.message} --`,i=r.placeholder?e.inverse(r.placeholder[0])+e.dim(r.placeholder.slice(1)):e.inverse(e.hidden("_")),t=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()} --${e.yellow(a)} ${t} --${e.yellow(d)} ${e.yellow(this.error)} -+`,t=r.placeholder?e.inverse(r.placeholder[0])+e.dim(r.placeholder.slice(1)):e.inverse(e.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${n.trim()} -+${e.yellow(a)} ${i} -+${e.yellow($)} ${e.yellow(this.error)} - `;case"submit":return`${n}${e.gray(a)} ${e.dim(this.value||r.placeholder)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(this.value??""))}${this.value?.trim()?` --`+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${t} --${e.cyan(d)} --`}}}).prompt(),re=r=>new j({validate:r.validate,mask:r.mask??U,render(){const n=`${e.gray(a)} --${y(this.state)} ${r.message} --`,i=this.valueWithCursor,t=this.masked;switch(this.state){case"error":return`${n.trim()} --${e.yellow(a)} ${t} --${e.yellow(d)} ${e.yellow(this.error)} --`;case"submit":return`${n}${e.gray(a)} ${e.dim(t)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(t??""))}${t?` - `+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${i} --${e.cyan(d)} --`}}}).prompt(),se=r=>{const n=r.active??"Yes",i=r.inactive??"No";return new N({active:n,inactive:i,initialValue:r.initialValue??!0,render(){const t=`${e.gray(a)} -+${e.cyan($)} -+`}}}).prompt(),$e=r=>new F({validate:r.validate,mask:r.mask??re,render(){const n=`${e.gray(a)} -+${y(this.state)} ${r.message} -+`,t=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()} -+${e.yellow(a)} ${i} -+${e.yellow($)} ${e.yellow(this.error)} -+`;case"submit":return`${n}${e.gray(a)} ${e.dim(i)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(i??""))}${i?` -+`+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${t} -+${e.cyan($)} -+`}}}).prompt(),de=r=>{const n=r.active??"Yes",t=r.inactive??"No";return new N({active:n,inactive:t,initialValue:r.initialValue??!0,render(){const i=`${e.gray(a)} - ${y(this.state)} ${r.message} --`,s=this.value?n:i;switch(this.state){case"submit":return`${t}${e.gray(a)} ${e.dim(s)}`;case"cancel":return`${t}${e.gray(a)} ${e.strikethrough(e.dim(s))} --${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${this.value?`${e.green(b)} ${n}`:`${e.dim(E)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(E)} ${e.dim(i)}`:`${e.green(b)} ${i}`} --${e.cyan(d)} --`}}}).prompt()},ie=r=>{const n=(t,s)=>{const c=t.label??String(t.value);return s==="active"?`${e.green(b)} ${c} ${t.hint?e.dim(`(${t.hint})`):""}`:s==="selected"?`${e.dim(c)}`:s==="cancelled"?`${e.strikethrough(e.dim(c))}`:`${e.dim(E)} ${e.dim(c)}`};let i=0;return new k({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)} -+`,s=this.value?n:t;switch(this.state){case"submit":return`${i}${e.gray(a)} ${e.dim(s)}`;case"cancel":return`${i}${e.gray(a)} ${e.strikethrough(e.dim(s))} -+${e.gray(a)}`;default:return`${i}${e.cyan(a)} ${this.value?`${e.green(T)} ${n}`:`${e.dim(j)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(j)} ${e.dim(t)}`:`${e.green(T)} ${t}`} -+${e.cyan($)} -+`}}}).prompt()},me=r=>{const n=(t,i)=>{const s=t.label??String(t.value);switch(i){case"selected":return`${e.dim(s)}`;case"active":return`${e.green(T)} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`;case"cancelled":return`${e.strikethrough(e.dim(s))}`;default:return`${e.dim(j)} ${e.dim(s)}`}};return new U({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)} - ${y(this.state)} ${r.message} - `;switch(this.state){case"submit":return`${t}${e.gray(a)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${e.gray(a)} ${n(this.options[this.cursor],"cancelled")} --${e.gray(a)}`;default:{const s=r.maxItems===void 0?1/0:Math.max(r.maxItems,5);this.cursor>=i+s-3?i=Math.max(Math.min(this.cursor-s+3,this.options.length-s),0):this.cursor0,l=sm===0&&c?e.dim("..."):m===$.length-1&&l?e.dim("..."):n(u,m+i===this.cursor?"active":"inactive")).join(` -+${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${R({cursor:this.cursor,options:this.options,maxItems:r.maxItems,style:(i,s)=>n(i,s?"active":"inactive")}).join(` - ${e.cyan(a)} `)} --${e.cyan(d)} --`}}}}).prompt()},ne=r=>{const n=(i,t="inactive")=>{const s=i.label??String(i.value);return t==="selected"?`${e.dim(s)}`:t==="cancelled"?`${e.strikethrough(e.dim(s))}`:t==="active"?`${e.bgCyan(e.gray(` ${i.value} `))} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${i.value} `)))} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`};return new W({options:r.options,initialValue:r.initialValue,render(){const i=`${e.gray(a)} -+${e.cyan($)} -+`}}}).prompt()},he=r=>{const n=(t,i="inactive")=>{const s=t.label??String(t.value);return i==="selected"?`${e.dim(s)}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active"?`${e.bgCyan(e.gray(` ${t.value} `))} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${t.value} `)))} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`};return new D({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)} - ${y(this.state)} ${r.message} --`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${n(this.options.find(t=>t.value===this.value),"selected")}`;case"cancel":return`${i}${e.gray(a)} ${n(this.options[0],"cancelled")} --${e.gray(a)}`;default:return`${i}${e.cyan(a)} ${this.options.map((t,s)=>n(t,s===this.cursor?"active":"inactive")).join(` -+`;switch(this.state){case"submit":return`${t}${e.gray(a)} ${n(this.options.find(i=>i.value===this.value),"selected")}`;case"cancel":return`${t}${e.gray(a)} ${n(this.options[0],"cancelled")} -+${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${this.options.map((i,s)=>n(i,s===this.cursor?"active":"inactive")).join(` - ${e.cyan(a)} `)} --${e.cyan(d)} --`}}}).prompt()},ae=r=>{const n=(i,t)=>{const s=i.label??String(i.value);return t==="active"?`${e.cyan(C)} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="selected"?`${e.green(w)} ${e.dim(s)}`:t==="cancelled"?`${e.strikethrough(e.dim(s))}`:t==="active-selected"?`${e.green(w)} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="submitted"?`${e.dim(s)}`:`${e.dim(M)} ${e.dim(s)}`};return new D({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. --${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let i=`${e.gray(a)} -+${e.cyan($)} -+`}}}).prompt()},pe=r=>{const n=(t,i)=>{const s=t.label??String(t.value);return i==="active"?`${e.cyan(P)} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="selected"?`${e.green(f)} ${e.dim(s)}`:i==="cancelled"?`${e.strikethrough(e.dim(s))}`:i==="active-selected"?`${e.green(f)} ${s} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="submitted"?`${e.dim(s)}`:`${e.dim(B)} ${e.dim(s)}`};return new Z({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option. -+${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let t=`${e.gray(a)} - ${y(this.state)} ${r.message} --`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${this.options.filter(({value:t})=>this.value.includes(t)).map(t=>n(t,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const t=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${i}${e.gray(a)} ${t.trim()?`${t} --${e.gray(a)}`:""}`}case"error":{const t=this.error.split(` --`).map((s,c)=>c===0?`${e.yellow(d)} ${e.yellow(s)}`:` ${s}`).join(` --`);return i+e.yellow(a)+" "+this.options.map((s,c)=>{const l=this.value.includes(s.value),u=c===this.cursor;return u&&l?n(s,"active-selected"):l?n(s,"selected"):n(s,u?"active":"inactive")}).join(` -+`;const i=(s,o)=>{const c=this.value.includes(s.value);return o&&c?n(s,"active-selected"):c?n(s,"selected"):n(s,o?"active":"inactive")};switch(this.state){case"submit":return`${t}${e.gray(a)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const s=this.options.filter(({value:o})=>this.value.includes(o)).map(o=>n(o,"cancelled")).join(e.dim(", "));return`${t}${e.gray(a)} ${s.trim()?`${s} -+${e.gray(a)}`:""}`}case"error":{const s=this.error.split(` -+`).map((o,c)=>c===0?`${e.yellow($)} ${e.yellow(o)}`:` ${o}`).join(` -+`);return t+e.yellow(a)+" "+R({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(` - ${e.yellow(a)} `)+` --`+t+` --`}default:return`${i}${e.cyan(a)} ${this.options.map((t,s)=>{const c=this.value.includes(t.value),l=s===this.cursor;return l&&c?n(t,"active-selected"):c?n(t,"selected"):n(t,l?"active":"inactive")}).join(` -+`+s+` -+`}default:return`${t}${e.cyan(a)} ${R({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(` - ${e.cyan(a)} `)} --${e.cyan(d)} --`}}}).prompt()},ce=r=>{const n=(i,t,s=[])=>{const c=i.label??String(i.value),l=typeof i.group=="string",u=l&&(s[s.indexOf(i)+1]??{group:!0}),m=l&&u.group===!0,$=l?`${m?d:a} `:"";return t==="active"?`${e.dim($)}${e.cyan(C)} ${c} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="group-active"?`${$}${e.cyan(C)} ${e.dim(c)}`:t==="group-active-selected"?`${$}${e.green(w)} ${e.dim(c)}`:t==="selected"?`${e.dim($)}${e.green(w)} ${e.dim(c)}`:t==="cancelled"?`${e.strikethrough(e.dim(c))}`:t==="active-selected"?`${e.dim($)}${e.green(w)} ${c} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="submitted"?`${e.dim(c)}`:`${e.dim($)}${e.dim(M)} ${e.dim(c)}`};return new L({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option. --${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let i=`${e.gray(a)} -+${e.cyan($)} -+`}}}).prompt()},ge=r=>{const n=(t,i,s=[])=>{const o=t.label??String(t.value),c=typeof t.group=="string",u=c&&(s[s.indexOf(t)+1]??{group:!0}),d=c&&u.group===!0,m=c?`${d?$:a} `:"";return i==="active"?`${e.dim(m)}${e.cyan(P)} ${o} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="group-active"?`${m}${e.cyan(P)} ${e.dim(o)}`:i==="group-active-selected"?`${m}${e.green(f)} ${e.dim(o)}`:i==="selected"?`${e.dim(m)}${e.green(f)} ${e.dim(o)}`:i==="cancelled"?`${e.strikethrough(e.dim(o))}`:i==="active-selected"?`${e.dim(m)}${e.green(f)} ${o} ${t.hint?e.dim(`(${t.hint})`):""}`:i==="submitted"?`${e.dim(o)}`:`${e.dim(m)}${e.dim(B)} ${e.dim(o)}`};return new z({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option. -+${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let t=`${e.gray(a)} - ${y(this.state)} ${r.message} --`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${this.options.filter(({value:t})=>this.value.includes(t)).map(t=>n(t,"submitted")).join(e.dim(", "))}`;case"cancel":{const t=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${i}${e.gray(a)} ${t.trim()?`${t} --${e.gray(a)}`:""}`}case"error":{const t=this.error.split(` --`).map((s,c)=>c===0?`${e.yellow(d)} ${e.yellow(s)}`:` ${s}`).join(` --`);return`${i}${e.yellow(a)} ${this.options.map((s,c,l)=>{const u=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),m=c===this.cursor;return!m&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?n(s,u?"group-active-selected":"group-active",l):m&&u?n(s,"active-selected",l):u?n(s,"selected",l):n(s,m?"active":"inactive",l)}).join(` -+`;switch(this.state){case"submit":return`${t}${e.gray(a)} ${this.options.filter(({value:i})=>this.value.includes(i)).map(i=>n(i,"submitted")).join(e.dim(", "))}`;case"cancel":{const i=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${t}${e.gray(a)} ${i.trim()?`${i} -+${e.gray(a)}`:""}`}case"error":{const i=this.error.split(` -+`).map((s,o)=>o===0?`${e.yellow($)} ${e.yellow(s)}`:` ${s}`).join(` -+`);return`${t}${e.yellow(a)} ${this.options.map((s,o,c)=>{const u=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),d=o===this.cursor;return!d&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?n(s,u?"group-active-selected":"group-active",c):d&&u?n(s,"active-selected",c):u?n(s,"selected",c):n(s,d?"active":"inactive",c)}).join(` - ${e.yellow(a)} `)} --${t} --`}default:return`${i}${e.cyan(a)} ${this.options.map((t,s,c)=>{const l=this.value.includes(t.value)||t.group===!0&&this.isGroupSelected(`${t.value}`),u=s===this.cursor;return!u&&typeof t.group=="string"&&this.options[this.cursor].value===t.group?n(t,l?"group-active-selected":"group-active",c):u&&l?n(t,"active-selected",c):l?n(t,"selected",c):n(t,u?"active":"inactive",c)}).join(` -+${i} -+`}default:return`${t}${e.cyan(a)} ${this.options.map((i,s,o)=>{const c=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),u=s===this.cursor;return!u&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?n(i,c?"group-active-selected":"group-active",o):u&&c?n(i,"active-selected",o):c?n(i,"selected",o):n(i,u?"active":"inactive",o)}).join(` - ${e.cyan(a)} `)} --${e.cyan(d)} --`}}}).prompt()},R=r=>r.replace(me(),""),le=(r="",n="")=>{const i=` -+${e.cyan($)} -+`}}}).prompt()},E=r=>r.replace(be(),""),ye=(r="",n="")=>{const t=` - ${r} - `.split(` --`),t=R(n).length,s=Math.max(i.reduce((l,u)=>(u=R(u),u.length>l?u.length:l),0),t)+2,c=i.map(l=>`${e.gray(a)} ${e.dim(l)}${" ".repeat(s-R(l).length)}${e.gray(a)}`).join(` -+`),i=E(n).length,s=Math.max(t.reduce((c,u)=>(u=E(u),u.length>c?u.length:c),0),i)+2,o=t.map(c=>`${e.gray(a)} ${e.dim(c)}${" ".repeat(s-E(c).length)}${e.gray(a)}`).join(` - `);process.stdout.write(`${e.gray(a)} --${e.green(S)} ${e.reset(n)} ${e.gray(B.repeat(Math.max(s-t-1,1))+Z)} --${c} --${e.gray(z+B.repeat(s+2)+X)} --`)},ue=(r="")=>{process.stdout.write(`${e.gray(d)} ${e.red(r)} -+${e.green(x)} ${e.reset(n)} ${e.gray(G.repeat(Math.max(s-i-1,1))+se)} -+${o} -+${e.gray(ie+G.repeat(s+2)+ne)} -+`)},ve=(r="")=>{process.stdout.write(`${e.gray($)} ${e.red(r)} - --`)},oe=(r="")=>{process.stdout.write(`${e.gray(K)} ${r} --`)},$e=(r="")=>{process.stdout.write(`${e.gray(a)} --${e.gray(d)} ${r} -+`)},we=(r="")=>{process.stdout.write(`${e.gray(te)} ${r} -+`)},fe=(r="")=>{process.stdout.write(`${e.gray(a)} -+${e.gray($)} ${r} - --`)},f={message:(r="",{symbol:n=e.gray(a)}={})=>{const i=[`${e.gray(a)}`];if(r){const[t,...s]=r.split(` --`);i.push(`${n} ${t}`,...s.map(c=>`${e.gray(a)} ${c}`))}process.stdout.write(`${i.join(` -+`)},v={message:(r="",{symbol:n=e.gray(a)}={})=>{const t=[`${e.gray(a)}`];if(r){const[i,...s]=r.split(` -+`);t.push(`${n} ${i}`,...s.map(o=>`${e.gray(a)} ${o}`))}process.stdout.write(`${t.join(` - `)} --`)},info:r=>{f.message(r,{symbol:e.blue(J)})},success:r=>{f.message(r,{symbol:e.green(Y)})},step:r=>{f.message(r,{symbol:e.green(S)})},warn:r=>{f.message(r,{symbol:e.yellow(Q)})},warning:r=>{f.warn(r)},error:r=>{f.message(r,{symbol:e.red(ee)})}},de=()=>{const r=_?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=_?80:120;let i,t,s=!1,c="";const l=(v="")=>{s=!0,i=F(),c=v.replace(/\.+$/,""),process.stdout.write(`${e.gray(a)} --`);let g=0,p=0;t=setInterval(()=>{const O=e.magenta(r[g]),P=".".repeat(Math.floor(p)).slice(0,3);process.stdout.write(T.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${O} ${c}${P}`),g=g+1{c=v??c,s=!1,clearInterval(t);const p=g===0?e.green(S):g===1?e.red(I):e.red(x);process.stdout.write(T.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${p} ${c} --`),i()},m=(v="")=>{c=v??c},$=v=>{const g=v>1?"Something went wrong":"Canceled";s&&u(g,v)};return process.on("uncaughtExceptionMonitor",()=>$(2)),process.on("unhandledRejection",()=>$(2)),process.on("SIGINT",()=>$(1)),process.on("SIGTERM",()=>$(1)),process.on("exit",$),{start:l,stop:u,message:m}};function me(){const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,"g")}const he=async(r,n)=>{const i={},t=Object.keys(r);for(const s of t){const c=r[s],l=await c({results:i})?.catch(u=>{throw u});if(typeof n?.onCancel=="function"&&G(l)){i[s]="canceled",n.onCancel({results:i});continue}i[s]=l}return i};export{ue as cancel,se as confirm,he as group,ce as groupMultiselect,oe as intro,f as log,ae as multiselect,le as note,$e as outro,re as password,ie as select,ne as selectKey,de as spinner,te as text}; -+`)},info:r=>{v.message(r,{symbol:e.blue(ae)})},success:r=>{v.message(r,{symbol:e.green(oe)})},step:r=>{v.message(r,{symbol:e.green(x)})},warn:r=>{v.message(r,{symbol:e.yellow(ce)})},warning:r=>{v.warn(r)},error:r=>{v.message(r,{symbol:e.red(ue)})}},O=()=>{const r=I?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=I?80:120;let t,i,s=!1,o="";const c=g=>{const p=g>1?"Something went wrong":"Canceled";s&&b(p,g)},u=()=>c(2),d=()=>c(1),m=()=>{process.on("uncaughtExceptionMonitor",u),process.on("unhandledRejection",u),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",c)},M=()=>{process.removeListener("uncaughtExceptionMonitor",u),process.removeListener("unhandledRejection",u),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",c)},S=(g="")=>{s=!0,t=K(),o=g.replace(/\.+$/,""),process.stdout.write(`${e.gray(a)} -+`);let p=0,w=0;m(),i=setInterval(()=>{const _=e.magenta(r[p]),L=".".repeat(Math.floor(w)).slice(0,3);process.stdout.write(k.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${_} ${o}${L}`),p=p+1{o=g??o,s=!1,clearInterval(i);const w=p===0?e.green(x):p===1?e.red(V):e.red(q);process.stdout.write(k.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${w} ${o} -+`),M(),t()};return{start:S,stop:b,message:(g="")=>{o=g??o}}};function be(){const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,"g")}const xe=async(r,n)=>{const t={},i=Object.keys(r);for(const s of i){const o=r[s],c=await o({results:t})?.catch(u=>{throw u});if(typeof n?.onCancel=="function"&&J(c)){t[s]="canceled",n.onCancel({results:t});continue}t[s]=c}return t},Me=async(r,n=1/0)=>{const t=new H({concurrency:n});await Promise.all(r.filter(i=>i.enabled!==!1).map(i=>t.add(async()=>{const s=O();s.start(i.title);const o=await i.task(s.message);s.stop(o||i.title)})))};export{ve as cancel,de as confirm,xe as group,ge as groupMultiselect,we as intro,v as log,pe as multiselect,ye as note,fe as outro,$e as password,me as select,he as selectKey,O as spinner,Me as tasks,le as text}; -+//# sourceMappingURL=index.mjs.map diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6e8b0ef6..49d40799 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,11 +9,8 @@ overrides: patchedDependencies: '@clack/core@0.3.3': - hash: eqexlyo4xb4wow7zklitcmhm24 + hash: sdevlgg5lm2tflzpgv2wxwifja path: patches/@clack__core@0.3.3.patch - '@clack/prompts@0.7.0': - hash: phrwq726kjmeof6tfupe6bspsa - path: patches/@clack__prompts@0.7.0.patch ast-types@0.16.1: hash: lbcpk3ulhul2sxdbqn4xesbaem path: patches/ast-types@0.16.1.patch @@ -101,10 +98,10 @@ importers: dependencies: '@clack/core': specifier: ^0.3.3 - version: 0.3.3(patch_hash=eqexlyo4xb4wow7zklitcmhm24) + version: 0.3.3(patch_hash=sdevlgg5lm2tflzpgv2wxwifja) '@clack/prompts': specifier: ^0.7.0 - version: 0.7.0(patch_hash=phrwq726kjmeof6tfupe6bspsa) + version: 0.7.0 fs-extra: specifier: ^11.1.1 version: 11.1.1 @@ -1684,7 +1681,7 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true - /@clack/core@0.3.3(patch_hash=eqexlyo4xb4wow7zklitcmhm24): + /@clack/core@0.3.3(patch_hash=sdevlgg5lm2tflzpgv2wxwifja): resolution: {integrity: sha512-5ZGyb75BUBjlll6eOa1m/IZBxwk91dooBWhPSL67sWcLS0zt9SnswRL0l26TVdBhb0wnWORRxUn//uH6n4z7+A==} dependencies: picocolors: 1.0.0 @@ -1692,16 +1689,15 @@ packages: dev: false patched: true - /@clack/prompts@0.7.0(patch_hash=phrwq726kjmeof6tfupe6bspsa): + /@clack/prompts@0.7.0: resolution: {integrity: sha512-0MhX9/B4iL6Re04jPrttDm+BsP8y6mS7byuv0BvXgdXhbV5PdlsHt55dvNsuBCPZ7xq1oTAOOuotR9NFbQyMSA==} dependencies: - '@clack/core': 0.3.3(patch_hash=eqexlyo4xb4wow7zklitcmhm24) + '@clack/core': 0.3.3(patch_hash=sdevlgg5lm2tflzpgv2wxwifja) picocolors: 1.0.0 sisteransi: 1.0.5 dev: false bundledDependencies: - is-unicode-supported - patched: true /@codemirror/autocomplete@6.9.0(@codemirror/language@6.8.0)(@codemirror/state@6.3.1)(@codemirror/view@6.22.0)(@lezer/common@1.0.3): resolution: {integrity: sha512-Fbwm0V/Wn3BkEJZRhr0hi5BhCo5a7eBL6LYaliPjOSwCyfOpnjXY59HruSxOUNV+1OYer0Tgx1zRNQttjXyDog==} From 3cbd77150eb3de7279d94250714e7c24eaf85504 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Thu, 14 Dec 2023 02:12:57 +0800 Subject: [PATCH 15/19] feat(cli): support performance statistic --- packages/cli/src/cli.ts | 48 +++++++++++++++++++------ packages/cli/src/{perf.ts => timing.ts} | 6 ++++ packages/cli/src/unminify.worker.ts | 7 ++-- packages/cli/src/unpacker.ts | 2 +- 4 files changed, 49 insertions(+), 14 deletions(-) rename packages/cli/src/{perf.ts => timing.ts} (93%) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index acf5823c..ebb09f40 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -23,8 +23,9 @@ import yargs from 'yargs' import { hideBin } from 'yargs/helpers' import { version } from '../package.json' import { findCommonBaseDir, getRelativePath, isPathInside, resolveGlob } from './path' -import { Timing } from './perf' +import { Timing } from './timing' import { unpacker } from './unpacker' +import type { Measurement } from './timing' import type { UnminifyWorkerParams } from './types' import type { ModuleMapping, ModuleMeta } from '@wakaru/ast-utils/types' import type { Module } from '@wakaru/unpacker' @@ -127,7 +128,7 @@ async function interactive({ output: _output, force: _force = false, concurrency = 1, - // perf, + perf, }: { inputs: string[] | undefined output: string | undefined @@ -395,10 +396,10 @@ async function interactive({ s.start('...') const timing = new Timing() - const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { errorHandler: e => console.error(e), }) - const execute = async (inputPath: string) => { + const unminify = async (inputPath: string) => { const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) const result = await pool.execute({ inputPath, @@ -409,10 +410,22 @@ async function interactive({ s.message(`${c.green(path.relative(cwd, inputPath))}`) return result } - const { time: elapsed } = await timing.measureTimeAsync(() => Promise.all( - unminifyInputPaths.map(p => execute(p)), + const { result: measurements, time: elapsed } = await timing.measureTimeAsync(() => Promise.all( + unminifyInputPaths.map(p => unminify(p)), )) + if (perf) { + const groupedByRules = measurements + .flat() + .reduce>((acc, { key, time }) => { + acc[key] = (acc[key] ?? 0) + time + return acc + }, {}) + const table = Object.entries(groupedByRules) + .map(([key, time]) => ({ key, time: ~~time })) + .sort((a, b) => a.time - b.time) + console.table(table, ['key', 'time']) + } s.stop('Finished') const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) @@ -434,7 +447,7 @@ async function nonInteractive(features: Feature[], { 'unminify-output': _unminifyOutput, force = false, concurrency = 1, - // perf, + perf, }: { inputs: string[] | undefined output: string | undefined @@ -568,10 +581,10 @@ async function nonInteractive(features: Feature[], { const timing = new Timing() - const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { errorHandler: e => console.error(e), }) - const execute = async (inputPath: string) => { + const unminify = async (inputPath: string) => { const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) const result = await pool.execute({ inputPath, @@ -582,10 +595,23 @@ async function nonInteractive(features: Feature[], { s.message(`${c.green(path.relative(cwd, inputPath))}`) return result } - const { time: elapsed } = await timing.measureTimeAsync(() => Promise.all( - unminifyInputPaths.map(p => execute(p)), + const { result: measurements, time: elapsed } = await timing.measureTimeAsync(() => Promise.all( + unminifyInputPaths.map(p => unminify(p)), )) + if (perf) { + const groupedByRules = measurements + .flat() + .reduce>((acc, { key, time }) => { + acc[key] = (acc[key] ?? 0) + time + return acc + }, {}) + const table = Object.entries(groupedByRules) + .map(([key, time]) => ({ key, time: ~~time })) + .sort((a, b) => a.time - b.time) + console.table(table, ['key', 'time']) + } + pool.destroy() s.stop('Finished') diff --git a/packages/cli/src/perf.ts b/packages/cli/src/timing.ts similarity index 93% rename from packages/cli/src/perf.ts rename to packages/cli/src/timing.ts index 1635a605..8ea51f99 100644 --- a/packages/cli/src/perf.ts +++ b/packages/cli/src/timing.ts @@ -12,6 +12,8 @@ interface TimingStat { time: number } +export type Measurement = TimingStat[] + export class Timing { private collected: TimingStat[] = [] @@ -64,4 +66,8 @@ export class Timing { return { result, time } } + + getMeasurements(): Measurement { + return this.collected + } } diff --git a/packages/cli/src/unminify.worker.ts b/packages/cli/src/unminify.worker.ts index 35916032..4f821e13 100644 --- a/packages/cli/src/unminify.worker.ts +++ b/packages/cli/src/unminify.worker.ts @@ -3,7 +3,8 @@ import process from 'node:process' import { runTransformations, transformationRules } from '@wakaru/unminify' import fsa from 'fs-extra' import { ThreadWorker } from 'poolifier' -import { Timing } from './perf' +import { Timing } from './timing' +import type { Measurement } from './timing' import type { UnminifyWorkerParams } from './types' import type { Transform } from 'jscodeshift' @@ -27,6 +28,8 @@ export async function unminify(data?: UnminifyWorkerParams) { const { code } = runTransformations(fileInfo, transformations, { moduleMeta, moduleMapping }) await fsa.ensureFile(outputPath) await fsa.writeFile(outputPath, code, 'utf-8') + + return timing.getMeasurements() } catch (e) { // We print the error here because it will lose the stack trace after being sent to the main thread @@ -35,4 +38,4 @@ export async function unminify(data?: UnminifyWorkerParams) { } } -export default new ThreadWorker(unminify) +export default new ThreadWorker(unminify) diff --git a/packages/cli/src/unpacker.ts b/packages/cli/src/unpacker.ts index 544af96a..71d72e13 100644 --- a/packages/cli/src/unpacker.ts +++ b/packages/cli/src/unpacker.ts @@ -1,7 +1,7 @@ import path from 'node:path' import { unpack } from '@wakaru/unpacker' import fsa from 'fs-extra' -import { Timing } from './perf' +import { Timing } from './timing' import type { ModuleMapping } from '@wakaru/ast-utils/types' import type { Module } from '@wakaru/unpacker' From ee876081a34ed27d5c59206b30513108e77f08de Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Thu, 14 Dec 2023 02:47:16 +0800 Subject: [PATCH 16/19] perf(unminify) : improve performance of `prettier` and `lebab` --- packages/ast-utils/package.json | 3 ++- .../ast-utils/src/wrapStringTransformation.ts | 18 ++++++++++++++++++ .../__tests__/un-parameters.spec.ts | 13 +++++++++++++ packages/unminify/src/transformations/lebab.ts | 9 ++++----- .../unminify/src/transformations/prettier.ts | 10 +++------- .../src/transformations/un-parameters.ts | 4 ++-- 6 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 packages/ast-utils/src/wrapStringTransformation.ts diff --git a/packages/ast-utils/package.json b/packages/ast-utils/package.json index 2cf82aeb..afe16885 100644 --- a/packages/ast-utils/package.json +++ b/packages/ast-utils/package.json @@ -23,7 +23,8 @@ "./reference": "./src/reference.ts", "./scope": "./src/scope.ts", "./types": "./src/types.ts", - "./wrapAstTransformation": "./src/wrapAstTransformation.ts" + "./wrapAstTransformation": "./src/wrapAstTransformation.ts", + "./wrapStringTransformation": "./src/wrapStringTransformation.ts" }, "files": [ "dist", diff --git a/packages/ast-utils/src/wrapStringTransformation.ts b/packages/ast-utils/src/wrapStringTransformation.ts new file mode 100644 index 00000000..8f0c68d9 --- /dev/null +++ b/packages/ast-utils/src/wrapStringTransformation.ts @@ -0,0 +1,18 @@ +import type { Options, Transform } from 'jscodeshift' + +export interface StringTransformation { + (code: string, params: Params): string | void +} + +export function wrapStringTransformation( + transformAST: StringTransformation, +): Transform { + // @ts-expect-error - jscodeshift is not happy + const transform: Transform = (file, api, options: Params) => { + const code = file.source + const result = transformAST(code, options) + return result ?? code + } + + return transform +} diff --git a/packages/unminify/src/transformations/__tests__/un-parameters.spec.ts b/packages/unminify/src/transformations/__tests__/un-parameters.spec.ts index 3254de29..3c7eb3d2 100644 --- a/packages/unminify/src/transformations/__tests__/un-parameters.spec.ts +++ b/packages/unminify/src/transformations/__tests__/un-parameters.spec.ts @@ -208,3 +208,16 @@ function test(a = 1, b) { } `, ) + +inlineTest('lebab', + ` +function test() { + console.log(arguments); +} +`, + ` +function test(...args) { + console.log(args); +} +`, +) diff --git a/packages/unminify/src/transformations/lebab.ts b/packages/unminify/src/transformations/lebab.ts index 90c14939..900a6c4f 100644 --- a/packages/unminify/src/transformations/lebab.ts +++ b/packages/unminify/src/transformations/lebab.ts @@ -1,6 +1,6 @@ -import { wrapAstTransformation } from '@wakaru/ast-utils/wrapAstTransformation' +import { wrapStringTransformation } from '@wakaru/ast-utils/wrapStringTransformation' import { transform } from 'lebab' -import type { ASTTransformation } from '@wakaru/ast-utils/wrapAstTransformation' +import type { StringTransformation } from '@wakaru/ast-utils/wrapStringTransformation' import type { LebabRule } from 'lebab' /** @@ -32,9 +32,8 @@ function transformLebab(input: string, rules: LebabRule[]) { return { code, warnings } } -export const transformASTWithRules = (rules: LebabRule[]): ASTTransformation => (context) => { - const code = context.root.toSource() +export const transformASTWithRules = (rules: LebabRule[]): StringTransformation => (code) => { return transformLebab(code, rules).code } -export default wrapAstTransformation(transformASTWithRules(allLebabRules)) +export default wrapStringTransformation(transformASTWithRules(allLebabRules)) diff --git a/packages/unminify/src/transformations/prettier.ts b/packages/unminify/src/transformations/prettier.ts index 054689db..bab04261 100644 --- a/packages/unminify/src/transformations/prettier.ts +++ b/packages/unminify/src/transformations/prettier.ts @@ -1,17 +1,13 @@ -import { wrapAstTransformation } from '@wakaru/ast-utils/wrapAstTransformation' +import { wrapStringTransformation } from '@wakaru/ast-utils/wrapStringTransformation' import babelParser from 'prettier/parser-babel' import prettier from 'prettier/standalone' -import type { ASTTransformation } from '@wakaru/ast-utils/wrapAstTransformation' /** * @url https://prettier.io */ -export const transformAST: ASTTransformation = (context) => { - const code = context.root.toSource() +export default wrapStringTransformation((code) => { return prettier.format(code, { parser: 'babel', plugins: [babelParser], }) -} - -export default wrapAstTransformation(transformAST) +}) diff --git a/packages/unminify/src/transformations/un-parameters.ts b/packages/unminify/src/transformations/un-parameters.ts index e9f86156..2ce6c842 100644 --- a/packages/unminify/src/transformations/un-parameters.ts +++ b/packages/unminify/src/transformations/un-parameters.ts @@ -79,12 +79,12 @@ export const transformAST: ASTTransformation = (context) => { handleBody(j, path) }) - transformASTWithRules([ + return transformASTWithRules([ // 'default-param', // 'destruct-param', 'arg-spread', 'arg-rest', - ])(context, {}) + ])(root.toSource({ lineTerminator: '\n' }), {}) } /** From edbc87e002dd991405988d75e0e0f9538b6c3e5c Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Fri, 15 Dec 2023 01:46:16 +0800 Subject: [PATCH 17/19] refactor(cli): extract duplicated logics --- packages/cli/src/cli.ts | 138 +++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 74 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index ebb09f40..d6f21506 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -280,25 +280,14 @@ async function interactive({ log.step('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) - const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) - log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) + log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formatElapsed(elapsed)})`)}`) outro(`Output directory: ${c.green(getRelativePath(cwd, outputPath))}`) unminifyInputPaths = items.flatMap(item => item.files) const modules = items.flatMap(item => item.modules) - moduleMeta = modules.reduce((acc, mod) => { - acc[mod.id] = { - import: mod.import, - export: mod.export, - tags: mod.tags, - } - return acc - }, {}) - moduleMapping = modules.reduce((acc, mod) => { - acc[mod.id] = getDepName(mod) - return acc - }, {}) + moduleMeta = generateModuleMeta(modules) + moduleMapping = generateModuleMapping(modules) } if (features.includes(Feature.Unminify)) { @@ -401,38 +390,24 @@ async function interactive({ }) const unminify = async (inputPath: string) => { const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) - const result = await pool.execute({ - inputPath, - outputPath, - moduleMeta, - moduleMapping, - }) + const result = await pool.execute({ inputPath, outputPath, moduleMeta, moduleMapping }) s.message(`${c.green(path.relative(cwd, inputPath))}`) return result } const { result: measurements, time: elapsed } = await timing.measureTimeAsync(() => Promise.all( unminifyInputPaths.map(p => unminify(p)), )) + pool.destroy() - if (perf) { - const groupedByRules = measurements - .flat() - .reduce>((acc, { key, time }) => { - acc[key] = (acc[key] ?? 0) + time - return acc - }, {}) - const table = Object.entries(groupedByRules) - .map(([key, time]) => ({ key, time: ~~time })) - .sort((a, b) => a.time - b.time) - console.table(table, ['key', 'time']) - } s.stop('Finished') - const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) - - log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) + log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formatElapsed(elapsed)})`)}`) outro(`Output directory: ${c.green(getRelativePath(cwd, outputDir))}`) + + if (perf) { + handlePerfMeasurements(measurements) + } } console.log() @@ -532,24 +507,13 @@ async function nonInteractive(features: Feature[], { log.step('Finished') const totalModules = items.reduce((acc, item) => acc + item.modules.length, 0) - const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) - log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formattedElapsed}ms)`)}`) + log.success(`Successfully generated ${c.green(totalModules)} modules ${c.dim(`(${formatElapsed(elapsed)})`)}`) outro(`Output directory: ${c.green(relativeOutputPath)}`) unminifyInputPaths = items.flatMap(item => item.files) const modules = items.flatMap(item => item.modules) - moduleMeta = modules.reduce((acc, mod) => { - acc[mod.id] = { - import: mod.import, - export: mod.export, - tags: mod.tags, - } - return acc - }, {}) - moduleMapping = modules.reduce((acc, mod) => { - acc[mod.id] = getDepName(mod) - return acc - }, {}) + moduleMeta = generateModuleMeta(modules) + moduleMapping = generateModuleMapping(modules) } if (features.includes(Feature.Unminify)) { @@ -586,44 +550,70 @@ async function nonInteractive(features: Feature[], { }) const unminify = async (inputPath: string) => { const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) - const result = await pool.execute({ - inputPath, - outputPath, - moduleMeta, - moduleMapping, - }) + const result = await pool.execute({ inputPath, outputPath, moduleMeta, moduleMapping }) s.message(`${c.green(path.relative(cwd, inputPath))}`) return result } const { result: measurements, time: elapsed } = await timing.measureTimeAsync(() => Promise.all( unminifyInputPaths.map(p => unminify(p)), )) - - if (perf) { - const groupedByRules = measurements - .flat() - .reduce>((acc, { key, time }) => { - acc[key] = (acc[key] ?? 0) + time - return acc - }, {}) - const table = Object.entries(groupedByRules) - .map(([key, time]) => ({ key, time: ~~time })) - .sort((a, b) => a.time - b.time) - console.table(table, ['key', 'time']) - } - pool.destroy() s.stop('Finished') - const formattedElapsed = elapsed.toLocaleString('en-US', { maximumFractionDigits: 1 }) - - log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formattedElapsed}ms)`)}`) + log.success(`Successfully unminified ${c.green(unminifyInputPaths.length)} files ${c.dim(`(${formatElapsed(elapsed)})`)}`) outro(`Output directory: ${c.green(relativeOutputPath)}`) + + if (perf) { + handlePerfMeasurements(measurements) + } } } -function getDepName(dep: Module) { - return dep.isEntry ? `entry-${dep.id}.js` : `module-${dep.id}.js` +function formatElapsed(elapsed: number) { + if (elapsed < 1000) return `${~~elapsed}ms` + if (elapsed < 1000 * 60) return `${(elapsed / 1000).toFixed(2)}s` + if (elapsed < 1000 * 60 * 60) return `${~~(elapsed / 1000 / 60)}m${~~((elapsed / 1000) % 60)}s` + return `${~~(elapsed / 1000 / 60 / 60)}h${~~((elapsed / 1000 / 60) % 60)}m${~~((elapsed / 1000) % 60)}s` +} + +function handlePerfMeasurements(measurements: Measurement[]) { + const groupedByRules = measurements + .flat() + .reduce>((acc, { key, time }) => { + acc[key] = (acc[key] ?? 0) + time + return acc + }, {}) + const table = Object.entries(groupedByRules) + .map(([key, time]) => ({ key, time: ~~time })) + .sort((a, b) => a.time - b.time) + console.log() + console.table(table, ['key', 'time']) +} + +function generateModuleMeta(modules: Module[]) { + return modules.reduce((acc, mod) => { + acc[mod.id] = { + import: mod.import, + export: mod.export, + tags: mod.tags, + } + return acc + }, {}) +} + +function generateModuleMapping(modules: Module[]) { + return modules.reduce((acc, mod) => { + acc[mod.id] = getModuleFileName(mod) + return acc + }, {}) +} + +function getModuleFileName(dep: Module) { + if (dep.isEntry) { + if (dep.id === 0) return 'entry.js' + return `entry-${dep.id}.js` + } + return `module-${dep.id}.js` } From c43854bc16c1e672b3887268c522d696d51b7e4c Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Fri, 15 Dec 2023 01:59:46 +0800 Subject: [PATCH 18/19] feat(cli): generate `perf.json` when perf is enabled --- packages/cli/src/cli.ts | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index d6f21506..4006f3c6 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -406,7 +406,9 @@ async function interactive({ outro(`Output directory: ${c.green(getRelativePath(cwd, outputDir))}`) if (perf) { - handlePerfMeasurements(measurements) + printPerfStats(measurements) + + writePerfStats(measurements, path.join(outputBase, 'perf.json')) } } @@ -456,19 +458,19 @@ async function nonInteractive(features: Feature[], { return process.exit(1) } - const output = _output ?? defaultOutputBase + const outputBase = _output ?? defaultOutputBase const singleFeature = features.length === 1 - const unpackerOutput = _unpackerOutput ?? (singleFeature ? output : path.join(output, defaultUnpackerOutputFolder)) - const unminifyOutput = _unminifyOutput ?? (singleFeature ? output : path.join(output, defaultUnminifyOutputFolder)) + const unpackerOutput = _unpackerOutput ?? (singleFeature ? outputBase : path.join(outputBase, defaultUnpackerOutputFolder)) + const unminifyOutput = _unminifyOutput ?? (singleFeature ? outputBase : path.join(outputBase, defaultUnminifyOutputFolder)) - if (!isPathInside(cwd, output)) { + if (!isPathInside(cwd, outputBase)) { log.error('Output directory must be inside the current working directory') return process.exit(1) } if (!force) { - if (fsa.existsSync(output)) { - log.error(`Output directory already exists at ${c.green(output)}. Pass ${c.green('--force')} to overwrite`) + if (fsa.existsSync(outputBase)) { + log.error(`Output directory already exists at ${c.green(outputBase)}. Pass ${c.green('--force')} to overwrite`) return process.exit(1) } @@ -566,7 +568,9 @@ async function nonInteractive(features: Feature[], { outro(`Output directory: ${c.green(relativeOutputPath)}`) if (perf) { - handlePerfMeasurements(measurements) + printPerfStats(measurements) + + writePerfStats(measurements, path.join(outputBase, 'perf.json')) } } } @@ -578,7 +582,7 @@ function formatElapsed(elapsed: number) { return `${~~(elapsed / 1000 / 60 / 60)}h${~~((elapsed / 1000 / 60) % 60)}m${~~((elapsed / 1000) % 60)}s` } -function handlePerfMeasurements(measurements: Measurement[]) { +function printPerfStats(measurements: Measurement[]) { const groupedByRules = measurements .flat() .reduce>((acc, { key, time }) => { @@ -592,6 +596,17 @@ function handlePerfMeasurements(measurements: Measurement[]) { console.table(table, ['key', 'time']) } +function writePerfStats(measurements: Measurement[], outputPath: string) { + fsa.writeJSONSync(outputPath, measurements.flat(), { + encoding: 'utf-8', + spaces: 2, + }) + + console.log() + console.log(`Performance statistics generated at ${c.green(getRelativePath(process.cwd(), outputPath))}`) + console.log() +} + function generateModuleMeta(modules: Module[]) { return modules.reduce((acc, mod) => { acc[mod.id] = { From 6f94ef50277317f009e0ab77e8ec6c2e87c011ed Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Fri, 15 Dec 2023 03:06:35 +0800 Subject: [PATCH 19/19] fix: improve error log --- packages/cli/src/cli.ts | 8 ++------ packages/cli/src/unminify.worker.ts | 13 +++++++++---- packages/unminify/src/index.ts | 7 ++----- packages/unminify/src/transformations/index.ts | 2 ++ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 4006f3c6..e5c9b044 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -385,9 +385,7 @@ async function interactive({ s.start('...') const timing = new Timing() - const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { - errorHandler: e => console.error(e), - }) + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile) const unminify = async (inputPath: string) => { const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) const result = await pool.execute({ inputPath, outputPath, moduleMeta, moduleMapping }) @@ -547,9 +545,7 @@ async function nonInteractive(features: Feature[], { const timing = new Timing() - const pool = new FixedThreadPool(concurrency, unminifyWorkerFile, { - errorHandler: e => console.error(e), - }) + const pool = new FixedThreadPool(concurrency, unminifyWorkerFile) const unminify = async (inputPath: string) => { const outputPath = path.join(outputDir, path.relative(commonBaseDir, inputPath)) const result = await pool.execute({ inputPath, outputPath, moduleMeta, moduleMapping }) diff --git a/packages/cli/src/unminify.worker.ts b/packages/cli/src/unminify.worker.ts index 4f821e13..89806e53 100644 --- a/packages/cli/src/unminify.worker.ts +++ b/packages/cli/src/unminify.worker.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import path from 'node:path' import process from 'node:process' import { runTransformations, transformationRules } from '@wakaru/unminify' @@ -11,9 +12,8 @@ import type { Transform } from 'jscodeshift' export async function unminify(data?: UnminifyWorkerParams) { if (!data) throw new Error('No data received') + const { inputPath, outputPath, moduleMeta, moduleMapping } = data try { - const { inputPath, outputPath, moduleMeta, moduleMapping } = data - const cwd = process.cwd() const filename = path.relative(cwd, inputPath) const source = await fsa.readFile(inputPath, 'utf-8') @@ -22,7 +22,10 @@ export async function unminify(data?: UnminifyWorkerParams) { const timing = new Timing() const transformations = transformationRules.map((rule) => { const { id, transform } = rule - return (...args: Parameters) => timing.collect(filename, id, () => transform(...args)) + const fn = (...args: Parameters) => timing.collect(filename, id, () => transform(...args)) + // Set the name of the function for better debugging + Object.defineProperty(fn, 'name', { value: id }) + return fn }) const { code } = runTransformations(fileInfo, transformations, { moduleMeta, moduleMapping }) @@ -33,8 +36,10 @@ export async function unminify(data?: UnminifyWorkerParams) { } catch (e) { // We print the error here because it will lose the stack trace after being sent to the main thread + console.log() console.error(e) - throw e + + return [] } } diff --git a/packages/unminify/src/index.ts b/packages/unminify/src/index.ts index 3938069d..69d80d51 100644 --- a/packages/unminify/src/index.ts +++ b/packages/unminify/src/index.ts @@ -41,9 +41,9 @@ export function runTransformations

>( if (newResult) code = newResult } catch (err: any) { - if ('loc' in err) { - console.error(err) + console.error(`\nError running transformation ${transform.name} on ${path}`, err) + if ('loc' in err) { const padLeft = (str: string, len: number, char: string) => { const count = len > str.length ? len - str.length : 0 return `${char.repeat(count)}${str}` @@ -68,9 +68,6 @@ export function runTransformations

>( printLine(loc.line + 1) printLine(loc.line + 2) } - else { - console.error(err) - } break } diff --git a/packages/unminify/src/transformations/index.ts b/packages/unminify/src/transformations/index.ts index 397bb4ee..87952caa 100644 --- a/packages/unminify/src/transformations/index.ts +++ b/packages/unminify/src/transformations/index.ts @@ -162,5 +162,7 @@ export const transformationRules: TransformationRule[] = _transformationRules.ma const occurrence = occurrenceMap.get(rule.name) ?? 0 occurrenceMap.set(rule.name, occurrence + 1) const id = occurrence === 0 ? rule.name : `${rule.name}-${occurrence}` + // Set the name of the function for better debugging + Object.defineProperty(rule.transform, 'name', { value: id }) return { ...rule, id } })