npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

asai-lua-format

v0.1.13

Published

asai for you

Readme

asai-lua-format — Lua 源码格式化(luamin)

包信息

| 建议 npm 名 | 入口文件 | $fn / 注入键 | 类型 | |------------|---------|-------------|------| | @estun/asai-lua-format | AsaiLuaFormat.js | AsaiLuaFormat{ Beautify, … } | Feature |

概述

asai-lua-format 封装 luamin 格式化引擎,提供 Beautify() 等方法,供 Monaco Lua 编辑器「格式化文档」使用。独立打包 JS(~4900 行),无 npm 运行时依赖。

集成方式

// monorepo — 延迟:lib/featurePlugs.ts
// import AsaiLuaFormat from './plugs/asai-lua-format/AsaiLuaFormat.js';
// npm
// import AsaiLuaFormat from '@estun/asai-lua-format';

await ensureFeaturePlug($fn, 'AsaiLuaFormat');
$fn.AsaiLuaFormat.Beautify(code, { RenameVariables: true });

独立性约束

  • 禁止 cross-import 其它 plugs/*(含 asai-lua-parse)。
  • 格式化与 AST 解析职责分离,业务按需分别 ensureFeaturePlug

主要 API / 导出

| 方法 | 说明 | |------|------| | Beautify(source, options?) | 格式化 Lua 源码 |

options: RenameVariables, RenameGlobals, SolveMath(boolean)

性能说明

  • 延迟加载;模块体积大,仅在 registerDeferredPlugsensureFeaturePlug 后进入内存。
  • Beautify 为 CPU 密集同步操作,大文件会阻塞主线程;编辑器层应 try/catch + Monaco undo。
  • 不在首屏 bundle 中。

peerDependencies 建议

{
  "peerDependencies": {}
}

(纯 JS 产物,无 Vue peer;若仅作工具包发布可不声明 vue。)


使用示例

const pretty = $fn.AsaiLuaFormat.Beautify('local x=1+2;print(x)', {
  RenameVariables: true,
  RenameGlobals: false,
  SolveMath: true,
});

与 asai-lua-parse

| 插件 | 职责 | |------|------| | asai-lua-format | 改写并美化源码 | | asai-lua-parse | AST 只读分析 |

文件结构

asai-lua-format/
├── AsaiLuaFormat.js
└── README.md

注意事项

  1. 格式化前确保 Monaco undo 栈可用。
  2. RenameGlobals: true 可能破坏跨文件全局引用,默认 false
  3. 语法错误时可能抛异常,需捕获并提示用户。

主要调用方

cocontrol/.../useLuaEditor.tsformatLuaCode()

测试

npx tsx --test .youmengyu/test/unit/webclient/plugs/asai-lua-format/*.test.mjs
npm test --prefix webclient/src/plugs/asai-lua-format
node .youmengyu/test/asaitest.mjs

入口:package.jsonmain/exports 指向 AsaiLuaFormat.js