@charmland/lipgloss

中文文档
2.0.0-beta.3-0e280f3发布于 2025/10/06MITES Module零依赖近 30 天下载 1.5万

良好终端布局的样式定义 QQ

中文使用文档
文档目录22 节
  1. 安装
  2. 示例
  3. 表格数据
  4. 基本用途
  5. 表格数据方法
  6. 环境变量
  7. 兼容性
  8. 规模(100%)
  9. 颜色 (100%)
  10. 边界(100%)
  11. 样式(97.62%)
  12. 表格(100%)
  13. 名单(100%)
  14. 树 (95%)
  15. 加入(100%)
  16. 职位(100%)
  17. 查询( 50%)
  18. 对齐(0%)
  19. 捐款
  20. 测试
  21. 反馈
  22. 许可证

LipGloss.js (英语)

你所知道和所爱的唇膏 现在在JavaScript.

[尖叫声] LipGloss.js是斯图尔实验.

安装

npm i @charmland/lipgloss

示例

const { Table, TableData, Style, Color, List, Tree, Leaf, Bullet, RoundedEnumerator } = require("@charmland/lipgloss");

var s = new Style().foreground(Color("240")).render;
console.log(
  new Table()
    .wrap(false)
    .headers("Drink", "Description")
    .row("Bubble Tea", s("Milky"))
    .row("Milk Tea", s("Also milky"))
    .row("Actual milk", s("Milky as well"))
    .render(),
);

// TableData example - for more complex data management
const employeeData = new TableData(
  ["Employee ID", "Name", "Department"],
  ["001", "John Doe", "Engineering"],
  ["002", "Jane Smith", "Marketing"],
  ["003", "Mike Johnson", "Sales"]
);

console.log(
  new Table()
    .data(employeeData)
    .styleFunc((row, col) => {
      if (row === -1) {
        return new Style().foreground(Color("99")).bold(true);
      }
      return new Style().padding(0, 1);
    })
    .render()
);

// List example
const groceries = new List("Bananas", "Barley", "Cashews", "Milk")
  .enumerator(Bullet)
  .itemStyle(new Style().foreground(Color("255")));

console.log(groceries.render());

// Tree example with Leaf nodes
const makeupTree = new Tree()
  .root("⁜ Makeup")
  .child(
    "Glossier",
    "Fenty Beauty",
    new Tree().child(
      new Leaf("Gloss Bomb Universal Lip Luminizer"),
      new Leaf("Hot Cheeks Velour Blushlighter")
    ),
    new Leaf("Nyx"),
    new Leaf("Mac"),
    "Milk"
  )
  .enumerator(RoundedEnumerator)
  .enumeratorStyle(new Style().foreground(Color("63")).marginRight(1))
  .rootStyle(new Style().foreground(Color("35")))
  .itemStyle(new Style().foreground(Color("212")));

console.log(makeupTree.render());

表格数据

这个 TableData 类提供了比起使用单个行来管理表格数据的更结构化的方法. 需要时特别有用:

  • 动态构建表格
  • 在方案上访问各个单元
  • 管理大数据集
  • 将数据逻辑与演示文稿分开

基本用途

const { Table, TableData, Style, Color } = require("@charmland/lipgloss");

// Create TableData with initial rows
const data = new TableData(
  ["Name", "Age", "City"],
  ["Alice", "25", "New York"],
  ["Bob", "30", "San Francisco"]
);

// Or build it incrementally
const data2 = new TableData()
  .append(["Product", "Price"])
  .append(["Laptop", "$999"])
  .append(["Mouse", "$25"]);

// Use with Table
const table = new Table()
  .data(data)
  .styleFunc((row, col) => {
    if (row === -1) return new Style().bold(true); // Header
    return new Style().padding(0, 1);
  })
  .render();

表格数据方法

  • new TableData(...rows) - 以可选初始行创建
  • .append(row) - 添加一行(字符串阵列)
  • .rows(...rows) - 一次添加多行
  • .at(row, col) - 在特定位置获得价值
  • .rowCount() - 获取行数
  • .columnCount() - 获取列数

见 examples/table-data.js 比较全面的例子.

环境变量

您可以使用环境变量控制调试输出 :

  • LIPGLOSS_DEBUG=true - 启用所有 lipgloss 调试输出
  • DEBUG=lipgloss - 启用 lipgloss 调试输出(标准调试模式)
  • DEBUG=* - 启用所有调试输出

示例

node your-script.js

兼容性

在JavaScript中Lipgloss是实验性的,很多已存在的功能还没有被移植到JavaScript上.

规模(100%)

函数状态
Width✅
Height✅
Size✅

颜色 (100%)

函数状态
Color✅
NoColor✅
Complete✅
LightDark✅
RGBA✅

边界(100%)

函数状态
NormalBorder✅
RoundedBorder✅
BlockBorder✅
OuterHalfBlockBorder✅
InnerHalfBlockBorder✅
ThickBorder✅
DoubleBorder✅
HiddenBorder✅
MarkdownBorder✅
ASCIIBorder✅

样式(97.62%)

函数状态
Foreground✅
Background✅
Width✅
Height✅
Align✅
AlignHorizontal✅
AlignVertical✅
Padding✅
PaddingLeft✅
PaddingRight✅
PaddingTop✅
PaddingBottom✅
ColorWhitespace✅
Margin✅
MarginLeft✅
MarginRight✅
MarginTop✅
MarginBottom✅
MarginBackground✅
Border✅
BorderStyle✅
SetBorderRight✅
SetBorderLeft✅
SetBorderTop✅
SetBorderBottom✅
BorderForeground✅
BorderTopForeground✅
BorderRightForeground✅
BorderBottomForeground✅
BorderLeftForeground✅
BorderBackground✅
BorderTopBackground✅
BorderRightBackground✅
BorderBottomBackground✅
BorderLeftBackground✅
Inline✅
MaxWidth✅
MaxHeight✅
TabWidth✅
UnderlineSpaces✅
Underline✅
Reverse✅
SetString✅
Inherit✅
Faint✅
Italic✅
Strikethrough✅
StrikethroughSpaces✅
Transform⏳

表格(100%)

函数状态
table.New✅
table.Rows✅
table.Headers✅
table.Render✅
table.ClearRows✅
table.BorderTop✅
table.BorderBottom✅
table.BorderLeft✅
table.BorderRight✅
table.BorderHeader✅
table.BorderColumn✅
table.BorderRow✅
table.Width✅
table.Height✅
table.Offset✅
table.String✅
table.StyleFunc✅
table.Data✅
table.Border✅
table.BorderStyle✅

名单(100%)

函数状态
Hidden✅
Hide✅
Offset✅
Value✅
String✅
Indenter✅
ItemStyle✅
ItemStyleFunc✅
EnumeratorStyle✅
EnumeratorStyleFunc✅
Item✅
Items✅
Enumerator✅

树 (95%)

函数状态
tree.New✅
tree.Root✅
tree.Child✅
tree.Hidden✅
tree.Hide✅
tree.SetHidden✅
tree.Offset✅
tree.Value✅
tree.SetValue✅
tree.String✅
tree.Render✅
tree.EnumeratorStyle✅
tree.EnumeratorStyleFunc✅
tree.ItemStyle✅
tree.ItemStyleFunc✅
tree.RootStyle✅
tree.Enumerator✅
tree.Indenter✅
tree.DefaultEnumerator✅
tree.RoundedEnumerator✅
tree.DefaultIndenter✅
NewLeaf✅
Leaf.Value✅
Leaf.SetValue✅
Leaf.Hidden✅
Leaf.SetHidden✅
Leaf.String✅
自定义数字⏳
自定义缩进⏳

加入(100%)

函数状态
JoinHorizontal✅
JoinVertical✅

职位(100%)

函数状态
Center✅
Right✅
Bottom✅
Top✅
Left✅
Place✅

查询( 50%)

函数状态
BackgroundColor⏳
HasDarkBackground✅

对齐(0%)

函数状态
EnableLegacyWindowsANSI⏳

捐款

我们很乐意你出力 请看 提供指南 更多信息.

测试

JavaScript装订包括一个全面的测试套件:

# From bindings directory
npm test                      # Run all tests
npm run test:simple           # Basic table functionality
npm run test:comprehensive    # Complete TableData tests
npm run examples              # Showcase functionality

# Or from examples directory
cd examples && npm test

测试位于 examples/tests/ 并覆盖:

  • 基本表格功能
  • 表格数据操作
  • 样式函数
  • Unicode 处理( 有已知限制)

见 捐款。 。 。 .

反馈

我们很想听听你对这个项目的看法。 给我们留个字条吧!

许可证

麻省理工学院


部分 魅力。 。 。 .

The Charm logo

• 魅力爱开源

版本与发布记录

@charmland/lipgloss 共发布 2 个版本,首次发布于 2025/10/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0-beta.3-0e280f3latest2025/10/061.1 年前
0.0.12025/10/021.1 年前

关于 @charmland/lipgloss 的常见问题

@charmland/lipgloss 是什么?

良好终端布局的样式定义 QQ

如何安装 @charmland/lipgloss?

在项目目录运行 npm install @charmland/lipgloss,或使用 pnpm add / yarn add / bun add。

@charmland/lipgloss 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/charmland__lipgloss 是否存在。

@charmland/lipgloss 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@charmland/lipgloss 可以商用吗?

@charmland/lipgloss 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@charmland/lipgloss 的下载量有多少?

根据 npm 官方下载统计,@charmland/lipgloss 在 2026/10/10 – 2026/11/08 这 30 天内被下载 15,450 次,日均约 515 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@charmland/lipgloss 还在维护吗?

最新版本 2.0.0-beta.3-0e280f3 发布于 2025/10/06(1.1 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/10/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。