@learnosity/lib-qti-converter 0.16.1 → 0.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +9 -9
  2. package/packages/cli/dist/{batchProcessors-BI6C89vy.js → batchProcessors-BGdELwug.js} +12 -12
  3. package/packages/cli/dist/{batchProcessors-BI6C89vy.js.map → batchProcessors-BGdELwug.js.map} +1 -1
  4. package/packages/cli/dist/batchWorker.js +1 -1
  5. package/packages/cli/dist/{configOutput-CJ-ryN3j.js → configOutput-DYPwNQf7.js} +1 -1
  6. package/packages/cli/dist/{configOutput-CJ-ryN3j.js.map → configOutput-DYPwNQf7.js.map} +1 -1
  7. package/packages/cli/dist/{create-prompt-m0MC0vT_.js → create-prompt-C3XKo-s3.js} +77 -34
  8. package/packages/cli/dist/create-prompt-C3XKo-s3.js.map +1 -0
  9. package/packages/cli/dist/{dist-8MaFD1oj.js → dist-D7b9-VIt.js} +8 -7
  10. package/packages/cli/dist/dist-D7b9-VIt.js.map +1 -0
  11. package/packages/cli/dist/{learnosityToQti-BDf_faIV.js → learnosityToQti-CN6KKSmF.js} +4 -4
  12. package/packages/cli/dist/{learnosityToQti-BDf_faIV.js.map → learnosityToQti-CN6KKSmF.js.map} +1 -1
  13. package/packages/cli/dist/{learnosityToQtiPackage-w-BXgsLt.js → learnosityToQtiPackage-CMOQRiCV.js} +22 -15
  14. package/packages/cli/dist/learnosityToQtiPackage-CMOQRiCV.js.map +1 -0
  15. package/packages/cli/dist/main.js +5 -5
  16. package/packages/cli/dist/{nodeFileAccess-BBS4FAK7.js → nodeFileAccess-_jRCd340.js} +2 -2
  17. package/packages/cli/dist/{nodeFileAccess-BBS4FAK7.js.map → nodeFileAccess-_jRCd340.js.map} +1 -1
  18. package/packages/cli/dist/{pathUtils-BUJJCvvp.js → pathUtils-I2bRHUwu.js} +14 -11
  19. package/packages/cli/dist/pathUtils-I2bRHUwu.js.map +1 -0
  20. package/packages/cli/dist/{qtiPackageToLearnosity-C24effmB.js → qtiPackageToLearnosity-JRb3TTyC.js} +6 -6
  21. package/packages/cli/dist/{qtiPackageToLearnosity-C24effmB.js.map → qtiPackageToLearnosity-JRb3TTyC.js.map} +1 -1
  22. package/packages/cli/dist/{qtiToLearnosity-BEOaukuf.js → qtiToLearnosity-C-jQYKqR.js} +5 -5
  23. package/packages/cli/dist/{qtiToLearnosity-BEOaukuf.js.map → qtiToLearnosity-C-jQYKqR.js.map} +1 -1
  24. package/packages/cli/dist/{resolveOptions-l0Hpn8hY.js → resolveOptions-ikupjaRQ.js} +6 -6
  25. package/packages/cli/dist/{resolveOptions-l0Hpn8hY.js.map → resolveOptions-ikupjaRQ.js.map} +1 -1
  26. package/packages/cli/dist/{rolldown-runtime-BVN1G_yT.js → rolldown-runtime-BuRBZLzk.js} +8 -6
  27. package/packages/cli/dist/{table-BkrwlSAQ.js → table-6SiZD7aK.js} +323 -326
  28. package/packages/cli/dist/table-6SiZD7aK.js.map +1 -0
  29. package/packages/core/dist/index.js +325 -332
  30. package/packages/core/dist/node.js +330 -337
  31. package/packages/cli/dist/create-prompt-m0MC0vT_.js.map +0 -1
  32. package/packages/cli/dist/dist-8MaFD1oj.js.map +0 -1
  33. package/packages/cli/dist/learnosityToQtiPackage-w-BXgsLt.js.map +0 -1
  34. package/packages/cli/dist/pathUtils-BUJJCvvp.js.map +0 -1
  35. package/packages/cli/dist/table-BkrwlSAQ.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { r as runBatchTask } from "./batchProcessors-BI6C89vy.js";
2
1
  import { parentPort } from "node:worker_threads";
2
+ import { r as runBatchTask } from "./batchProcessors-BGdELwug.js";
3
3
  // src/batchWorker.ts
4
4
  /**
5
5
  * Worker-thread entry for parallel batch conversion. Receives one package task
@@ -392,4 +392,4 @@ function configField(label, value, indent = 0) {
392
392
  }
393
393
  export { processBatchParallel as i, displayConfiguration as n, processBatch as r, configField as t };
394
394
 
395
- //# sourceMappingURL=configOutput-CJ-ryN3j.js.map
395
+ //# sourceMappingURL=configOutput-DYPwNQf7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configOutput-CJ-ryN3j.js","names":[],"sources":["../src/utils/packageScanner.ts","../src/utils/workerPool.ts","../src/utils/batchProcessing.ts","../src/utils/configOutput.ts"],"sourcesContent":["/**\n * Package scanning utilities for detecting QTI and Learnosity packages\n */\n\nimport { existsSync, statSync, readdirSync } from 'fs';\nimport { join, basename } from 'path';\n\n/**\n * Package type detection result\n */\nexport type PackageType = 'qti' | 'learnosity' | 'unknown';\n\n/**\n * Detected package information\n */\nexport interface DetectedPackage {\n /** Absolute path to the package directory */\n path: string;\n /** Package directory name */\n name: string;\n /**\n * Path to the package relative to the scanned root directory, e.g.\n * `grade-3/maths/package-a`. Used to mirror the input folder structure in\n * the output directory. Equals `name` for packages directly under the root.\n *\n * Optional so custom scanners can omit it; consumers fall back to `name`.\n */\n relativePath?: string;\n /** Detected package type */\n type: PackageType;\n}\n\n/**\n * Detect if a directory is a QTI package\n * A QTI package must contain an imsmanifest.xml file\n */\nexport function isQtiPackage(dirPath: string): boolean {\n if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) {\n return false;\n }\n\n // dirPath is a directory the operator pointed the CLI at; the filename is a\n // literal, so this join cannot traverse anywhere the caller did not ask for.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const manifestPath = join(dirPath, 'imsmanifest.xml');\n\n return existsSync(manifestPath);\n}\n\n/**\n * Detect if a directory is a Learnosity bundle\n * A Learnosity bundle must contain a manifest.json file\n */\nexport function isLearnosityBundle(dirPath: string): boolean {\n if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) {\n return false;\n }\n\n // Same as isQtiPackage: operator-supplied directory plus a literal filename.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const manifestPath = join(dirPath, 'manifest.json');\n\n return existsSync(manifestPath);\n}\n\n/**\n * Detect package type for a directory\n */\nexport function detectPackageType(dirPath: string): PackageType {\n if (isQtiPackage(dirPath)) {\n return 'qti';\n }\n if (isLearnosityBundle(dirPath)) {\n return 'learnosity';\n }\n\n return 'unknown';\n}\n\n/**\n * Scan a directory recursively for packages and detect their package types\n *\n * @param parentDir - Parent directory containing subdirectories to scan\n * @param expectedType - Optional filter to only return packages of a specific type\n * @returns Array of detected packages\n */\nexport function scanForPackages(parentDir: string, expectedType?: PackageType): DetectedPackage[] {\n const packages: DetectedPackage[] = [];\n\n if (!existsSync(parentDir)) {\n return packages;\n }\n\n const stat = statSync(parentDir);\n\n if (!stat.isDirectory()) {\n return packages;\n }\n\n /**\n * Recursively scan directories for packages\n *\n * @param currentDir - Directory being scanned\n * @param relativeDir - Path of `currentDir` relative to `parentDir` ('' at the root)\n */\n function scanRecursive(currentDir: string, relativeDir: string): void {\n // Read all items in the current directory\n const items = readdirSync(currentDir);\n\n for (const item of items) {\n // item comes from readdirSync, so it is a single existing directory\n // entry name and cannot contain separators or traversal segments.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const itemPath = join(currentDir, item);\n\n // relativeDir is built from earlier readdirSync entry names and item is\n // a single entry name, so this label cannot escape the scanned root.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const itemRelativePath = relativeDir ? join(relativeDir, item) : item;\n\n // Skip non-directories\n try {\n if (!statSync(itemPath).isDirectory()) {\n continue;\n }\n } catch {\n // Skip items that can't be accessed (permissions, broken symlinks, etc.)\n continue;\n }\n\n // Detect package type\n const type = detectPackageType(itemPath);\n\n // If this directory is a package, add it and don't recurse into it\n if (type !== 'unknown') {\n // Skip if type doesn't match expected type (if specified)\n if (expectedType && type !== expectedType) {\n continue;\n }\n\n packages.push({\n path: itemPath,\n name: basename(itemPath),\n relativePath: itemRelativePath,\n type,\n });\n\n // Don't recurse into package directories\n continue;\n }\n\n // If not a package, recurse into subdirectories\n scanRecursive(itemPath, itemRelativePath);\n }\n }\n\n scanRecursive(parentDir, '');\n\n return packages;\n}\n","/**\n * Minimal reusable worker_threads pool.\n *\n * Spawns up to `concurrency` long-lived workers, dispatches one task at a time\n * to each idle worker, and resolves with results in the SAME order as the input\n * tasks (deterministic) regardless of completion order. A worker error/crash\n * fails only its in-flight task (via `onError`) and the worker is respawned if\n * work remains, so one bad package can't sink the whole batch.\n */\n\nimport { Worker } from 'node:worker_threads';\n\nexport interface RunPoolOptions<TTask, TResult> {\n /** Tasks to process (results are returned in this order). */\n tasks: TTask[];\n /** URL/path of the worker module. */\n workerUrl: URL | string;\n /** Max concurrent workers (clamped to [1, tasks.length]). */\n concurrency: number;\n /** Map a worker error/crash to a result for the failing task. */\n onError: (task: TTask, error: Error) => TResult;\n /** Optional callback fired as each task completes (for progress). */\n onResult?: (index: number, task: TTask, result: TResult) => void;\n}\n\n/**\n * Run `tasks` across a pool of workers. Each worker receives one task at a time\n * as a message and posts back a single result message.\n */\nexport function runPool<TTask, TResult>(options: RunPoolOptions<TTask, TResult>): Promise<TResult[]> {\n const { tasks, workerUrl, onError, onResult } = options;\n const results = new Array<TResult>(tasks.length);\n\n if (tasks.length === 0) {\n return Promise.resolve(results);\n }\n\n const poolSize = Math.max(1, Math.min(options.concurrency, tasks.length));\n\n return new Promise<TResult[]>((resolve) => {\n let nextTaskIndex = 0;\n let completed = 0;\n const inFlight = new Map<Worker, number>();\n const workers = new Set<Worker>();\n\n const settleIfDone = (): void => {\n if (completed === tasks.length) {\n for (const worker of workers) {\n void worker.terminate();\n }\n resolve(results);\n }\n };\n\n const recordResult = (index: number, result: TResult): void => {\n if (results[index] !== undefined) {\n return; // already recorded (e.g. error then late message)\n }\n results[index] = result;\n\n if (onResult) {\n onResult(index, tasks[index], result);\n }\n completed++;\n settleIfDone();\n };\n\n const dispatchNext = (worker: Worker): void => {\n if (nextTaskIndex >= tasks.length) {\n inFlight.delete(worker);\n workers.delete(worker);\n void worker.terminate();\n\n return;\n }\n\n const index = nextTaskIndex++;\n\n inFlight.set(worker, index);\n\n worker.once('message', (result: TResult) => {\n inFlight.delete(worker);\n recordResult(index, result);\n dispatchNext(worker);\n });\n\n worker.postMessage(tasks[index]);\n };\n\n const spawn = (): void => {\n const worker = new Worker(workerUrl);\n\n workers.add(worker);\n\n worker.on('error', (err) => {\n const index = inFlight.get(worker);\n\n inFlight.delete(worker);\n workers.delete(worker);\n void worker.terminate();\n\n if (index !== undefined) {\n recordResult(index, onError(tasks[index], err instanceof Error ? err : new Error(String(err))));\n }\n\n // Respawn to keep draining the queue if work remains.\n if (nextTaskIndex < tasks.length) {\n spawn();\n } else {\n settleIfDone();\n }\n });\n\n dispatchNext(worker);\n };\n\n for (let i = 0; i < poolSize; i++) {\n spawn();\n }\n });\n}\n","/**\n * Batch processing utilities for recursive directory conversion\n */\n\nimport { join, resolve, sep } from 'path';\nimport { scanForPackages, type PackageType, type DetectedPackage } from './packageScanner.js';\nimport { runPool } from './workerPool.js';\nimport type { BatchTask, BatchPackageOptions, PackageResult } from './batchProcessors.js';\n\n// Re-export types for backward compatibility\nexport type { PackageType, DetectedPackage };\n\n/**\n * Batch conversion summary\n */\nexport interface BatchConversionSummary {\n /** Total packages found */\n total: number;\n /** Successfully converted packages */\n succeeded: number;\n /** Failed conversions */\n failed: number;\n /** Skipped packages (wrong type or errors) */\n skipped: number;\n /** Total items successfully converted across all packages */\n totalConvertedItems: number;\n /** Total items that failed conversion across all packages */\n totalFailedItems: number;\n /** Details for each package */\n packages: Array<{\n name: string;\n type: PackageType;\n status: 'success' | 'failed' | 'skipped';\n errorCount?: number;\n warningCount?: number;\n }>;\n}\n\n/**\n * Package processor function type\n */\nexport type PackageProcessor<TOptions> = (\n pkg: DetectedPackage,\n outputPath: string,\n options: TOptions\n) => Promise<{\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}>;\n\n/**\n * Package scanner function type\n */\nexport type PackageScanner = (parentDir: string, expectedType?: PackageType) => DetectedPackage[];\n\n/**\n * Batch processor configuration\n */\nexport interface BatchProcessorConfig<TOptions> {\n inputPath: string;\n outputPath: string;\n packageType: PackageType;\n processPackage: PackageProcessor<TOptions>;\n options: TOptions;\n quiet?: boolean;\n /** Optional package scanner function (defaults to scanForPackages from packageScanner.ts) */\n scanner?: PackageScanner;\n}\n\n/**\n * Resolve the output directory for a package, mirroring the input folder\n * structure below the scanned root.\n *\n * A package found at `<input>/grade-3/maths/pkg-a` is written to\n * `<output>/grade-3/maths/pkg-a`, so siblings with the same directory name in\n * different subtrees no longer collide.\n *\n * Falls back to `pkg.name` when a scanner does not provide `relativePath`.\n */\nexport function resolvePackageOutputPath(outputPath: string, pkg: DetectedPackage): string {\n const relativePath = pkg.relativePath ?? pkg.name;\n\n // relativePath is built from readdirSync entry names below the scanned root,\n // so it cannot contain traversal segments. Resolve and verify anyway so a\n // custom scanner cannot escape the output directory.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const packageOutputPath = resolve(outputPath, relativePath);\n\n // outputPath is the operator-supplied --out directory and is the containment\n // boundary being checked below, not untrusted input being appended to it.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const outputRoot = resolve(outputPath);\n\n if (packageOutputPath !== outputRoot && !packageOutputPath.startsWith(outputRoot + sep)) {\n throw new Error(`Package output path escapes the output directory: ${relativePath}`);\n }\n\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n return join(outputPath, relativePath);\n}\n\n/**\n * Label used when reporting a package, preferring the path relative to the\n * scanned root so nested packages are distinguishable.\n */\nfunction packageLabel(pkg: DetectedPackage): string {\n return pkg.relativePath ?? pkg.name;\n}\n\n/**\n * Display batch processing summary\n */\nexport function displayBatchSummary(summary: BatchConversionSummary, quiet = false): void {\n if (quiet) {\n return;\n }\n\n console.log('\\n' + '='.repeat(60));\n console.log('Batch Conversion Summary');\n console.log('='.repeat(60));\n console.log(`Total packages: ${summary.total}`);\n console.log(`✓ Succeeded: ${summary.succeeded}`);\n console.log(`✗ Failed: ${summary.failed}`);\n console.log(`⊘ Skipped: ${summary.skipped}`);\n console.log('-'.repeat(60));\n console.log(`Total items: ${summary.totalConvertedItems + summary.totalFailedItems}`);\n console.log(`✓ Converted: ${summary.totalConvertedItems}`);\n console.log(`✗ Errored: ${summary.totalFailedItems}`);\n console.log('='.repeat(60) + '\\n');\n}\n\n/**\n * Generic batch processor that works for both conversion directions\n */\nexport async function processBatch<TOptions>(\n config: BatchProcessorConfig<TOptions>\n): Promise<BatchConversionSummary> {\n const {\n inputPath,\n outputPath,\n packageType,\n processPackage,\n options,\n quiet = false,\n scanner = scanForPackages,\n } = config;\n const startTime = Date.now();\n\n // Scan for packages using the provided scanner or default\n const packages = scanner(inputPath, packageType);\n\n if (packages.length === 0) {\n const typeLabel = packageType === 'qti' ? 'QTI packages' : 'Learnosity bundles';\n const manifestFile = packageType === 'qti' ? 'imsmanifest.xml' : 'manifest.json';\n\n console.error(`Error: No ${typeLabel} found in subdirectories.`);\n console.error(`A ${packageType} package must contain a ${manifestFile} file.`);\n process.exit(1);\n }\n\n if (!quiet) {\n const typeLabel = packageType === 'qti' ? 'QTI package(s)' : 'Learnosity bundle(s)';\n\n console.log(`Found ${packages.length} ${typeLabel}:\\n`);\n packages.forEach((pkg, idx) => {\n console.log(` ${idx + 1}. ${packageLabel(pkg)}`);\n });\n console.log('');\n }\n\n // Initialize summary\n const summary: BatchConversionSummary = {\n total: packages.length,\n succeeded: 0,\n failed: 0,\n skipped: 0,\n totalConvertedItems: 0,\n totalFailedItems: 0,\n packages: [],\n };\n\n // Process each package\n for (let i = 0; i < packages.length; i++) {\n const pkg = packages[i];\n\n // Mirror the input folder structure below the scanned root.\n const packageOutputPath = resolvePackageOutputPath(outputPath, pkg);\n\n if (!quiet) {\n console.log(`\\n[${i + 1}/${packages.length}] Converting: ${packageLabel(pkg)}`);\n console.log(` Input: ${pkg.path}`);\n console.log(` Output: ${packageOutputPath}`);\n console.log('');\n }\n\n try {\n const result = await processPackage(pkg, packageOutputPath, options);\n\n summary.totalConvertedItems += result.convertedItemCount ?? 0;\n summary.totalFailedItems += result.failedItemCount ?? 0;\n\n if (result.success) {\n summary.succeeded++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'success',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n\n if (!quiet) {\n console.log(\n ` ✓ SUCCESS (${result.errorCount} error(s), ${result.warningCount} warning(s))`\n );\n }\n } else {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n\n if (!quiet) {\n console.error(` ✗ FAILED (${result.errorCount} error(s))`);\n if (result.message) {\n console.error(` ${result.message}`);\n }\n }\n }\n } catch (error) {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: 1,\n });\n\n if (!quiet) {\n console.error(\n ` ✗ FAILED: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n }\n\n // Display summary\n displayBatchSummary(summary, quiet);\n\n const duration = ((Date.now() - startTime) / 1000).toFixed(2);\n\n if (!quiet) {\n console.log(`Completed in ${duration}s\\n`);\n }\n\n // Exit with appropriate code\n if (summary.failed > 0 && summary.succeeded === 0) {\n process.exit(1);\n }\n\n return summary;\n}\n\n/**\n * Configuration for the parallel (worker-pool) batch processor.\n */\nexport interface ParallelBatchConfig {\n inputPath: string;\n outputPath: string;\n packageType: PackageType;\n direction: BatchTask['direction'];\n options: BatchPackageOptions;\n /** Max concurrent worker threads. */\n concurrency: number;\n quiet?: boolean;\n scanner?: PackageScanner;\n /** Worker module URL (defaults to the built batchWorker.js next to main.js). */\n workerUrl?: URL | string;\n}\n\n/**\n * Parallel batch processor: converts packages across a pool of worker threads.\n *\n * Behaviour mirrors {@link processBatch} — same scan, summary shape, console\n * summary and exit code — but per-package conversion runs on worker threads so\n * multiple cores are used. Results are aggregated in package order for a\n * deterministic summary.\n */\nexport async function processBatchParallel(\n config: ParallelBatchConfig\n): Promise<BatchConversionSummary> {\n const {\n inputPath,\n outputPath,\n packageType,\n direction,\n options,\n concurrency,\n quiet = false,\n scanner = scanForPackages,\n workerUrl = new URL('./batchWorker.js', import.meta.url),\n } = config;\n const startTime = Date.now();\n\n const packages = scanner(inputPath, packageType);\n\n if (packages.length === 0) {\n const typeLabel = packageType === 'qti' ? 'QTI packages' : 'Learnosity bundles';\n const manifestFile = packageType === 'qti' ? 'imsmanifest.xml' : 'manifest.json';\n\n console.error(`Error: No ${typeLabel} found in subdirectories.`);\n console.error(`A ${packageType} package must contain a ${manifestFile} file.`);\n process.exit(1);\n }\n\n if (!quiet) {\n const typeLabel = packageType === 'qti' ? 'QTI package(s)' : 'Learnosity bundle(s)';\n\n console.log(\n `Found ${packages.length} ${typeLabel} (converting with ${Math.min(concurrency, packages.length)} workers):\\n`\n );\n packages.forEach((pkg, idx) => {\n console.log(` ${idx + 1}. ${packageLabel(pkg)}`);\n });\n console.log('');\n }\n\n const tasks: BatchTask[] = packages.map((pkg) => ({\n direction,\n pkg,\n // Mirror the input folder structure below the scanned root.\n packageOutputPath: resolvePackageOutputPath(outputPath, pkg),\n options,\n }));\n\n const results = await runPool<BatchTask, PackageResult>({\n tasks,\n workerUrl,\n concurrency,\n onError: (_task, error) => ({\n success: false,\n errorCount: 1,\n warningCount: 0,\n message: error.message,\n }),\n onResult: (index, task, result) => {\n if (quiet) {\n return;\n }\n\n if (result.success) {\n console.log(\n ` ✓ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} (${result.errorCount} error(s), ${result.warningCount} warning(s))`\n );\n } else {\n console.error(\n ` ✗ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} FAILED (${result.errorCount} error(s))${result.message ? `: ${result.message}` : ''}`\n );\n }\n },\n });\n\n // Aggregate summary in package order (deterministic).\n const summary: BatchConversionSummary = {\n total: packages.length,\n succeeded: 0,\n failed: 0,\n skipped: 0,\n totalConvertedItems: 0,\n totalFailedItems: 0,\n packages: [],\n };\n\n for (let i = 0; i < packages.length; i++) {\n const pkg = packages[i];\n const result = results[i];\n\n summary.totalConvertedItems += result.convertedItemCount ?? 0;\n summary.totalFailedItems += result.failedItemCount ?? 0;\n\n if (result.success) {\n summary.succeeded++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'success',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n } else {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n }\n }\n\n displayBatchSummary(summary, quiet);\n\n const duration = ((Date.now() - startTime) / 1000).toFixed(2);\n\n if (!quiet) {\n console.log(`Completed in ${duration}s\\n`);\n }\n\n if (summary.failed > 0 && summary.succeeded === 0) {\n process.exit(1);\n }\n\n return summary;\n}\n","/**\n * Shared utilities for displaying configuration output in CLI commands\n */\n\nexport interface ConfigField {\n label: string;\n value: string | number | boolean;\n indent?: number;\n}\n\nexport interface ConfigOutputOptions {\n quiet?: boolean;\n}\n\n/**\n * Display a configuration block with consistent formatting\n */\nexport function displayConfiguration(fields: ConfigField[], options: ConfigOutputOptions = {}): void {\n if (options.quiet) {\n return;\n }\n\n console.log('\\nConfiguration:');\n\n for (const field of fields) {\n const indent = field.indent ?? 0;\n const padding = ' ' + ' '.repeat(indent * 2);\n const label = field.label.padEnd(14 - indent * 2, ' ');\n\n console.log(`${padding}${label}${field.value}`);\n }\n\n console.log('');\n}\n\n/**\n * Helper to create a config field\n */\nexport function configField(label: string, value: string | number | boolean, indent = 0): ConfigField {\n return { label, value, indent };\n}\n\n/**\n * Format a list of items for configuration output\n */\nexport function formatList(items: string[], _singular: string, plural: string, showAll = false): string {\n if (items.length === 0) {\n return `0 ${plural}`;\n }\n if (items.length === 1) {\n return items[0];\n }\n\n return `${items.length} ${plural}${showAll ? ' (all)' : ''}`;\n}\n\n"],"mappings":";;;;;;;;;;;AAoCA,SAAgB,aAAa,SAA0B;CACnD,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,YAAY,GACvD,OAAO;CAMX,MAAM,eAAe,KAAK,SAAS,iBAAiB;CAEpD,OAAO,WAAW,YAAY;AAClC;;;;;AAMA,SAAgB,mBAAmB,SAA0B;CACzD,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,YAAY,GACvD,OAAO;CAKX,MAAM,eAAe,KAAK,SAAS,eAAe;CAElD,OAAO,WAAW,YAAY;AAClC;;;;AAKA,SAAgB,kBAAkB,SAA8B;CAC5D,IAAI,aAAa,OAAO,GACpB,OAAO;CAEX,IAAI,mBAAmB,OAAO,GAC1B,OAAO;CAGX,OAAO;AACX;;;;;;;;AASA,SAAgB,gBAAgB,WAAmB,cAA+C;CAC9F,MAAM,WAA8B,CAAC;CAErC,IAAI,CAAC,WAAW,SAAS,GACrB,OAAO;CAKX,IAAI,CAFS,SAAS,SAEd,CAAC,CAAC,YAAY,GAClB,OAAO;;;;;;;CASX,SAAS,cAAc,YAAoB,aAA2B;EAElE,MAAM,QAAQ,YAAY,UAAU;EAEpC,KAAK,MAAM,QAAQ,OAAO;GAItB,MAAM,WAAW,KAAK,YAAY,IAAI;GAKtC,MAAM,mBAAmB,cAAc,KAAK,aAAa,IAAI,IAAI;GAGjE,IAAI;IACA,IAAI,CAAC,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QAAQ,IAAI,kBAAkB;CAE9B,KAAK,MAAM,SAAS,QAAQ;EACxB,MAAM,SAAS,MAAM,UAAU;EAC/B,MAAM,UAAU,OAAO,IAAI,OAAO,SAAS,CAAC;EAC5C,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,SAAS,GAAG,GAAG;EAErD,QAAQ,IAAI,GAAG,UAAU,QAAQ,MAAM,OAAO;CAClD;CAEA,QAAQ,IAAI,EAAE;AAClB;;;;AAKA,SAAgB,YAAY,OAAe,OAAkC,SAAS,GAAgB;CAClG,OAAO;EAAE;EAAO;EAAO;CAAO;AAClC"}
1
+ {"version":3,"file":"configOutput-DYPwNQf7.js","names":[],"sources":["../src/utils/packageScanner.ts","../src/utils/workerPool.ts","../src/utils/batchProcessing.ts","../src/utils/configOutput.ts"],"sourcesContent":["/**\n * Package scanning utilities for detecting QTI and Learnosity packages\n */\n\nimport { existsSync, statSync, readdirSync } from 'fs';\nimport { join, basename } from 'path';\n\n/**\n * Package type detection result\n */\nexport type PackageType = 'qti' | 'learnosity' | 'unknown';\n\n/**\n * Detected package information\n */\nexport interface DetectedPackage {\n /** Absolute path to the package directory */\n path: string;\n /** Package directory name */\n name: string;\n /**\n * Path to the package relative to the scanned root directory, e.g.\n * `grade-3/maths/package-a`. Used to mirror the input folder structure in\n * the output directory. Equals `name` for packages directly under the root.\n *\n * Optional so custom scanners can omit it; consumers fall back to `name`.\n */\n relativePath?: string;\n /** Detected package type */\n type: PackageType;\n}\n\n/**\n * Detect if a directory is a QTI package\n * A QTI package must contain an imsmanifest.xml file\n */\nexport function isQtiPackage(dirPath: string): boolean {\n if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) {\n return false;\n }\n\n // dirPath is a directory the operator pointed the CLI at; the filename is a\n // literal, so this join cannot traverse anywhere the caller did not ask for.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const manifestPath = join(dirPath, 'imsmanifest.xml');\n\n return existsSync(manifestPath);\n}\n\n/**\n * Detect if a directory is a Learnosity bundle\n * A Learnosity bundle must contain a manifest.json file\n */\nexport function isLearnosityBundle(dirPath: string): boolean {\n if (!existsSync(dirPath) || !statSync(dirPath).isDirectory()) {\n return false;\n }\n\n // Same as isQtiPackage: operator-supplied directory plus a literal filename.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const manifestPath = join(dirPath, 'manifest.json');\n\n return existsSync(manifestPath);\n}\n\n/**\n * Detect package type for a directory\n */\nexport function detectPackageType(dirPath: string): PackageType {\n if (isQtiPackage(dirPath)) {\n return 'qti';\n }\n if (isLearnosityBundle(dirPath)) {\n return 'learnosity';\n }\n\n return 'unknown';\n}\n\n/**\n * Scan a directory recursively for packages and detect their package types\n *\n * @param parentDir - Parent directory containing subdirectories to scan\n * @param expectedType - Optional filter to only return packages of a specific type\n * @returns Array of detected packages\n */\nexport function scanForPackages(parentDir: string, expectedType?: PackageType): DetectedPackage[] {\n const packages: DetectedPackage[] = [];\n\n if (!existsSync(parentDir)) {\n return packages;\n }\n\n const stat = statSync(parentDir);\n\n if (!stat.isDirectory()) {\n return packages;\n }\n\n /**\n * Recursively scan directories for packages\n *\n * @param currentDir - Directory being scanned\n * @param relativeDir - Path of `currentDir` relative to `parentDir` ('' at the root)\n */\n function scanRecursive(currentDir: string, relativeDir: string): void {\n // Read all items in the current directory\n const items = readdirSync(currentDir);\n\n for (const item of items) {\n // item comes from readdirSync, so it is a single existing directory\n // entry name and cannot contain separators or traversal segments.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const itemPath = join(currentDir, item);\n\n // relativeDir is built from earlier readdirSync entry names and item is\n // a single entry name, so this label cannot escape the scanned root.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const itemRelativePath = relativeDir ? join(relativeDir, item) : item;\n\n // Skip non-directories\n try {\n if (!statSync(itemPath).isDirectory()) {\n continue;\n }\n } catch {\n // Skip items that can't be accessed (permissions, broken symlinks, etc.)\n continue;\n }\n\n // Detect package type\n const type = detectPackageType(itemPath);\n\n // If this directory is a package, add it and don't recurse into it\n if (type !== 'unknown') {\n // Skip if type doesn't match expected type (if specified)\n if (expectedType && type !== expectedType) {\n continue;\n }\n\n packages.push({\n path: itemPath,\n name: basename(itemPath),\n relativePath: itemRelativePath,\n type,\n });\n\n // Don't recurse into package directories\n continue;\n }\n\n // If not a package, recurse into subdirectories\n scanRecursive(itemPath, itemRelativePath);\n }\n }\n\n scanRecursive(parentDir, '');\n\n return packages;\n}\n","/**\n * Minimal reusable worker_threads pool.\n *\n * Spawns up to `concurrency` long-lived workers, dispatches one task at a time\n * to each idle worker, and resolves with results in the SAME order as the input\n * tasks (deterministic) regardless of completion order. A worker error/crash\n * fails only its in-flight task (via `onError`) and the worker is respawned if\n * work remains, so one bad package can't sink the whole batch.\n */\n\nimport { Worker } from 'node:worker_threads';\n\nexport interface RunPoolOptions<TTask, TResult> {\n /** Tasks to process (results are returned in this order). */\n tasks: TTask[];\n /** URL/path of the worker module. */\n workerUrl: URL | string;\n /** Max concurrent workers (clamped to [1, tasks.length]). */\n concurrency: number;\n /** Map a worker error/crash to a result for the failing task. */\n onError: (task: TTask, error: Error) => TResult;\n /** Optional callback fired as each task completes (for progress). */\n onResult?: (index: number, task: TTask, result: TResult) => void;\n}\n\n/**\n * Run `tasks` across a pool of workers. Each worker receives one task at a time\n * as a message and posts back a single result message.\n */\nexport function runPool<TTask, TResult>(options: RunPoolOptions<TTask, TResult>): Promise<TResult[]> {\n const { tasks, workerUrl, onError, onResult } = options;\n const results = new Array<TResult>(tasks.length);\n\n if (tasks.length === 0) {\n return Promise.resolve(results);\n }\n\n const poolSize = Math.max(1, Math.min(options.concurrency, tasks.length));\n\n return new Promise<TResult[]>((resolve) => {\n let nextTaskIndex = 0;\n let completed = 0;\n const inFlight = new Map<Worker, number>();\n const workers = new Set<Worker>();\n\n const settleIfDone = (): void => {\n if (completed === tasks.length) {\n for (const worker of workers) {\n void worker.terminate();\n }\n resolve(results);\n }\n };\n\n const recordResult = (index: number, result: TResult): void => {\n if (results[index] !== undefined) {\n return; // already recorded (e.g. error then late message)\n }\n results[index] = result;\n\n if (onResult) {\n onResult(index, tasks[index], result);\n }\n completed++;\n settleIfDone();\n };\n\n const dispatchNext = (worker: Worker): void => {\n if (nextTaskIndex >= tasks.length) {\n inFlight.delete(worker);\n workers.delete(worker);\n void worker.terminate();\n\n return;\n }\n\n const index = nextTaskIndex++;\n\n inFlight.set(worker, index);\n\n worker.once('message', (result: TResult) => {\n inFlight.delete(worker);\n recordResult(index, result);\n dispatchNext(worker);\n });\n\n worker.postMessage(tasks[index]);\n };\n\n const spawn = (): void => {\n const worker = new Worker(workerUrl);\n\n workers.add(worker);\n\n worker.on('error', (err) => {\n const index = inFlight.get(worker);\n\n inFlight.delete(worker);\n workers.delete(worker);\n void worker.terminate();\n\n if (index !== undefined) {\n recordResult(index, onError(tasks[index], err instanceof Error ? err : new Error(String(err))));\n }\n\n // Respawn to keep draining the queue if work remains.\n if (nextTaskIndex < tasks.length) {\n spawn();\n } else {\n settleIfDone();\n }\n });\n\n dispatchNext(worker);\n };\n\n for (let i = 0; i < poolSize; i++) {\n spawn();\n }\n });\n}\n","/**\n * Batch processing utilities for recursive directory conversion\n */\n\nimport { join, resolve, sep } from 'path';\nimport { scanForPackages, type PackageType, type DetectedPackage } from './packageScanner.js';\nimport { runPool } from './workerPool.js';\nimport type { BatchTask, BatchPackageOptions, PackageResult } from './batchProcessors.js';\n\n// Re-export types for backward compatibility\nexport type { PackageType, DetectedPackage };\n\n/**\n * Batch conversion summary\n */\nexport interface BatchConversionSummary {\n /** Total packages found */\n total: number;\n /** Successfully converted packages */\n succeeded: number;\n /** Failed conversions */\n failed: number;\n /** Skipped packages (wrong type or errors) */\n skipped: number;\n /** Total items successfully converted across all packages */\n totalConvertedItems: number;\n /** Total items that failed conversion across all packages */\n totalFailedItems: number;\n /** Details for each package */\n packages: Array<{\n name: string;\n type: PackageType;\n status: 'success' | 'failed' | 'skipped';\n errorCount?: number;\n warningCount?: number;\n }>;\n}\n\n/**\n * Package processor function type\n */\nexport type PackageProcessor<TOptions> = (\n pkg: DetectedPackage,\n outputPath: string,\n options: TOptions\n) => Promise<{\n success: boolean;\n errorCount: number;\n warningCount: number;\n convertedItemCount?: number;\n failedItemCount?: number;\n message?: string;\n}>;\n\n/**\n * Package scanner function type\n */\nexport type PackageScanner = (parentDir: string, expectedType?: PackageType) => DetectedPackage[];\n\n/**\n * Batch processor configuration\n */\nexport interface BatchProcessorConfig<TOptions> {\n inputPath: string;\n outputPath: string;\n packageType: PackageType;\n processPackage: PackageProcessor<TOptions>;\n options: TOptions;\n quiet?: boolean;\n /** Optional package scanner function (defaults to scanForPackages from packageScanner.ts) */\n scanner?: PackageScanner;\n}\n\n/**\n * Resolve the output directory for a package, mirroring the input folder\n * structure below the scanned root.\n *\n * A package found at `<input>/grade-3/maths/pkg-a` is written to\n * `<output>/grade-3/maths/pkg-a`, so siblings with the same directory name in\n * different subtrees no longer collide.\n *\n * Falls back to `pkg.name` when a scanner does not provide `relativePath`.\n */\nexport function resolvePackageOutputPath(outputPath: string, pkg: DetectedPackage): string {\n const relativePath = pkg.relativePath ?? pkg.name;\n\n // relativePath is built from readdirSync entry names below the scanned root,\n // so it cannot contain traversal segments. Resolve and verify anyway so a\n // custom scanner cannot escape the output directory.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const packageOutputPath = resolve(outputPath, relativePath);\n\n // outputPath is the operator-supplied --out directory and is the containment\n // boundary being checked below, not untrusted input being appended to it.\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n const outputRoot = resolve(outputPath);\n\n if (packageOutputPath !== outputRoot && !packageOutputPath.startsWith(outputRoot + sep)) {\n throw new Error(`Package output path escapes the output directory: ${relativePath}`);\n }\n\n // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal, javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal\n return join(outputPath, relativePath);\n}\n\n/**\n * Label used when reporting a package, preferring the path relative to the\n * scanned root so nested packages are distinguishable.\n */\nfunction packageLabel(pkg: DetectedPackage): string {\n return pkg.relativePath ?? pkg.name;\n}\n\n/**\n * Display batch processing summary\n */\nexport function displayBatchSummary(summary: BatchConversionSummary, quiet = false): void {\n if (quiet) {\n return;\n }\n\n console.log('\\n' + '='.repeat(60));\n console.log('Batch Conversion Summary');\n console.log('='.repeat(60));\n console.log(`Total packages: ${summary.total}`);\n console.log(`✓ Succeeded: ${summary.succeeded}`);\n console.log(`✗ Failed: ${summary.failed}`);\n console.log(`⊘ Skipped: ${summary.skipped}`);\n console.log('-'.repeat(60));\n console.log(`Total items: ${summary.totalConvertedItems + summary.totalFailedItems}`);\n console.log(`✓ Converted: ${summary.totalConvertedItems}`);\n console.log(`✗ Errored: ${summary.totalFailedItems}`);\n console.log('='.repeat(60) + '\\n');\n}\n\n/**\n * Generic batch processor that works for both conversion directions\n */\nexport async function processBatch<TOptions>(\n config: BatchProcessorConfig<TOptions>\n): Promise<BatchConversionSummary> {\n const {\n inputPath,\n outputPath,\n packageType,\n processPackage,\n options,\n quiet = false,\n scanner = scanForPackages,\n } = config;\n const startTime = Date.now();\n\n // Scan for packages using the provided scanner or default\n const packages = scanner(inputPath, packageType);\n\n if (packages.length === 0) {\n const typeLabel = packageType === 'qti' ? 'QTI packages' : 'Learnosity bundles';\n const manifestFile = packageType === 'qti' ? 'imsmanifest.xml' : 'manifest.json';\n\n console.error(`Error: No ${typeLabel} found in subdirectories.`);\n console.error(`A ${packageType} package must contain a ${manifestFile} file.`);\n process.exit(1);\n }\n\n if (!quiet) {\n const typeLabel = packageType === 'qti' ? 'QTI package(s)' : 'Learnosity bundle(s)';\n\n console.log(`Found ${packages.length} ${typeLabel}:\\n`);\n packages.forEach((pkg, idx) => {\n console.log(` ${idx + 1}. ${packageLabel(pkg)}`);\n });\n console.log('');\n }\n\n // Initialize summary\n const summary: BatchConversionSummary = {\n total: packages.length,\n succeeded: 0,\n failed: 0,\n skipped: 0,\n totalConvertedItems: 0,\n totalFailedItems: 0,\n packages: [],\n };\n\n // Process each package\n for (let i = 0; i < packages.length; i++) {\n const pkg = packages[i];\n\n // Mirror the input folder structure below the scanned root.\n const packageOutputPath = resolvePackageOutputPath(outputPath, pkg);\n\n if (!quiet) {\n console.log(`\\n[${i + 1}/${packages.length}] Converting: ${packageLabel(pkg)}`);\n console.log(` Input: ${pkg.path}`);\n console.log(` Output: ${packageOutputPath}`);\n console.log('');\n }\n\n try {\n const result = await processPackage(pkg, packageOutputPath, options);\n\n summary.totalConvertedItems += result.convertedItemCount ?? 0;\n summary.totalFailedItems += result.failedItemCount ?? 0;\n\n if (result.success) {\n summary.succeeded++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'success',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n\n if (!quiet) {\n console.log(\n ` ✓ SUCCESS (${result.errorCount} error(s), ${result.warningCount} warning(s))`\n );\n }\n } else {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n\n if (!quiet) {\n console.error(` ✗ FAILED (${result.errorCount} error(s))`);\n if (result.message) {\n console.error(` ${result.message}`);\n }\n }\n }\n } catch (error) {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: 1,\n });\n\n if (!quiet) {\n console.error(\n ` ✗ FAILED: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n }\n\n // Display summary\n displayBatchSummary(summary, quiet);\n\n const duration = ((Date.now() - startTime) / 1000).toFixed(2);\n\n if (!quiet) {\n console.log(`Completed in ${duration}s\\n`);\n }\n\n // Exit with appropriate code\n if (summary.failed > 0 && summary.succeeded === 0) {\n process.exit(1);\n }\n\n return summary;\n}\n\n/**\n * Configuration for the parallel (worker-pool) batch processor.\n */\nexport interface ParallelBatchConfig {\n inputPath: string;\n outputPath: string;\n packageType: PackageType;\n direction: BatchTask['direction'];\n options: BatchPackageOptions;\n /** Max concurrent worker threads. */\n concurrency: number;\n quiet?: boolean;\n scanner?: PackageScanner;\n /** Worker module URL (defaults to the built batchWorker.js next to main.js). */\n workerUrl?: URL | string;\n}\n\n/**\n * Parallel batch processor: converts packages across a pool of worker threads.\n *\n * Behaviour mirrors {@link processBatch} — same scan, summary shape, console\n * summary and exit code — but per-package conversion runs on worker threads so\n * multiple cores are used. Results are aggregated in package order for a\n * deterministic summary.\n */\nexport async function processBatchParallel(\n config: ParallelBatchConfig\n): Promise<BatchConversionSummary> {\n const {\n inputPath,\n outputPath,\n packageType,\n direction,\n options,\n concurrency,\n quiet = false,\n scanner = scanForPackages,\n workerUrl = new URL('./batchWorker.js', import.meta.url),\n } = config;\n const startTime = Date.now();\n\n const packages = scanner(inputPath, packageType);\n\n if (packages.length === 0) {\n const typeLabel = packageType === 'qti' ? 'QTI packages' : 'Learnosity bundles';\n const manifestFile = packageType === 'qti' ? 'imsmanifest.xml' : 'manifest.json';\n\n console.error(`Error: No ${typeLabel} found in subdirectories.`);\n console.error(`A ${packageType} package must contain a ${manifestFile} file.`);\n process.exit(1);\n }\n\n if (!quiet) {\n const typeLabel = packageType === 'qti' ? 'QTI package(s)' : 'Learnosity bundle(s)';\n\n console.log(\n `Found ${packages.length} ${typeLabel} (converting with ${Math.min(concurrency, packages.length)} workers):\\n`\n );\n packages.forEach((pkg, idx) => {\n console.log(` ${idx + 1}. ${packageLabel(pkg)}`);\n });\n console.log('');\n }\n\n const tasks: BatchTask[] = packages.map((pkg) => ({\n direction,\n pkg,\n // Mirror the input folder structure below the scanned root.\n packageOutputPath: resolvePackageOutputPath(outputPath, pkg),\n options,\n }));\n\n const results = await runPool<BatchTask, PackageResult>({\n tasks,\n workerUrl,\n concurrency,\n onError: (_task, error) => ({\n success: false,\n errorCount: 1,\n warningCount: 0,\n message: error.message,\n }),\n onResult: (index, task, result) => {\n if (quiet) {\n return;\n }\n\n if (result.success) {\n console.log(\n ` ✓ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} (${result.errorCount} error(s), ${result.warningCount} warning(s))`\n );\n } else {\n console.error(\n ` ✗ [${index + 1}/${tasks.length}] ${packageLabel(task.pkg)} FAILED (${result.errorCount} error(s))${result.message ? `: ${result.message}` : ''}`\n );\n }\n },\n });\n\n // Aggregate summary in package order (deterministic).\n const summary: BatchConversionSummary = {\n total: packages.length,\n succeeded: 0,\n failed: 0,\n skipped: 0,\n totalConvertedItems: 0,\n totalFailedItems: 0,\n packages: [],\n };\n\n for (let i = 0; i < packages.length; i++) {\n const pkg = packages[i];\n const result = results[i];\n\n summary.totalConvertedItems += result.convertedItemCount ?? 0;\n summary.totalFailedItems += result.failedItemCount ?? 0;\n\n if (result.success) {\n summary.succeeded++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'success',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n } else {\n summary.failed++;\n summary.packages.push({\n name: packageLabel(pkg),\n type: pkg.type,\n status: 'failed',\n errorCount: result.errorCount,\n warningCount: result.warningCount,\n });\n }\n }\n\n displayBatchSummary(summary, quiet);\n\n const duration = ((Date.now() - startTime) / 1000).toFixed(2);\n\n if (!quiet) {\n console.log(`Completed in ${duration}s\\n`);\n }\n\n if (summary.failed > 0 && summary.succeeded === 0) {\n process.exit(1);\n }\n\n return summary;\n}\n","/**\n * Shared utilities for displaying configuration output in CLI commands\n */\n\nexport interface ConfigField {\n label: string;\n value: string | number | boolean;\n indent?: number;\n}\n\nexport interface ConfigOutputOptions {\n quiet?: boolean;\n}\n\n/**\n * Display a configuration block with consistent formatting\n */\nexport function displayConfiguration(fields: ConfigField[], options: ConfigOutputOptions = {}): void {\n if (options.quiet) {\n return;\n }\n\n console.log('\\nConfiguration:');\n\n for (const field of fields) {\n const indent = field.indent ?? 0;\n const padding = ' ' + ' '.repeat(indent * 2);\n const label = field.label.padEnd(14 - indent * 2, ' ');\n\n console.log(`${padding}${label}${field.value}`);\n }\n\n console.log('');\n}\n\n/**\n * Helper to create a config field\n */\nexport function configField(label: string, value: string | number | boolean, indent = 0): ConfigField {\n return { label, value, indent };\n}\n\n/**\n * Format a list of items for configuration output\n */\nexport function formatList(items: string[], _singular: string, plural: string, showAll = false): string {\n if (items.length === 0) {\n return `0 ${plural}`;\n }\n if (items.length === 1) {\n return items[0];\n }\n\n return `${items.length} ${plural}${showAll ? ' (all)' : ''}`;\n}\n\n"],"mappings":";;;;;;;;;;;AAoCA,SAAgB,aAAa,SAA0B;CACnD,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,YAAY,GACvD,OAAO;CAMX,MAAM,eAAe,KAAK,SAAS,iBAAiB;CAEpD,OAAO,WAAW,YAAY;AAClC;;;;;AAMA,SAAgB,mBAAmB,SAA0B;CACzD,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,YAAY,GACvD,OAAO;CAKX,MAAM,eAAe,KAAK,SAAS,eAAe;CAElD,OAAO,WAAW,YAAY;AAClC;;;;AAKA,SAAgB,kBAAkB,SAA8B;CAC5D,IAAI,aAAa,OAAO,GACpB,OAAO;CAEX,IAAI,mBAAmB,OAAO,GAC1B,OAAO;CAGX,OAAO;AACX;;;;;;;;AASA,SAAgB,gBAAgB,WAAmB,cAA+C;CAC9F,MAAM,WAA8B,CAAC;CAErC,IAAI,CAAC,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AK;CAElC,MAAM,aAAa,KAAK,IAAI,IAAI,aAAa,IAAA,CAAM,QAAQ,CAAC;CAE5D,IAAI,CAAC,OACD,QAAQ,IAAI,gBAAgB,SAAS,IAAI;CAG7C,IAAI,QAAQ,SAAS,KAAK,QAAQ,cAAc,GAC5C,QAAQ,KAAK,CAAC;CAGlB,OAAO;AACX;;;;;ACrZA,SAAgB,qBAAqB,QAAuB,UAA+B,CAAC,GAAS;CACjG,IAAI,QAAQ,OACR;CAGJ,QAAQ,IAAI,kBAAkB;CAE9B,KAAK,MAAM,SAAS,QAAQ;EACxB,MAAM,SAAS,MAAM,UAAU;EAC/B,MAAM,UAAU,OAAO,IAAI,OAAO,SAAS,CAAC;EAC5C,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,SAAS,GAAG,GAAG;EAErD,QAAQ,IAAI,GAAG,UAAU,QAAQ,MAAM,OAAO;CAClD;CAEA,QAAQ,IAAI,EAAE;AAClB;;;;AAKA,SAAgB,YAAY,OAAe,OAAkC,SAAS,GAAgB;CAClG,OAAO;EAAE;EAAO;EAAO;CAAO;AAClC"}
@@ -1,10 +1,16 @@
1
- import { i as __toESM, r as __require, t as __commonJSMin } from "./rolldown-runtime-BVN1G_yT.js";
1
+ import { i as __toESM, t as __commonJSMin } from "./rolldown-runtime-BuRBZLzk.js";
2
2
  import path from "node:path";
3
3
  import process$2 from "node:process";
4
4
  import { stripVTControlCharacters, styleText } from "node:util";
5
5
  import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
6
6
  import * as readline from "node:readline";
7
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/key.js
7
+ import { createRequire as __createRequire } from "node:module";
8
+ function __require() {
9
+ const require = __createRequire(import.meta.url);
10
+ __require = () => require;
11
+ return require;
12
+ }
13
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/key.js
8
14
  const keybindingLookup = /* @__PURE__ */ new Set(["emacs", "vim"]);
9
15
  function isKeybinding(value) {
10
16
  return keybindingLookup.has(value);
@@ -21,7 +27,7 @@ const isBackspaceKey = (key) => key.name === "backspace";
21
27
  const isTabKey = (key) => key.name === "tab";
22
28
  const isNumberKey = (key) => "1234567890".includes(key.name);
23
29
  const isEnterKey = (key) => key.name === "enter" || key.name === "return";
24
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/errors.js
30
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/errors.js
25
31
  var AbortPromptError = class extends Error {
26
32
  name = "AbortPromptError";
27
33
  message = "Prompt was aborted";
@@ -43,7 +49,8 @@ var HookError = class extends Error {
43
49
  var ValidationError = class extends Error {
44
50
  name = "ValidationError";
45
51
  };
46
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/hook-engine.js
52
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/hook-engine.js
53
+ const nativeQueueMicrotask = globalThis.queueMicrotask;
47
54
  const hookStorage = new AsyncLocalStorage();
48
55
  function createStore(rl) {
49
56
  return {
@@ -52,7 +59,8 @@ function createStore(rl) {
52
59
  hooksCleanup: [],
53
60
  hooksEffect: [],
54
61
  index: 0,
55
- handleChange() {}
62
+ handleChange() {},
63
+ deferredPaint: null
56
64
  };
57
65
  }
58
66
  function withHooks(rl, cb) {
@@ -79,16 +87,34 @@ function withUpdates(fn) {
79
87
  const store = getStore();
80
88
  let shouldUpdate = false;
81
89
  const oldHandleChange = store.handleChange;
82
- store.handleChange = () => {
90
+ const recordChange = () => {
83
91
  shouldUpdate = true;
84
92
  };
93
+ store.handleChange = recordChange;
85
94
  const returnValue = fn(...args);
86
- if (shouldUpdate) oldHandleChange();
87
- store.handleChange = oldHandleChange;
95
+ if (shouldUpdate) {
96
+ let flushedUpdate = false;
97
+ store.handleChange = () => {
98
+ flushedUpdate = true;
99
+ };
100
+ oldHandleChange();
101
+ store.handleChange = oldHandleChange;
102
+ if (flushedUpdate) scheduleDeferredPaint(store, oldHandleChange);
103
+ } else store.handleChange = oldHandleChange;
88
104
  return returnValue;
89
105
  };
90
106
  return AsyncResource.bind(wrapped);
91
107
  }
108
+ function scheduleDeferredPaint(store, paint) {
109
+ if (store.deferredPaint !== null) return;
110
+ store.deferredPaint = AsyncResource.bind(paint);
111
+ nativeQueueMicrotask(() => {
112
+ const pending = store.deferredPaint;
113
+ if (pending === null) return;
114
+ store.deferredPaint = null;
115
+ pending();
116
+ });
117
+ }
92
118
  function withPointer(cb) {
93
119
  const store = getStore();
94
120
  const { index } = store;
@@ -134,9 +160,10 @@ const effectScheduler = {
134
160
  });
135
161
  store.hooksEffect.length = 0;
136
162
  store.hooksCleanup.length = 0;
163
+ store.deferredPaint = null;
137
164
  }
138
165
  };
139
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-state.js
166
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/use-state.js
140
167
  function isFactory(value) {
141
168
  return typeof value === "function";
142
169
  }
@@ -159,7 +186,7 @@ function useState(defaultValue) {
159
186
  return [value, setState];
160
187
  });
161
188
  }
162
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-effect.js
189
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/use-effect.js
163
190
  function useEffect(cb, depArray) {
164
191
  withPointer((pointer) => {
165
192
  const oldDeps = pointer.get();
@@ -167,7 +194,7 @@ function useEffect(cb, depArray) {
167
194
  pointer.set(depArray);
168
195
  });
169
196
  }
170
- // ../../node_modules/.pnpm/@inquirer+figures@2.0.10/node_modules/@inquirer/figures/dist/index.js
197
+ // ../../node_modules/.pnpm/@inquirer+figures@2.1.1/node_modules/@inquirer/figures/dist/index.js
171
198
  function isUnicodeSupported() {
172
199
  if (!process$2.platform.startsWith("win")) return process$2.env["TERM"] !== "linux";
173
200
  return Boolean(process$2.env["CI"]) || Boolean(process$2.env["WT_SESSION"]) || Boolean(process$2.env["TERMINUS_SUBLIME"]) || process$2.env["ConEmuTask"] === "{cmd::Cmder}" || process$2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process$2.env["TERM_PROGRAM"] === "vscode" || process$2.env["TERM"] === "xterm-256color" || process$2.env["TERM"] === "alacritty" || process$2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
@@ -450,7 +477,7 @@ const fallbackSymbols = {
450
477
  };
451
478
  const figures = isUnicodeSupported() ? mainSymbols : fallbackSymbols;
452
479
  Object.entries(specialMainSymbols);
453
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/theme.js
480
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/theme.js
454
481
  const defaultTheme = {
455
482
  prefix: {
456
483
  idle: styleText("blue", "?"),
@@ -488,7 +515,7 @@ function getDefaultTheme() {
488
515
  keybindings: getDefaultKeybindings()
489
516
  };
490
517
  }
491
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/make-theme.js
518
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/make-theme.js
492
519
  function isPlainObject(value) {
493
520
  if (typeof value !== "object" || value === null) return false;
494
521
  let proto = value;
@@ -498,6 +525,7 @@ function isPlainObject(value) {
498
525
  function deepMerge(...objects) {
499
526
  const output = {};
500
527
  for (const obj of objects) for (const [key, value] of Object.entries(obj)) {
528
+ if (value === void 0) continue;
501
529
  const prevValue = output[key];
502
530
  output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
503
531
  }
@@ -506,7 +534,7 @@ function deepMerge(...objects) {
506
534
  function makeTheme(...themes) {
507
535
  return deepMerge(...[getDefaultTheme(), ...themes.filter((theme) => theme != null)]);
508
536
  }
509
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-prefix.js
537
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/use-prefix.js
510
538
  function usePrefix({ status = "idle", theme }) {
511
539
  const [showLoader, setShowLoader] = useState(false);
512
540
  const [tick, setTick] = useState(0);
@@ -531,11 +559,11 @@ function usePrefix({ status = "idle", theme }) {
531
559
  if (showLoader) return spinner.frames[tick];
532
560
  return typeof prefix === "string" ? prefix : prefix[status === "loading" ? "idle" : status] ?? prefix["idle"];
533
561
  }
534
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-ref.js
562
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/use-ref.js
535
563
  function useRef(val) {
536
564
  return useState({ current: val })[0];
537
565
  }
538
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-keypress.js
566
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/use-keypress.js
539
567
  function useKeypress(userHandler) {
540
568
  const signal = useRef(userHandler);
541
569
  signal.current = userHandler;
@@ -552,14 +580,14 @@ function useKeypress(userHandler) {
552
580
  };
553
581
  }, []);
554
582
  }
555
- // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
556
- var import_cli_width = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
583
+ // ../../node_modules/.pnpm/cli-width@4.1.0/node_modules/cli-width/index.js
584
+ var require_cli_width = /* @__PURE__ */ __commonJSMin(((exports, module) => {
557
585
  module.exports = cliWidth;
558
586
  function normalizeOpts(options) {
559
587
  const defaultOpts = {
560
588
  defaultWidth: 0,
561
589
  output: process.stdout,
562
- tty: __require("tty")
590
+ tty: (/* @__PURE__ */ __require())("tty")
563
591
  };
564
592
  if (!options) return defaultOpts;
565
593
  Object.keys(defaultOpts).forEach(function(key) {
@@ -578,7 +606,8 @@ var import_cli_width = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((
578
606
  }
579
607
  return opts.defaultWidth;
580
608
  }
581
- })))(), 1);
609
+ }));
610
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
582
611
  const getCodePointsLength = (() => {
583
612
  const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
584
613
  return (input) => {
@@ -693,6 +722,7 @@ const fastStringWidth = (input, options = {}) => {
693
722
  return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
694
723
  };
695
724
  // ../../node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
725
+ var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
696
726
  const ESC$1 = "\x1B";
697
727
  const CSI = "›";
698
728
  const END_CODE = 39;
@@ -856,7 +886,7 @@ const CRLF_OR_LF = /\r?\n/;
856
886
  function wrapAnsi(string, columns, options) {
857
887
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
858
888
  }
859
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/utils.js
889
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/utils.js
860
890
  /**
861
891
  * Force line returns at specific width. This function is ANSI code friendly and it'll
862
892
  * ignore invisible codes during width calculation.
@@ -865,10 +895,19 @@ function wrapAnsi(string, columns, options) {
865
895
  * @return {string}
866
896
  */
867
897
  function breakLines(content, width) {
868
- return content.split("\n").flatMap((line) => wrapAnsi(line, width, {
898
+ return wrapContent(content, width).text;
899
+ }
900
+ function wrapContent(content, width) {
901
+ const wrappedLines = content.split("\n").map((line) => wrapAnsi(line, width, {
869
902
  trim: false,
870
903
  wordWrap: false
871
- }).split("\n").map((str) => str.trimEnd())).join("\n");
904
+ }).split("\n"));
905
+ const finalLine = wrappedLines.at(-1) ?? [];
906
+ return {
907
+ text: wrappedLines.flat().map((line) => line.trimEnd()).join("\n"),
908
+ lastRow: finalLine.at(-1) ?? "",
909
+ finalLineRows: finalLine.length
910
+ };
872
911
  }
873
912
  /**
874
913
  * Returns the width of the active readline, or 80 as default value.
@@ -880,7 +919,7 @@ function readlineWidth() {
880
919
  output: readline$1().output
881
920
  });
882
921
  }
883
- // ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@26.6.6/node_modules/@inquirer/type/dist/utils.js
922
+ // ../../node_modules/.pnpm/@inquirer+type@4.3.1_@types+node@26.6.10/node_modules/@inquirer/type/dist/utils.js
884
923
  /**
885
924
  * Create a promise and get access to its `resolve` and `reject` functions.
886
925
  *
@@ -901,7 +940,7 @@ function withResolver() {
901
940
  }
902
941
  // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
903
942
  var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
904
- const Stream = __require("stream");
943
+ const Stream = (/* @__PURE__ */ __require())("stream");
905
944
  var MuteStream = class extends Stream {
906
945
  #isTTY = null;
907
946
  constructor(opts = {}) {
@@ -1192,7 +1231,7 @@ var SignalExit = class extends SignalExitBase {
1192
1231
  };
1193
1232
  const process$1 = globalThis.process;
1194
1233
  const { onExit, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
1195
- // ../../node_modules/.pnpm/@inquirer+ansi@2.0.10/node_modules/@inquirer/ansi/dist/index.js
1234
+ // ../../node_modules/.pnpm/@inquirer+ansi@2.1.1/node_modules/@inquirer/ansi/dist/index.js
1196
1235
  const ESC = "\x1B[";
1197
1236
  /** Hide the cursor */
1198
1237
  const cursorHide = "\x1B[?25l";
@@ -1210,7 +1249,7 @@ const cursorTo = (x, y) => {
1210
1249
  const eraseLine = "\x1B[2K";
1211
1250
  /** Erase the specified number of lines above the cursor */
1212
1251
  const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
1213
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/screen-manager.js
1252
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/screen-manager.js
1214
1253
  const height = (content) => content.split("\n").length;
1215
1254
  const lastLine = (content) => content.split("\n").pop() ?? "";
1216
1255
  var ScreenManager = class {
@@ -1235,11 +1274,13 @@ var ScreenManager = class {
1235
1274
  this.rl.setPrompt(prompt);
1236
1275
  this.cursorPos = this.rl.getCursorPos();
1237
1276
  const width = readlineWidth();
1238
- content = breakLines(content, width);
1277
+ const wrapped = wrapContent(content, width);
1278
+ content = wrapped.text;
1239
1279
  bottomContent = breakLines(bottomContent, width);
1240
- if (rawPromptLine.length % width === 0) content += "\n";
1280
+ const atRightEdge = fastStringWidth(stripVTControlCharacters(wrapped.lastRow)) >= width;
1281
+ if (atRightEdge || rawPromptLine.length === 0) content += "\n";
1241
1282
  let output = content + (bottomContent ? "\n" + bottomContent : "");
1242
- const bottomContentHeight = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows + (bottomContent ? height(bottomContent) : 0);
1283
+ const bottomContentHeight = wrapped.finalLineRows - 1 + Number(atRightEdge) - this.cursorPos.rows + (bottomContent ? height(bottomContent) : 0);
1243
1284
  if (bottomContentHeight > 0) output += cursorUp(bottomContentHeight);
1244
1285
  output += cursorTo(this.cursorPos.cols);
1245
1286
  /**
@@ -1266,7 +1307,7 @@ var ScreenManager = class {
1266
1307
  this.rl.close();
1267
1308
  }
1268
1309
  };
1269
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/create-prompt.js
1310
+ // ../../node_modules/.pnpm/@inquirer+core@12.1.1_@types+node@26.6.10/node_modules/@inquirer/core/dist/lib/create-prompt.js
1270
1311
  const nativeSetImmediate = globalThis.setImmediate;
1271
1312
  const nativeClearImmediate = globalThis.clearImmediate;
1272
1313
  /**
@@ -1341,7 +1382,9 @@ function createPrompt(view) {
1341
1382
  rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code} ${signal}`));
1342
1383
  }));
1343
1384
  cleanups.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
1344
- cleanups.add(listenTo(rl, "close", clearEffects));
1385
+ const isTTY = "isTTY" in input && input.isTTY;
1386
+ const onReadlineClose = isTTY ? () => rejectPrompt(new ExitPromptError("User force closed the prompt with EOF")) : clearEffects;
1387
+ cleanups.add(listenTo(rl, "close", onReadlineClose));
1345
1388
  const startCycle = () => {
1346
1389
  cleanups.add(listenTo(rl.input, "keypress", () => screen.checkCursorPos()));
1347
1390
  let pendingDone = null;
@@ -1371,7 +1414,7 @@ function createPrompt(view) {
1371
1414
  }
1372
1415
  });
1373
1416
  };
1374
- if ("readableFlowing" in input && input.isTTY) {
1417
+ if ("readableFlowing" in input && isTTY) {
1375
1418
  const immediate = nativeSetImmediate(startCycle);
1376
1419
  cleanups.add(() => nativeClearImmediate(immediate));
1377
1420
  } else startCycle();
@@ -1382,4 +1425,4 @@ function createPrompt(view) {
1382
1425
  }
1383
1426
  export { isEnterKey as _, readlineWidth as a, isTabKey as b, usePrefix as c, useEffect as d, useState as f, isDownKey as g, isBackspaceKey as h, breakLines as i, makeTheme as l, ValidationError as m, cursorHide as n, useKeypress as o, withPointer as p, onExit as r, useRef as s, createPrompt as t, figures as u, isNumberKey as v, isUpKey as x, isSpaceKey as y };
1384
1427
 
1385
- //# sourceMappingURL=create-prompt-m0MC0vT_.js.map
1428
+ //# sourceMappingURL=create-prompt-C3XKo-s3.js.map