poe-code 5.0.3 → 5.0.4

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/dist/index.js CHANGED
@@ -10952,6 +10952,14 @@ function computeExplorerLayout(opts) {
10952
10952
  footer
10953
10953
  };
10954
10954
  }
10955
+ function paneBodyRect(rect) {
10956
+ return {
10957
+ x: rect.x + 2,
10958
+ y: rect.y + 1,
10959
+ width: Math.max(0, rect.width - 4),
10960
+ height: Math.max(0, rect.height - 2)
10961
+ };
10962
+ }
10955
10963
  function resolveMode(cols, rows) {
10956
10964
  if (cols < 60 || rows < 8) {
10957
10965
  return "too-narrow";
@@ -11302,6 +11310,43 @@ var init_ansi_text = __esm({
11302
11310
  }
11303
11311
  });
11304
11312
 
11313
+ // packages/toolcraft-design/src/explorer/detail-content.ts
11314
+ function prepareDetailContent(content, width) {
11315
+ if (content.trim().length === 0) {
11316
+ return { text: "", lines: [[]] };
11317
+ }
11318
+ width = Math.max(1, width);
11319
+ const key3 = `${contentHash(content)}:${width}`;
11320
+ const cached2 = markdownCache.get(key3);
11321
+ if (cached2 !== void 0) return cached2;
11322
+ const text5 = renderMarkdown(content, { width }).trimEnd();
11323
+ const lines = [[]];
11324
+ for (const cell2 of ansiToCells(text5)) {
11325
+ if (cell2.ch === "\n") lines.push([]);
11326
+ else lines.at(-1).push(cell2);
11327
+ }
11328
+ const prepared = { text: text5, lines };
11329
+ markdownCache.set(key3, prepared);
11330
+ return prepared;
11331
+ }
11332
+ function contentHash(content) {
11333
+ let hash = 2166136261;
11334
+ for (let index = 0; index < content.length; index += 1) {
11335
+ hash ^= content.charCodeAt(index);
11336
+ hash = Math.imul(hash, 16777619);
11337
+ }
11338
+ return hash >>> 0;
11339
+ }
11340
+ var markdownCache;
11341
+ var init_detail_content = __esm({
11342
+ "packages/toolcraft-design/src/explorer/detail-content.ts"() {
11343
+ "use strict";
11344
+ init_ansi_text();
11345
+ init_terminal_markdown();
11346
+ markdownCache = /* @__PURE__ */ new Map();
11347
+ }
11348
+ });
11349
+
11305
11350
  // packages/toolcraft-design/src/explorer/render/text.ts
11306
11351
  function cellWidth(value, startColumn = 0) {
11307
11352
  return displayWidth2(value, startColumn);
@@ -11421,18 +11466,11 @@ function drawPaneFrame(screen, rect, title2, style = {}, options = {}) {
11421
11466
  screen.put(rect.x, rect.y + rect.height - 1, `${options.focused ? "\u2517" : "\u2514"}${horizontal.repeat(innerWidth)}${options.focused ? "\u251B" : "\u2518"}`, style);
11422
11467
  }
11423
11468
  }
11424
- function paneBodyRect(rect) {
11425
- return {
11426
- x: rect.x + 2,
11427
- y: rect.y + 1,
11428
- width: Math.max(0, rect.width - 4),
11429
- height: Math.max(0, rect.height - 2)
11430
- };
11431
- }
11432
11469
  var init_pane = __esm({
11433
11470
  "packages/toolcraft-design/src/explorer/render/pane.ts"() {
11434
11471
  "use strict";
11435
11472
  init_text2();
11473
+ init_layout2();
11436
11474
  }
11437
11475
  });
11438
11476
 
@@ -11471,7 +11509,8 @@ function renderDetailBody(state, screen, rect, row) {
11471
11509
  return { start: 0, max: 0 };
11472
11510
  }
11473
11511
  if (items.length === 1 && items[0]?.title === void 0) {
11474
- return renderBlob(screen, rect, renderItemMarkdown(items[0], rect, row), state.detail.scroll);
11512
+ const content = prepareDetailContent(renderItem(items[0], rect, row), rect.width);
11513
+ return renderBlob(screen, rect, content.lines, state.detail.scroll);
11475
11514
  }
11476
11515
  return renderListMode(state, screen, rect, items, row);
11477
11516
  }
@@ -11499,7 +11538,8 @@ function renderListMode(state, screen, rect, items, row) {
11499
11538
  writeLine2(screen, rect, y, ` ${item.subtitle}`, styles.muted);
11500
11539
  y += 1;
11501
11540
  }
11502
- for (const line of renderItemMarkdown(item, rect, row).split("\n")) {
11541
+ const content = prepareDetailContent(renderItem(item, rect, row), rect.width);
11542
+ for (const line of content.text.split("\n")) {
11503
11543
  if (y >= rect.height) {
11504
11544
  break;
11505
11545
  }
@@ -11512,12 +11552,7 @@ function renderListMode(state, screen, rect, items, row) {
11512
11552
  }
11513
11553
  return { start, max };
11514
11554
  }
11515
- function renderBlob(screen, rect, text5, scroll) {
11516
- const allLines = [[]];
11517
- for (const cell2 of ansiToCells(text5)) {
11518
- if (cell2.ch === "\n") allLines.push([]);
11519
- else allLines.at(-1).push(cell2);
11520
- }
11555
+ function renderBlob(screen, rect, allLines, scroll) {
11521
11556
  const max = Math.max(0, allLines.length - rect.height);
11522
11557
  const start = clamp3(scroll, 0, max);
11523
11558
  const lines = allLines.slice(start);
@@ -11531,19 +11566,6 @@ function renderBlob(screen, rect, text5, scroll) {
11531
11566
  }
11532
11567
  return { start, max };
11533
11568
  }
11534
- function renderItemMarkdown(item, rect, row) {
11535
- const content = renderItem(item, rect, row);
11536
- if (content.trim().length === 0) {
11537
- return "";
11538
- }
11539
- const width = Math.max(1, rect.width);
11540
- const key3 = `${contentHash(content)}:${width}`;
11541
- const cached2 = markdownCache.get(key3);
11542
- if (cached2 !== void 0) return cached2;
11543
- const rendered = renderMarkdown(content, { width }).trimEnd();
11544
- markdownCache.set(key3, rendered);
11545
- return rendered;
11546
- }
11547
11569
  function renderItem(item, rect, row) {
11548
11570
  if (item.renderedContent !== void 0) {
11549
11571
  return item.renderedContent;
@@ -11573,24 +11595,14 @@ function scrollIndicator(state, start, max) {
11573
11595
  if (state.detail.loading) return "\u280B";
11574
11596
  return `${max === 0 ? 0 : Math.round(start / max * 100)}%`;
11575
11597
  }
11576
- function contentHash(content) {
11577
- let hash = 2166136261;
11578
- for (let index = 0; index < content.length; index += 1) {
11579
- hash ^= content.charCodeAt(index);
11580
- hash = Math.imul(hash, 16777619);
11581
- }
11582
- return hash >>> 0;
11583
- }
11584
- var markdownCache;
11585
11598
  var init_detail = __esm({
11586
11599
  "packages/toolcraft-design/src/explorer/render/detail.ts"() {
11587
11600
  "use strict";
11588
- init_ansi_text();
11589
- init_terminal_markdown();
11601
+ init_detail_content();
11602
+ init_layout2();
11590
11603
  init_theme();
11591
11604
  init_pane();
11592
11605
  init_text2();
11593
- markdownCache = /* @__PURE__ */ new Map();
11594
11606
  }
11595
11607
  });
11596
11608
 
@@ -12927,31 +12939,18 @@ function maxDetailScroll(state) {
12927
12939
  return 0;
12928
12940
  }
12929
12941
  if (items.length === 1 && items[0]?.title === void 0) {
12930
- const visibleHeight = detailBodyHeight(state);
12931
- if (visibleHeight <= 0) {
12942
+ const body = paneBodyRect(computeExplorerLayout({ ...state.size, focused: state.focused }).detail);
12943
+ const content = items[0]?.renderedContent;
12944
+ if (body.width <= 0 || body.height <= 0 || content === void 0) {
12932
12945
  return 0;
12933
12946
  }
12934
- return Math.max(0, detailContentLineCount(items[0]) - visibleHeight);
12947
+ return Math.max(0, prepareDetailContent(content, body.width).lines.length - body.height);
12935
12948
  }
12936
12949
  return Math.max(0, items.length - 1);
12937
12950
  }
12938
- function detailContentLineCount(item) {
12939
- return (item.renderedContent ?? "").split("\n").length;
12940
- }
12941
12951
  function detailBodyHeight(state) {
12942
- if (state.layout === "too-narrow" || state.layout === "narrow-list-only" && state.focused !== "detail") {
12943
- return 0;
12944
- }
12945
- const rows = normalizeSize6(state.size.rows);
12946
- const footerHeight = rows > 0 ? Math.min(1, rows) : 0;
12947
- const headerHeight = Math.min(3, Math.max(0, rows - footerHeight));
12948
- const contentHeight = Math.max(0, rows - headerHeight - footerHeight);
12949
- if (state.layout === "narrow-vertical") {
12950
- const listHeight = Math.ceil(contentHeight / 2);
12951
- const detailHeight = contentHeight - listHeight;
12952
- return Math.max(0, detailHeight - 2);
12953
- }
12954
- return Math.max(0, contentHeight - 2);
12952
+ const body = paneBodyRect(computeExplorerLayout({ ...state.size, focused: state.focused }).detail);
12953
+ return body.width > 0 ? body.height : 0;
12955
12954
  }
12956
12955
  function extendSelection(state, delta2) {
12957
12956
  if (!state.multiSelect) {
@@ -13270,7 +13269,9 @@ var init_reducer = __esm({
13270
13269
  "use strict";
13271
13270
  init_terminal_width();
13272
13271
  init_actions();
13272
+ init_detail_content();
13273
13273
  init_filter();
13274
+ init_layout2();
13274
13275
  init_state();
13275
13276
  NO_EFFECTS = [];
13276
13277
  DEFAULT_ACTION_HANDLES = {
@@ -154211,7 +154212,7 @@ var init_package2 = __esm({
154211
154212
  "package.json"() {
154212
154213
  package_default2 = {
154213
154214
  name: "poe-code",
154214
- version: "5.0.3",
154215
+ version: "5.0.4",
154215
154216
  description: "CLI tool to configure Poe API for developer workflows.",
154216
154217
  license: "MIT",
154217
154218
  type: "module",