@qodalis/cli-core 2.0.0-beta.7 → 2.0.0-beta.9

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.
package/public-api.mjs CHANGED
@@ -2006,7 +2006,7 @@ var CliIcon = /* @__PURE__ */ ((CliIcon2) => {
2006
2006
  CliIcon2["Server"] = "\u{1F5A5}";
2007
2007
  CliIcon2["Cloud"] = "\u2601";
2008
2008
  CliIcon2["Network"] = "\u{1F310}";
2009
- CliIcon2["Monitor"] = "\u{1F5A5}";
2009
+ CliIcon2["Monitor"] = "\u{1F4FA}";
2010
2010
  CliIcon2["Printer"] = "\u{1F5A8}";
2011
2011
  CliIcon2["USB"] = "\u{1F50C}";
2012
2012
  CliIcon2["Speaker"] = "\u{1F50A}";
@@ -2016,14 +2016,14 @@ var CliIcon = /* @__PURE__ */ ((CliIcon2) => {
2016
2016
  CliIcon2["Music"] = "\u{1F3B5}";
2017
2017
  CliIcon2["Phone"] = "\u{1F4DE}";
2018
2018
  CliIcon2["Package"] = "\u{1F4E6}";
2019
- CliIcon2["Plugin"] = "\u{1F50C}";
2020
- CliIcon2["Extension"] = "\u{1F9E9}";
2021
- CliIcon2["Module"] = "\u{1F4E6}";
2019
+ CliIcon2["Plugin"] = "\u{1F9E9}";
2020
+ CliIcon2["Extension"] = "\u{1F50C}";
2021
+ CliIcon2["Module"] = "\u{1F9F1}";
2022
2022
  CliIcon2["Evaluate"] = "\u{1F50D}";
2023
- CliIcon2["Variable"] = "\u{1F527}";
2023
+ CliIcon2["Variable"] = "\u{1D465}";
2024
2024
  CliIcon2["Script"] = "\u{1F4DC}";
2025
- CliIcon2["Code"] = "\u{1F4BE}";
2026
- CliIcon2["Logs"] = "\u{1F4DC}";
2025
+ CliIcon2["Code"] = "\u{1F4DD}";
2026
+ CliIcon2["Logs"] = "\u{1F4CB}";
2027
2027
  CliIcon2["Power"] = "\u23FB";
2028
2028
  CliIcon2["Heart"] = "\u2764";
2029
2029
  CliIcon2["Flame"] = "\u{1F525}";
@@ -2070,18 +2070,17 @@ var enums = {
2070
2070
  CliLogLevel
2071
2071
  };
2072
2072
 
2073
- // src/lib/interfaces/completion.ts
2073
+ // src/lib/tokens.ts
2074
+ var ICliUserSessionService_TOKEN = "cli-user-session-service";
2075
+ var ICliUsersStoreService_TOKEN = "cli-users-store-service";
2076
+ var ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
2077
+ var ICliAuthService_TOKEN = "cli-auth-service";
2074
2078
  var ICliCompletionProvider_TOKEN = "cli-completion-provider";
2075
-
2076
- // src/lib/interfaces/file-transfer.ts
2077
- var ICliFileTransferService_TOKEN = "cli-file-transfer-service";
2078
-
2079
- // src/lib/interfaces/drag-drop.ts
2080
2079
  var ICliDragDropService_TOKEN = "cli-drag-drop-service";
2081
-
2082
- // src/lib/interfaces/index.ts
2080
+ var ICliFileTransferService_TOKEN = "cli-file-transfer-service";
2083
2081
  var ICliTranslationService_TOKEN = "cli-translation-service";
2084
2082
  var ICliPermissionService_TOKEN = "cli-permission-service";
2083
+ var ICliFilePickerProvider_TOKEN = "cli-file-picker-provider";
2085
2084
 
2086
2085
  // src/lib/constants/index.ts
2087
2086
  var DefaultLibraryAuthor = {
@@ -2243,6 +2242,19 @@ function getConfigValue(state, category, key, defaultValue) {
2243
2242
  }
2244
2243
  return defaultValue;
2245
2244
  }
2245
+ function getPluginConfigValue(context, category, key, defaultValue) {
2246
+ try {
2247
+ const storeManager = context.services.get(
2248
+ "cli-state-store-manager"
2249
+ );
2250
+ if (!storeManager) return defaultValue;
2251
+ const store = storeManager.getStateStore(CLI_CONFIGURE_STORE_NAME);
2252
+ if (!store) return defaultValue;
2253
+ return getConfigValue(store, category, key, defaultValue);
2254
+ } catch {
2255
+ return defaultValue;
2256
+ }
2257
+ }
2246
2258
  function resolveConfigurationCategories(registry) {
2247
2259
  const categories = /* @__PURE__ */ new Map();
2248
2260
  for (const processor of registry.processors) {
@@ -2264,7 +2276,8 @@ function resolveConfigurationCategories(registry) {
2264
2276
 
2265
2277
  // src/lib/utils/terminal-utils.ts
2266
2278
  var clearTerminalLine = (terminal, contentLength) => {
2267
- const lines = Math.max(1, Math.ceil(contentLength / terminal.cols));
2279
+ if (contentLength <= 0) return;
2280
+ const lines = Math.ceil(contentLength / terminal.cols);
2268
2281
  for (let i = 0; i < lines; i++) {
2269
2282
  terminal.write("\x1B[2K");
2270
2283
  if (i < lines - 1) {
@@ -2295,10 +2308,15 @@ function satisfiesVersionRange(installed, range) {
2295
2308
  return semver.satisfies(coerced, range);
2296
2309
  }
2297
2310
 
2311
+ // src/lib/version.ts
2312
+ var LIBRARY_VERSION = "2.0.0-beta.9";
2313
+ var API_VERSION = 2;
2314
+
2298
2315
  // src/lib/utils/server-version-negotiator.ts
2316
+ var VERSIONS_ENDPOINT = "/api/qcli/versions";
2299
2317
  var ServerVersionNegotiator = class {
2300
2318
  static {
2301
- this.CLIENT_SUPPORTED_VERSIONS = [2];
2319
+ this.CLIENT_SUPPORTED_VERSIONS = [API_VERSION];
2302
2320
  }
2303
2321
  /**
2304
2322
  * Given a server's version info, pick the highest mutually compatible version.
@@ -2317,7 +2335,7 @@ var ServerVersionNegotiator = class {
2317
2335
  */
2318
2336
  static async discover(baseUrl) {
2319
2337
  try {
2320
- const response = await fetch(`${baseUrl}/api/qcli/versions`);
2338
+ const response = await fetch(`${baseUrl}${VERSIONS_ENDPOINT}`);
2321
2339
  if (!response.ok) return null;
2322
2340
  const info = await response.json();
2323
2341
  const version = this.negotiate(info);
@@ -2334,7 +2352,7 @@ var ServerVersionNegotiator = class {
2334
2352
 
2335
2353
  // src/lib/utils/panel-theme-sync.ts
2336
2354
  function hexToRgb(hex) {
2337
- const m = /^#?([0-9A-Fa-f]{6})$/.exec(hex);
2355
+ const m = /^#?([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/.exec(hex);
2338
2356
  if (!m) return null;
2339
2357
  const n = parseInt(m[1], 16);
2340
2358
  return { r: n >> 16 & 255, g: n >> 8 & 255, b: n & 255 };
@@ -2352,10 +2370,13 @@ function hexToRgba(hex, alpha) {
2352
2370
  if (!rgb) return hex;
2353
2371
  return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
2354
2372
  }
2373
+ var DEFAULT_BG = "#111827";
2374
+ var DEFAULT_FG = "#ffffff";
2375
+ var DEFAULT_ACCENT = "#818cf8";
2355
2376
  function derivePanelThemeStyles(theme) {
2356
- const bg = theme.background || "#111827";
2357
- const fg = theme.foreground || "#ffffff";
2358
- const accent = theme.cyan || theme.blue || theme.magenta || "#818cf8";
2377
+ const bg = theme.background || DEFAULT_BG;
2378
+ const fg = theme.foreground || DEFAULT_FG;
2379
+ const accent = theme.cyan || theme.blue || theme.magenta || DEFAULT_ACCENT;
2359
2380
  return {
2360
2381
  "--cli-panel-bg": bg,
2361
2382
  "--cli-panel-header-bg": shiftColor(bg, 12),
@@ -2389,9 +2410,21 @@ function savePanelPosition(position) {
2389
2410
  }
2390
2411
  function nextPanelPosition(current) {
2391
2412
  const index = POSITION_CYCLE.indexOf(current);
2413
+ if (index === -1) {
2414
+ return POSITION_CYCLE[0];
2415
+ }
2392
2416
  return POSITION_CYCLE[(index + 1) % POSITION_CYCLE.length];
2393
2417
  }
2394
2418
 
2419
+ // src/lib/utils/ansi-utils.ts
2420
+ var ANSI_RE = /\x1b\[[0-9;]*m/g;
2421
+ function stripAnsi(text) {
2422
+ return text.replace(ANSI_RE, "");
2423
+ }
2424
+ function visibleLength(text) {
2425
+ return stripAnsi(text).length;
2426
+ }
2427
+
2395
2428
  // src/lib/utils/index.ts
2396
2429
  var getParameterValue = (p, args) => {
2397
2430
  if (args[p.name] !== void 0) {
@@ -2409,14 +2442,11 @@ var colorizeJson = (jsonString) => {
2409
2442
  };
2410
2443
  var toQueryString = (params) => {
2411
2444
  const searchParams = new URLSearchParams();
2412
- for (const key in params) {
2413
- if (params.hasOwnProperty(key)) {
2414
- const value = params[key];
2415
- if (Array.isArray(value)) {
2416
- value.forEach((v) => searchParams.append(key, v.toString()));
2417
- } else if (value !== null && value !== void 0) {
2418
- searchParams.append(key, value.toString());
2419
- }
2445
+ for (const [key, value] of Object.entries(params)) {
2446
+ if (Array.isArray(value)) {
2447
+ value.forEach((v) => searchParams.append(key, v.toString()));
2448
+ } else if (value !== null && value !== void 0) {
2449
+ searchParams.append(key, value.toString());
2420
2450
  }
2421
2451
  }
2422
2452
  return searchParams.toString();
@@ -2453,14 +2483,11 @@ var utils = {
2453
2483
  ObjectDescriber,
2454
2484
  delay,
2455
2485
  getConfigValue,
2486
+ getPluginConfigValue,
2456
2487
  resolveConfigurationCategories,
2457
2488
  CLI_CONFIGURE_STORE_NAME
2458
2489
  };
2459
2490
 
2460
- // src/lib/version.ts
2461
- var LIBRARY_VERSION = "2.0.0-beta.7";
2462
- var API_VERSION = 2;
2463
-
2464
2491
  // src/lib/modules/cli-module-registry.ts
2465
2492
  var CliModuleRegistry = class {
2466
2493
  constructor() {
@@ -2475,19 +2502,31 @@ var CliModuleRegistry = class {
2475
2502
  }
2476
2503
  /**
2477
2504
  * Register a module and notify all boot handlers.
2478
- * Modules that do not meet the required API version are silently skipped.
2505
+ * Modules that do not meet the required API version are skipped with a warning.
2479
2506
  */
2480
2507
  async register(module) {
2481
2508
  const modApiVersion = module.apiVersion;
2482
2509
  if (typeof modApiVersion !== "number" || modApiVersion < API_VERSION) {
2483
- console.warn(
2484
- `[CLI] Plugin "${module.name}" targets API version ${modApiVersion ?? "unknown"}, but this runtime requires API version ${API_VERSION}. Skipping.`
2485
- );
2510
+ const msg = `[CLI] Plugin "${module.name}" targets API version ${modApiVersion ?? "unknown"}, but this runtime requires API version ${API_VERSION}. Skipping.`;
2511
+ if (this.onWarn) {
2512
+ this.onWarn(msg);
2513
+ } else {
2514
+ console.warn(msg);
2515
+ }
2486
2516
  return;
2487
2517
  }
2488
2518
  this.modules.set(module.name, module);
2489
2519
  for (const handler of this.bootHandlers) {
2490
- await handler(module);
2520
+ try {
2521
+ await handler(module);
2522
+ } catch (e) {
2523
+ const msg = `[CLI] Boot handler failed for module "${module.name}": ${e instanceof Error ? e.message : e}`;
2524
+ if (this.onWarn) {
2525
+ this.onWarn(msg);
2526
+ } else {
2527
+ console.warn(msg);
2528
+ }
2529
+ }
2491
2530
  }
2492
2531
  }
2493
2532
  /**
@@ -2552,16 +2591,21 @@ var bootUmdModule = async (module) => {
2552
2591
  };
2553
2592
 
2554
2593
  // src/lib/types/CancellablePromise.ts
2594
+ var CANCELLATION_ERROR_MESSAGE = "Promise cancelled";
2555
2595
  var CancellablePromise = class {
2556
2596
  constructor(executor) {
2557
2597
  this.executor = executor;
2558
2598
  this.hasCancelled = false;
2559
2599
  this.abortController = new AbortController();
2560
2600
  }
2601
+ /**
2602
+ * Run the executor and return a promise for its result.
2603
+ * If `cancel()` has been called, the promise rejects immediately.
2604
+ */
2561
2605
  execute() {
2562
2606
  return new Promise((resolve, reject) => {
2563
2607
  this.abortController.signal.onabort = () => {
2564
- reject(new Error("Promise cancelled"));
2608
+ reject(new Error(CANCELLATION_ERROR_MESSAGE));
2565
2609
  };
2566
2610
  this.executor(
2567
2611
  (value) => {
@@ -2577,6 +2621,10 @@ var CancellablePromise = class {
2577
2621
  );
2578
2622
  });
2579
2623
  }
2624
+ /**
2625
+ * Cancel the promise. The executing promise rejects with
2626
+ * `Error('Promise cancelled')` and subsequent resolve/reject calls are ignored.
2627
+ */
2580
2628
  cancel() {
2581
2629
  this.hasCancelled = true;
2582
2630
  this.abortController.abort();
@@ -3396,12 +3444,6 @@ var DefaultThemeInfos = {
3396
3444
  }
3397
3445
  };
3398
3446
 
3399
- // src/lib/tokens.ts
3400
- var ICliUserSessionService_TOKEN = "cli-user-session-service";
3401
- var ICliUsersStoreService_TOKEN = "cli-users-store-service";
3402
- var ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
3403
- var ICliAuthService_TOKEN = "cli-auth-service";
3404
-
3405
3447
  // src/lib/worker/create-worker-service.ts
3406
3448
  function createWorkerService(handlers) {
3407
3449
  const abortController = new AbortController();
@@ -3494,9 +3536,17 @@ var BrowserFileTransferService = class {
3494
3536
  const filename = path.split("/").pop() || "download";
3495
3537
  this.downloadToBrowser(filename, content);
3496
3538
  }
3539
+ /**
3540
+ * Not supported in browser — always returns an empty array.
3541
+ * Use `@qodalis/cli-files` for directory listing.
3542
+ */
3497
3543
  async listFiles(_path) {
3498
3544
  return [];
3499
3545
  }
3546
+ /**
3547
+ * Not supported in browser — always returns `false`.
3548
+ * Use `@qodalis/cli-files` for file existence checks.
3549
+ */
3500
3550
  async exists(_path) {
3501
3551
  return false;
3502
3552
  }
@@ -3540,6 +3590,6 @@ var BrowserFileTransferService = class {
3540
3590
  }
3541
3591
  };
3542
3592
 
3543
- export { API_VERSION, BrowserFileTransferService, CLI_CONFIGURE_STORE_NAME, CancellablePromise, CliBackgroundColor, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, ICliAuthService_TOKEN, ICliCompletionProvider_TOKEN, ICliDragDropService_TOKEN, ICliFileTransferService_TOKEN, ICliGroupsStoreService_TOKEN, ICliPermissionService_TOKEN, ICliTranslationService_TOKEN, ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, ServerVersionNegotiator, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, toQueryString, utils };
3593
+ export { API_VERSION, BrowserFileTransferService, CANCELLATION_ERROR_MESSAGE, CLI_CONFIGURE_STORE_NAME, CancellablePromise, CliBackgroundColor, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, ICliAuthService_TOKEN, ICliCompletionProvider_TOKEN, ICliDragDropService_TOKEN, ICliFilePickerProvider_TOKEN, ICliFileTransferService_TOKEN, ICliGroupsStoreService_TOKEN, ICliPermissionService_TOKEN, ICliTranslationService_TOKEN, ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, ServerVersionNegotiator, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getPluginConfigValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, stripAnsi, toQueryString, utils, visibleLength };
3544
3594
  //# sourceMappingURL=public-api.mjs.map
3545
3595
  //# sourceMappingURL=public-api.mjs.map