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 🙏

© 2024 – Pkg Stats / Ryan Hefner

type2lua

v0.3.50

Published

type2lua 顾名思义就是将ts代码编译到lua。 > 当前版本仅兼容lua5.3及以上版本。

Downloads

14

Readme

type2Lua 工程说明文档

type2lua 顾名思义就是将ts代码编译到lua。

当前版本仅兼容lua5.3及以上版本。

使用方法

tsconfig.json 配置

配置方式与ts2js环境基本相同,以下列举一些常见配置:

  1. compilerOptions.rootDir 被编译文件的根目录,里面的所有文件都会保持目录结构得编译到outDir目录。
  2. compilerOptions.outDir 最终导出的目录
  3. compilerOptions.rootDirs 里面的文件的根目录会指向rootDir 并编译到outDir目录,意味着rootDir中的文件可以通过相对引用的方式引用到rootDirs中的文件,在逻辑上rootDirs中的文件其实是rootDir中的文件。
  4. include 包含的文件列表,这里指的是真正被加载编译的文件。
  5. typelua.extName 自定义扩展名
    //配置案例
    {
    "compilerOptions": {
        "target": "esnext", 
        "strict": true, 
        "esModuleInterop": true, 
        "experimentalDecorators": true, 
        "forceConsistentCasingInFileNames": true, 
        "skipLibCheck": true,
        "rootDir": "./src",
        "rootDirs": [
            "./src/gleetslibs"
        ],
        "outDir": "../Assets/Bundle/Lua"
    },
    "include": [
        "./src/**/*",
    ],
    "typelua": {
        "extName": ".lua.txt"
    },
}

编译

如果你是通过ccf安装的type2lua,则执行以下命令即可编译:

$ ccf type2lua #以当前目录下tsconfig.json的文件编译
$ ccf type2lua -w #持续编译项目
$ ccf type2lua --build '文件地址' #指定配置文件
$ ccf type2lua --libs #同时生成js环境基础库到rootDir目录

修改及发布

当你需要对js环境基础库进行修改时; 当你需要对type2lua编译器进行改进时; 你可以向我们获取type2lua工程的访问权限。其中包含一个自模块baselib,可以在此工程中修改js环境基础库的源代码。修改后按F5进行编译,然后即可以升级codecanfly的版本号,添加修改记录,并执行 ccf publish 发布新版本。同样,修改编译器源码也可以执行这样的步骤发布。

问题反馈

当遇到编译器的问题时,你首先要查看该文档的FAQ,这里会记录很多常见的问题。如果没有记录则可以通过钉钉的《引擎工具组》使用对接群进行反馈获得最快的解决方案。

目前已知问题

  1. 暂不支持错误检查
  2. 暂不支持自动处理文件相互引用
  3. 暂不支持 ?? 运算符
  4. 暂不支持 in 运算符
  5. stirng 不支持utf-16,当前字符串的api以lua的string接口为基础,因此汉字的字符串长度获取可能异常,暂时可通过lua5.3的utf8库进行解决。

FAQ

  1. 在ts中我们往往会接收一个callback函数,并保存下来,作为逻辑处理的返回值,但是当回掉时会默认使用:进行会掉,导致第一个参数变成了self,遇到这种情况如何处理?

我们只需要在函数的申明出添加 @noSelf 即可,这样调用时就不会传递self了。

    class Test{
        /**
         * @noSelf
         **/
        _callback:(value)=>{}
        play(callback:(value)=>{}){
            this._callback=callback;
            
            //noSelf 帮助了编译器自动使用.来调用回掉函数
            this._callback(1);// => self._callback(1)
        }
    }