@learnosity/lib-qti-converter 0.16.0 → 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 (41) hide show
  1. package/package.json +10 -10
  2. package/packages/cli/dist/{batchProcessors-C7czhqX0.js → batchProcessors-BGdELwug.js} +75 -102
  3. package/packages/cli/dist/batchProcessors-BGdELwug.js.map +1 -0
  4. package/packages/cli/dist/batchWorker.js +2 -3
  5. package/packages/cli/dist/{configOutput-FwkFyQmk.js → configOutput-DYPwNQf7.js} +5 -9
  6. package/packages/cli/dist/{configOutput-FwkFyQmk.js.map → configOutput-DYPwNQf7.js.map} +1 -1
  7. package/packages/cli/dist/{create-prompt-dWckcotJ.js → create-prompt-C3XKo-s3.js} +95 -71
  8. package/packages/cli/dist/create-prompt-C3XKo-s3.js.map +1 -0
  9. package/packages/cli/dist/{dist-DXDR2peT.js → dist-D7b9-VIt.js} +8 -11
  10. package/packages/cli/dist/dist-D7b9-VIt.js.map +1 -0
  11. package/packages/cli/dist/{learnosityToQti-D4ddrXaz.js → learnosityToQti-CN6KKSmF.js} +5 -6
  12. package/packages/cli/dist/{learnosityToQti-D4ddrXaz.js.map → learnosityToQti-CN6KKSmF.js.map} +1 -1
  13. package/packages/cli/dist/{learnosityToQtiPackage-Bwzm-uLX.js → learnosityToQtiPackage-CMOQRiCV.js} +29 -21
  14. package/packages/cli/dist/learnosityToQtiPackage-CMOQRiCV.js.map +1 -0
  15. package/packages/cli/dist/main.js +22 -29
  16. package/packages/cli/dist/main.js.map +1 -1
  17. package/packages/cli/dist/{nodeFileAccess-BhCoGDOi.js → nodeFileAccess-_jRCd340.js} +6 -10
  18. package/packages/cli/dist/{nodeFileAccess-BhCoGDOi.js.map → nodeFileAccess-_jRCd340.js.map} +1 -1
  19. package/packages/cli/dist/pathUtils-I2bRHUwu.js +2922 -0
  20. package/packages/cli/dist/pathUtils-I2bRHUwu.js.map +1 -0
  21. package/packages/cli/dist/{qtiPackageToLearnosity-CX9htPId.js → qtiPackageToLearnosity-JRb3TTyC.js} +7 -8
  22. package/packages/cli/dist/{qtiPackageToLearnosity-CX9htPId.js.map → qtiPackageToLearnosity-JRb3TTyC.js.map} +1 -1
  23. package/packages/cli/dist/{qtiToLearnosity-JQYOkNbM.js → qtiToLearnosity-C-jQYKqR.js} +6 -7
  24. package/packages/cli/dist/{qtiToLearnosity-JQYOkNbM.js.map → qtiToLearnosity-C-jQYKqR.js.map} +1 -1
  25. package/packages/cli/dist/{resolveOptions-BuNN2KMA.js → resolveOptions-ikupjaRQ.js} +322 -359
  26. package/packages/cli/dist/resolveOptions-ikupjaRQ.js.map +1 -0
  27. package/packages/cli/dist/{rolldown-runtime-DktXgydw.js → rolldown-runtime-BuRBZLzk.js} +13 -12
  28. package/packages/cli/dist/{table-DsKq-B4-.js → table-6SiZD7aK.js} +9944 -2294
  29. package/packages/cli/dist/table-6SiZD7aK.js.map +1 -0
  30. package/packages/core/dist/index.d.ts +8 -58
  31. package/packages/core/dist/index.js +9923 -2267
  32. package/packages/core/dist/node.d.ts +10 -80
  33. package/packages/core/dist/node.js +9951 -2311
  34. package/packages/cli/dist/batchProcessors-C7czhqX0.js.map +0 -1
  35. package/packages/cli/dist/create-prompt-dWckcotJ.js.map +0 -1
  36. package/packages/cli/dist/dist-DXDR2peT.js.map +0 -1
  37. package/packages/cli/dist/learnosityToQtiPackage-Bwzm-uLX.js.map +0 -1
  38. package/packages/cli/dist/pathUtils-D_VsVde8.js +0 -2272
  39. package/packages/cli/dist/pathUtils-D_VsVde8.js.map +0 -1
  40. package/packages/cli/dist/resolveOptions-BuNN2KMA.js.map +0 -1
  41. package/packages/cli/dist/table-DsKq-B4-.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { r as runBatchTask } from "./batchProcessors-C7czhqX0.js";
2
1
  import { parentPort } from "node:worker_threads";
3
- //#region src/batchWorker.ts
2
+ import { r as runBatchTask } from "./batchProcessors-BGdELwug.js";
3
+ // src/batchWorker.ts
4
4
  /**
5
5
  * Worker-thread entry for parallel batch conversion. Receives one package task
6
6
  * at a time and posts back the per-package result. All conversion CPU work runs
@@ -20,7 +20,6 @@ if (parentPort) {
20
20
  });
21
21
  });
22
22
  }
23
- //#endregion
24
23
  export {};
25
24
 
26
25
  //# sourceMappingURL=batchWorker.js.map
@@ -1,7 +1,7 @@
1
1
  import { basename, join, resolve, sep } from "path";
2
2
  import { existsSync, readdirSync, statSync } from "fs";
3
3
  import { Worker } from "node:worker_threads";
4
- //#region src/utils/packageScanner.ts
4
+ // src/utils/packageScanner.ts
5
5
  /**
6
6
  * Package scanning utilities for detecting QTI and Learnosity packages
7
7
  */
@@ -75,8 +75,7 @@ function scanForPackages(parentDir, expectedType) {
75
75
  scanRecursive(parentDir, "");
76
76
  return packages;
77
77
  }
78
- //#endregion
79
- //#region src/utils/workerPool.ts
78
+ // src/utils/workerPool.ts
80
79
  /**
81
80
  * Minimal reusable worker_threads pool.
82
81
  *
@@ -146,8 +145,7 @@ function runPool(options) {
146
145
  for (let i = 0; i < poolSize; i++) spawn();
147
146
  });
148
147
  }
149
- //#endregion
150
- //#region src/utils/batchProcessing.ts
148
+ // src/utils/batchProcessing.ts
151
149
  /**
152
150
  * Batch processing utilities for recursive directory conversion
153
151
  */
@@ -367,8 +365,7 @@ async function processBatchParallel(config) {
367
365
  if (summary.failed > 0 && summary.succeeded === 0) process.exit(1);
368
366
  return summary;
369
367
  }
370
- //#endregion
371
- //#region src/utils/configOutput.ts
368
+ // src/utils/configOutput.ts
372
369
  /**
373
370
  * Display a configuration block with consistent formatting
374
371
  */
@@ -393,7 +390,6 @@ function configField(label, value, indent = 0) {
393
390
  indent
394
391
  };
395
392
  }
396
- //#endregion
397
393
  export { processBatchParallel as i, displayConfiguration as n, processBatch as r, configField as t };
398
394
 
399
- //# sourceMappingURL=configOutput-FwkFyQmk.js.map
395
+ //# sourceMappingURL=configOutput-DYPwNQf7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configOutput-FwkFyQmk.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,SAAS,QAAQ,CAAC,CAAC,YAAY,GAChC;GAER,QAAQ;IAEJ;GACJ;GAGA,MAAM,OAAO,kBAAkB,QAAQ;G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AM,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,WAAW,SAAS,GACrB,OAAO;CAKX,IAAI,CAFS,SAAS,SAEd,CAAC,CAAC,YAAY,GAClB,OAAO;;;;;;;CAS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,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-DktXgydw.js";
1
+ import { i as __toESM, t as __commonJSMin } from "./rolldown-runtime-BuRBZLzk.js";
2
2
  import path from "node:path";
3
- import process$1 from "node:process";
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
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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,8 +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
- //#endregion
25
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
26
31
  var AbortPromptError = class extends Error {
27
32
  name = "AbortPromptError";
28
33
  message = "Prompt was aborted";
@@ -44,8 +49,8 @@ var HookError = class extends Error {
44
49
  var ValidationError = class extends Error {
45
50
  name = "ValidationError";
46
51
  };
47
- //#endregion
48
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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;
49
54
  const hookStorage = new AsyncLocalStorage();
50
55
  function createStore(rl) {
51
56
  return {
@@ -54,7 +59,8 @@ function createStore(rl) {
54
59
  hooksCleanup: [],
55
60
  hooksEffect: [],
56
61
  index: 0,
57
- handleChange() {}
62
+ handleChange() {},
63
+ deferredPaint: null
58
64
  };
59
65
  }
60
66
  function withHooks(rl, cb) {
@@ -81,16 +87,34 @@ function withUpdates(fn) {
81
87
  const store = getStore();
82
88
  let shouldUpdate = false;
83
89
  const oldHandleChange = store.handleChange;
84
- store.handleChange = () => {
90
+ const recordChange = () => {
85
91
  shouldUpdate = true;
86
92
  };
93
+ store.handleChange = recordChange;
87
94
  const returnValue = fn(...args);
88
- if (shouldUpdate) oldHandleChange();
89
- 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;
90
104
  return returnValue;
91
105
  };
92
106
  return AsyncResource.bind(wrapped);
93
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
+ }
94
118
  function withPointer(cb) {
95
119
  const store = getStore();
96
120
  const { index } = store;
@@ -136,10 +160,10 @@ const effectScheduler = {
136
160
  });
137
161
  store.hooksEffect.length = 0;
138
162
  store.hooksCleanup.length = 0;
163
+ store.deferredPaint = null;
139
164
  }
140
165
  };
141
- //#endregion
142
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
143
167
  function isFactory(value) {
144
168
  return typeof value === "function";
145
169
  }
@@ -162,8 +186,7 @@ function useState(defaultValue) {
162
186
  return [value, setState];
163
187
  });
164
188
  }
165
- //#endregion
166
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
167
190
  function useEffect(cb, depArray) {
168
191
  withPointer((pointer) => {
169
192
  const oldDeps = pointer.get();
@@ -171,11 +194,10 @@ function useEffect(cb, depArray) {
171
194
  pointer.set(depArray);
172
195
  });
173
196
  }
174
- //#endregion
175
- //#region ../../node_modules/.pnpm/@inquirer+figures@2.0.9/node_modules/@inquirer/figures/dist/index.js
197
+ // ../../node_modules/.pnpm/@inquirer+figures@2.1.1/node_modules/@inquirer/figures/dist/index.js
176
198
  function isUnicodeSupported() {
177
- if (!process$1.platform.startsWith("win")) return process$1.env["TERM"] !== "linux";
178
- return 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";
199
+ if (!process$2.platform.startsWith("win")) return process$2.env["TERM"] !== "linux";
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";
179
201
  }
180
202
  const common = {
181
203
  circleQuestionMark: "(?)",
@@ -455,8 +477,7 @@ const fallbackSymbols = {
455
477
  };
456
478
  const figures = isUnicodeSupported() ? mainSymbols : fallbackSymbols;
457
479
  Object.entries(specialMainSymbols);
458
- //#endregion
459
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
460
481
  const defaultTheme = {
461
482
  prefix: {
462
483
  idle: styleText("blue", "?"),
@@ -494,8 +515,7 @@ function getDefaultTheme() {
494
515
  keybindings: getDefaultKeybindings()
495
516
  };
496
517
  }
497
- //#endregion
498
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
499
519
  function isPlainObject(value) {
500
520
  if (typeof value !== "object" || value === null) return false;
501
521
  let proto = value;
@@ -505,6 +525,7 @@ function isPlainObject(value) {
505
525
  function deepMerge(...objects) {
506
526
  const output = {};
507
527
  for (const obj of objects) for (const [key, value] of Object.entries(obj)) {
528
+ if (value === void 0) continue;
508
529
  const prevValue = output[key];
509
530
  output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
510
531
  }
@@ -513,8 +534,7 @@ function deepMerge(...objects) {
513
534
  function makeTheme(...themes) {
514
535
  return deepMerge(...[getDefaultTheme(), ...themes.filter((theme) => theme != null)]);
515
536
  }
516
- //#endregion
517
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
518
538
  function usePrefix({ status = "idle", theme }) {
519
539
  const [showLoader, setShowLoader] = useState(false);
520
540
  const [tick, setTick] = useState(0);
@@ -539,13 +559,11 @@ function usePrefix({ status = "idle", theme }) {
539
559
  if (showLoader) return spinner.frames[tick];
540
560
  return typeof prefix === "string" ? prefix : prefix[status === "loading" ? "idle" : status] ?? prefix["idle"];
541
561
  }
542
- //#endregion
543
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
544
563
  function useRef(val) {
545
564
  return useState({ current: val })[0];
546
565
  }
547
- //#endregion
548
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
549
567
  function useKeypress(userHandler) {
550
568
  const signal = useRef(userHandler);
551
569
  signal.current = userHandler;
@@ -562,15 +580,14 @@ function useKeypress(userHandler) {
562
580
  };
563
581
  }, []);
564
582
  }
565
- //#endregion
566
- //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
567
- 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) => {
568
585
  module.exports = cliWidth;
569
586
  function normalizeOpts(options) {
570
587
  const defaultOpts = {
571
588
  defaultWidth: 0,
572
589
  output: process.stdout,
573
- tty: __require("tty")
590
+ tty: (/* @__PURE__ */ __require())("tty")
574
591
  };
575
592
  if (!options) return defaultOpts;
576
593
  Object.keys(defaultOpts).forEach(function(key) {
@@ -589,7 +606,8 @@ var import_cli_width = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((
589
606
  }
590
607
  return opts.defaultWidth;
591
608
  }
592
- })))(), 1);
609
+ }));
610
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
593
611
  const getCodePointsLength = (() => {
594
612
  const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
595
613
  return (input) => {
@@ -605,8 +623,7 @@ const isFullWidth = (x) => {
605
623
  const isWideNotCJKTNotEmoji = (x) => {
606
624
  return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
607
625
  };
608
- //#endregion
609
- //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
626
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
610
627
  const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
611
628
  const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
612
629
  const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
@@ -615,11 +632,11 @@ const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{
615
632
  const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
616
633
  const MODIFIER_RE = /\p{M}+/gu;
617
634
  const NO_TRUNCATION$1 = {
618
- limit: Infinity,
635
+ limit: 1e400,
619
636
  ellipsis: ""
620
637
  };
621
638
  const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
622
- const LIMIT = truncationOptions.limit ?? Infinity;
639
+ const LIMIT = truncationOptions.limit ?? 1e400;
623
640
  const ELLIPSIS = truncationOptions.ellipsis ?? "";
624
641
  const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
625
642
  const ANSI_WIDTH = 0;
@@ -695,18 +712,17 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
695
712
  ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
696
713
  };
697
714
  };
698
- //#endregion
699
- //#region ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
715
+ // ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
700
716
  const NO_TRUNCATION = {
701
- limit: Infinity,
717
+ limit: 1e400,
702
718
  ellipsis: "",
703
719
  ellipsisWidth: 0
704
720
  };
705
721
  const fastStringWidth = (input, options = {}) => {
706
722
  return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
707
723
  };
708
- //#endregion
709
- //#region ../../node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
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);
710
726
  const ESC$1 = "\x1B";
711
727
  const CSI = "›";
712
728
  const END_CODE = 39;
@@ -870,8 +886,7 @@ const CRLF_OR_LF = /\r?\n/;
870
886
  function wrapAnsi(string, columns, options) {
871
887
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
872
888
  }
873
- //#endregion
874
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
875
890
  /**
876
891
  * Force line returns at specific width. This function is ANSI code friendly and it'll
877
892
  * ignore invisible codes during width calculation.
@@ -880,10 +895,19 @@ function wrapAnsi(string, columns, options) {
880
895
  * @return {string}
881
896
  */
882
897
  function breakLines(content, width) {
883
- 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, {
884
902
  trim: false,
885
903
  wordWrap: false
886
- }).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
+ };
887
911
  }
888
912
  /**
889
913
  * Returns the width of the active readline, or 80 as default value.
@@ -895,8 +919,7 @@ function readlineWidth() {
895
919
  output: readline$1().output
896
920
  });
897
921
  }
898
- //#endregion
899
- //#region ../../node_modules/.pnpm/@inquirer+type@4.2.0_@types+node@26.6.5/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
900
923
  /**
901
924
  * Create a promise and get access to its `resolve` and `reject` functions.
902
925
  *
@@ -915,10 +938,9 @@ function withResolver() {
915
938
  reject
916
939
  };
917
940
  }
918
- //#endregion
919
- //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
941
+ // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
920
942
  var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
921
- const Stream = __require("stream");
943
+ const Stream = (/* @__PURE__ */ __require())("stream");
922
944
  var MuteStream = class extends Stream {
923
945
  #isTTY = null;
924
946
  constructor(opts = {}) {
@@ -1043,8 +1065,7 @@ const signals = [];
1043
1065
  signals.push("SIGHUP", "SIGINT", "SIGTERM");
1044
1066
  if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
1045
1067
  if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
1046
- //#endregion
1047
- //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
1068
+ // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
1048
1069
  const processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
1049
1070
  const kExitEmitter = Symbol.for("signal-exit emitter");
1050
1071
  const global = globalThis;
@@ -1113,7 +1134,7 @@ var SignalExitFallback = class extends SignalExitBase {
1113
1134
  };
1114
1135
  var SignalExit = class extends SignalExitBase {
1115
1136
  /* c8 ignore start */
1116
- #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
1137
+ #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
1117
1138
  /* c8 ignore stop */
1118
1139
  #emitter = new Emitter();
1119
1140
  #process;
@@ -1208,10 +1229,9 @@ var SignalExit = class extends SignalExitBase {
1208
1229
  } else return og.call(this.#process, ev, ...args);
1209
1230
  }
1210
1231
  };
1211
- const process$2 = globalThis.process;
1212
- const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
1213
- //#endregion
1214
- //#region ../../node_modules/.pnpm/@inquirer+ansi@2.0.9/node_modules/@inquirer/ansi/dist/index.js
1232
+ const process$1 = globalThis.process;
1233
+ const { onExit, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
1234
+ // ../../node_modules/.pnpm/@inquirer+ansi@2.1.1/node_modules/@inquirer/ansi/dist/index.js
1215
1235
  const ESC = "\x1B[";
1216
1236
  /** Hide the cursor */
1217
1237
  const cursorHide = "\x1B[?25l";
@@ -1229,8 +1249,7 @@ const cursorTo = (x, y) => {
1229
1249
  const eraseLine = "\x1B[2K";
1230
1250
  /** Erase the specified number of lines above the cursor */
1231
1251
  const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
1232
- //#endregion
1233
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
1234
1253
  const height = (content) => content.split("\n").length;
1235
1254
  const lastLine = (content) => content.split("\n").pop() ?? "";
1236
1255
  var ScreenManager = class {
@@ -1255,11 +1274,13 @@ var ScreenManager = class {
1255
1274
  this.rl.setPrompt(prompt);
1256
1275
  this.cursorPos = this.rl.getCursorPos();
1257
1276
  const width = readlineWidth();
1258
- content = breakLines(content, width);
1277
+ const wrapped = wrapContent(content, width);
1278
+ content = wrapped.text;
1259
1279
  bottomContent = breakLines(bottomContent, width);
1260
- if (rawPromptLine.length % width === 0) content += "\n";
1280
+ const atRightEdge = fastStringWidth(stripVTControlCharacters(wrapped.lastRow)) >= width;
1281
+ if (atRightEdge || rawPromptLine.length === 0) content += "\n";
1261
1282
  let output = content + (bottomContent ? "\n" + bottomContent : "");
1262
- 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);
1263
1284
  if (bottomContentHeight > 0) output += cursorUp(bottomContentHeight);
1264
1285
  output += cursorTo(this.cursorPos.cols);
1265
1286
  /**
@@ -1286,9 +1307,9 @@ var ScreenManager = class {
1286
1307
  this.rl.close();
1287
1308
  }
1288
1309
  };
1289
- //#endregion
1290
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/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
1291
1311
  const nativeSetImmediate = globalThis.setImmediate;
1312
+ const nativeClearImmediate = globalThis.clearImmediate;
1292
1313
  /**
1293
1314
  * Register an event listener and return its disposer, so registrations collapse
1294
1315
  * into a single statement: `cleanups.add(listenTo(rl, 'close', handler))`.
@@ -1361,7 +1382,9 @@ function createPrompt(view) {
1361
1382
  rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code} ${signal}`));
1362
1383
  }));
1363
1384
  cleanups.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
1364
- 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));
1365
1388
  const startCycle = () => {
1366
1389
  cleanups.add(listenTo(rl.input, "keypress", () => screen.checkCursorPos()));
1367
1390
  let pendingDone = null;
@@ -1391,14 +1414,15 @@ function createPrompt(view) {
1391
1414
  }
1392
1415
  });
1393
1416
  };
1394
- if ("readableFlowing" in input) nativeSetImmediate(startCycle);
1395
- else startCycle();
1417
+ if ("readableFlowing" in input && isTTY) {
1418
+ const immediate = nativeSetImmediate(startCycle);
1419
+ cleanups.add(() => nativeClearImmediate(immediate));
1420
+ } else startCycle();
1396
1421
  return promptPromise;
1397
1422
  });
1398
1423
  };
1399
1424
  return prompt;
1400
1425
  }
1401
- //#endregion
1402
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 };
1403
1427
 
1404
- //# sourceMappingURL=create-prompt-dWckcotJ.js.map
1428
+ //# sourceMappingURL=create-prompt-C3XKo-s3.js.map