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