{"id":30283157,"url":"https://github.com/halliwood/as2ts","last_synced_at":"2025-08-16T17:14:10.064Z","repository":{"id":57184558,"uuid":"285557276","full_name":"Halliwood/as2ts","owner":"Halliwood","description":"A great nodejs tool to translate actionscript 3 to typescript. Useful for h5 game developer!","archived":false,"fork":false,"pushed_at":"2021-05-28T10:53:54.000Z","size":749,"stargazers_count":28,"open_issues_count":0,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-08-09T01:41:35.058Z","etag":null,"topics":["actionscript3","nodejs","translation","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Halliwood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-06T11:48:49.000Z","updated_at":"2025-06-24T13:51:18.000Z","dependencies_parsed_at":"2022-09-14T08:50:43.408Z","dependency_job_id":null,"html_url":"https://github.com/Halliwood/as2ts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Halliwood/as2ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Halliwood%2Fas2ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Halliwood%2Fas2ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Halliwood%2Fas2ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Halliwood%2Fas2ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Halliwood","download_url":"https://codeload.github.com/Halliwood/as2ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Halliwood%2Fas2ts/sbom","scorecard":{"id":60929,"data":{"date":"2025-08-11","repo":{"name":"github.com/Halliwood/as2ts","commit":"4f32e019e10eb9c873f0fc29ecee392b7d9b2d7c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T01:41:24.094Z","repository_id":57184558,"created_at":"2025-08-15T01:41:24.095Z","updated_at":"2025-08-15T01:41:24.095Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270742064,"owners_count":24637513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actionscript3","nodejs","translation","typescript"],"created_at":"2025-08-16T17:14:09.037Z","updated_at":"2025-08-16T17:14:10.051Z","avatar_url":"https://github.com/Halliwood.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## AS2TS\n\n本工具可以帮助你将Actionscript3.0项目完美地转换为TypeScript项目，特别适合于早期使用Laya1.0+AS3开发项目的你。\n\n## 特色\n\n* 批量将ActionScript3.0代码完美翻译成TypeScript代码，解决普通的正则表达式替换无法解决的各类问题\n* 智能添加this指针\n* 智能导入import\n* 支持自定义类型转换\n\n## 比较\n\n* [nshen/as2ts](https://github.com/nshen/as2ts) - 只是简单的正则表达式替换，翻译后会有各种语法问题，无法解决`for each`/`for in`/`new Vector.\u003cint\u003e()`之类的翻译问题，也无法自动添加this指针和import。\n\n## 将Laya 1.0 as项目转换为Laya 2.0 ts项目\n  使用本工具可以一键转换Laya项目，这篇文章提供了操作步骤，请参考：[全网最好用的AS3转TS代码工具：as2ts-smart](https://www.jianshu.com/p/c25f1112f310)\n\n## 使用环境\n\nNode.js\n\n## 安装\n\n`npm i as2ts-smart -g`\n\n## 用法\n\n简单模式\n```\nas2ts-smart -s E:\\\\asproj\\\\src\\\\ --dist E:\\\\tsproj\\\\src\\\\\n```\n\n高级模式\n```\nas2ts-smart -s E:\\\\asproj\\\\src\\\\ --dist E:\\\\tsproj\\\\src\\\\ -r E:\\\\rule.json\n```\n\n### 参数\n\n#### -h, --help \n  输出帮助信息。\n\n#### -s, --src\n  必须。待翻译的ActionScript3.0代码目录。\n\n#### --dist\n  必须。生成的TypeScript代码输出目录。\n\n#### -m, --module\n  可选。将ActionScript3.0的`package`翻译成`module`。\n\n#### -M, --no-module\n  可选（默认）。与-m相反。\n  \n#### -r, --rule\n  可选。翻译规则描述文件，as2ts-smart将根据该描述指定的规则进行翻译。\n\n### 使用配置文件自定义翻译规则\n\nas2ts-smart支持你通过配置文件自定义翻译规则，配置文件需要为一个JSON文件。\n配置文件的格式定义如下，请参见[As2TsOption](./typings/index.d.ts)\n\n```TypeScript\nexport interface As2TsOption {\n    /**忽略规则 */\n    skipRule?: As2TsSkipRule, \n    /**标识符替换规则，不支持正则表达式匹配 */\n    idReplacement?: {[raw: string]: string}, \n    /**字面量替换规则，不支持正则表达式匹配 */\n    literalReplacement?: {[raw: string]: string}, \n    /**类型映射规则，不支持正则表达式匹配 */\n    typeMapper?: {[key: string]: string}, \n    /**方法替换映射规则，不支持正则表达式匹配 */\n    methordMapper?: {[key: string]: string}, \n    /**是否生成模块，默认为false */\n    module?: boolean, \n    /**模块导入规则 */\n    importRule?: As2TsImportRule, \n    /**额外的typescript代码库，用于补充类库信息 */\n    tsLibs?: string[], \n    /**是否打印详细的错误信息 */\n    errorDetail?: boolean, \n    /**是否在发生错误时立即终止 */\n    terminateWhenError?: boolean, \n    /**是否从上次运行处继续翻译 */\n    continueLast?: boolean,\n    /**临时文件缓存目录 */\n    tmpRoot?: string\n}\n```\n\n#### 配置例子\n\n完整的配置例子，请参见[rule.json](./example/rule.json)\n将Laya 1.0+as升级到Laya 2.0+ts的配置例子，请参见[laya1upto2.json](./example/laya1upto2.json)\n\n#### skipRule\n  此项用于在翻译时忽略部分文件，其格式定义如下，请参见[As2TsSkipRule](./typings/index.d.ts)\n\n```TypeScript\nexport interface As2TsSkipRule {\n    /**需要忽略的文件夹，支持正则表达式匹配 */\n    \"dirs\"?: string[], \n    /**需要忽略的文件，支持正则表达式匹配 */\n    \"files\"?: string[]\n}\n```\n\n  比如，假设输入的as3项目目录为`asproj/src`，则下述规则表示不要翻译`asproj/src/ui/*`和`asproj/src/automatic/*`目录下的文件，以及`MsgPool.as`等文件。\n  注意，如果使用正则表达式匹配，也要用字符串形式配置，如例子中的`\"^\\\\bui\\\\b\"`，相当于正则表达式`^\\bui\\b`。\n  小提示：`\\b`用于匹配单词的边界，关于其详细用法请查找正则表达式资料，以下不详细解释。\n\n```JSON\n\"skipRule\": {\n    \"dirs\": [\"^\\\\bui\\\\b\", \"^automatic\"], \n    \"files\": [\"FyMsg.as\", \"DecodeUtil.as\", \"EncodeUtil.as\", \"SendMsgUtil.as\"]\n}\n```\n\n#### idReplacement\n  此项用于在翻译时将某些标识符（包括变量名、类名、函数名等）进行替换。不支持正则表达式匹配。比如下述规则表示将`KW`替换为`KeyWord`等。\n\n```JSON\n\"idReplacement\": {\n    \"KW\": \"KeyWord\", \n    \"Laya.Component\": \"Laya.UIComponent\", \n    \"Laya.RaycastHit\": \"Laya.HitResult\", \n    \"Laya.StandardMaterial\": \"Laya.BlinnPhongMaterial\"\n}\n```\n\n#### literalReplacement\n  此项用于在翻译时将某些字面量（包括数值、字符串等）进行替换。不支持正则表达式匹配比如下述规则表示将字符串`automatic/constants/KW`替换为`automatic/constants/KeyWord`。\n\n```JSON\n\"literalReplacement\": {\n    \"\\\"automatic/constants/KW\\\"\": \"\\\"automatic/constants/KeyWord\\\"\"\n}\n```\n\n#### typeMapper\n  此项用于对某些类型进行自定义替换。下述是as2ts-smart对此项的默认配置，用于对AS3的基本类型进行翻译。\n  你只需要配置自己新增的替换项，而不需要重复配置默认替换项。as2ts-smart会将你的自定义配置和默认配置进行合并。\n\n```JSON\n{\n    \"int\": \"number\", \n    \"Number\": \"number\", \n    \"uint\": \"number\", \n    \"Boolean\": \"boolean\", \n    \"String\": \"string\", \n    \"Object\": \"any\"\n}\n```\n\n#### methordMapper\n  此项用于对某些函数进行自定义替换。下述是as2ts-smart对此项的默认配置，用于对AS3的`trace`方法翻译为TS的`console.log`方法。\n  你只需要配置自己新增的替换项，而不需要重复配置默认替换项。as2ts-smart会将你的自定义配置和默认配置进行合并。\n\n```JSON\n{\n    \"trace\": \"console.log\"\n}\n```\n\n#### module\n  此项用于指定是否将AS3中的`package xxx`翻译为`module xxx`，相应的，所有的`import a.b.C;`将会翻译为`import C = a.b.C;`。默认关闭。也可用参数`-m`/`--module`开启。比如如下两个AS3类：\n\n```ActionScript 3.0\n// file a/B.as\npackage a {\n    public class B\n    {\n        //...\n    }\n}\n```\n\n```ActionScript 3.0\n// file a/b/C.as\npackage a.b {\n    import a.B;\n    public class C extends B\n    {\n        //...\n    }\n}\n```\n\n默认情况下，将分别翻译为\n\n```TypeScript\n// file a/B.ts\nmodule a {\n    expport class B\n    {\n        //...\n    }\n}\n```\n\n```TypeScript\n// file a/b/C.ts\nmodule a.b {\n    import B = a.B;\n    export class C extends B\n    {\n        //...\n    }\n}\n```\n\n  当`noModule`选项设置为`true`时，则翻译为\n  \n```TypeScript\n// file a/B.ts\nexpport class B\n{\n    //...\n}\n```\n\n```TypeScript\n// file a/b/C.ts\nimport {B} from '../B';\nexport class C extends B\n{\n    //...\n}\n```\n\n#### importRule\n  此项用于将AS的包按照指定的规则以TS模块的形式进行导入，并去除原先的import语句。其格式定义如下，请参见[As2TsImportRule](./typings/index.d.ts)。\n  \n```TypeScript\nexport interface FromModule {\n    /**导入的模块名 */\n    \"module\": string, \n    /**匹配规则，支持正则表达式匹配 */\n    \"regular\": string, \n    /**模块名需要另外import的路径*/\n    \"import\"?: string\n}\n\nexport interface As2TsImportRule {\n    /**需要以模块形式进行import导入的规则 */\n    \"fromModule\"?: FromModule[]\n}\n```\n  \n  下述例子的第一个配置即是对AS中的`laya.*`等进行翻译的应用。它将会把`laya.utils.Handler`和`laya.ui.Image`之类的翻译成`Laya.Handler`和`Laya.Image`。\n  对于某些需要import的模块，比如Laya2.0中ui类的使用，可以配置`import`项进行import。\n\n```JSON\n\"importRule\": {\n    \"fromModule\": [\n        {\"module\": \"Protocol\", \"regular\": \"^automatic/protocol/(?!Macros|ErrorId)\" }, \n        {\"module\": \"GameConfig\", \"regular\": \"^automatic/cfgs/(?!ConfigDecoder)\" }, \n        {\"module\": \"Laya\", \"regular\": \"^laya/\" }, \n        {\"module\": \"ui\", \"regular\": \"^ui/\", \"import\": \"ui/layaMaxUI\" }\n    ]\n}\n```\n\n#### tsLibs\n  as2ts-smart在翻译时会通过分析AS代码得到类与类之间的继承关系，进而实现对AS中常见的this指针缺省现象进行智能添加。但有时候输入的AS项目中并不能提供最完整的信息，会导致as2ts-smart无法判定某些标识符是否需要添加this指针。比如，有些类型的是由第三方SDK定义的，这时你可以将第三方SDK的`.d.ts`文件配置于此项。比如，下述例子可以让as2ts-smart获得Laya SDK的相关信息。\n\n```JSON\n\"tsLibs\": [\"E:/qhgame/tsproj/libs/LayaAir.d.ts\", \"E:/qhgame/tsproj/libs/layaAir.minigame.d.ts\", \"E:/qhgame/tsproj/src/ui/layaMaxUI.ts\"]\n```\n\n#### errorDetail\n  开启此项，当发生错误时as2ts-smart将输出更详尽的信息方便定位问题。\n\n#### terminateWhenError\n  开启此项，当发生错误时as2ts-smart将停止继续翻译。\n\n#### continueLast\n  开启此项，as2ts-smart将从上一次翻译中断的文件继续翻译。\n\n#### tmpRoot\n  设置as2ts-smart的工作临时目录，默认为`{CURRENTDIRECTORY}/tmp`。\n\n## 已知问题\n\n### 内联函数\n  暂不支持内联函数的翻译。如果AS代码中存在内联函数，可能导致转换时发生错误（当然也有可能可以成功转换）。请尽量避免使用类似下述的写法：\n\n```as3\nprivate function doSomething(): void {\n    // 以下调用了一个内联函数\n    doSomethingInner();\n    // 不要使用此类内联函数\n    function doSomethingInner(): void {\n        // ...\n    }\n}\n```\n\n### 某些不常规的写法\n  比如不常规的换行、拆行，也可能导致转换时失败，请根据失败提示修改一下写法。比如：\n\n```as3\nprivate function maybeFailed(sth: *): void {\n    // 以下写法把包括is关键的一对括号放在上下两行，可能会导致转换失败\n    if(sth is \n    Image) {\n        // ...\n    }\n}\n```\n\n## 使用许可\n\nISC\n\n## 作者\n\n[Github](https://github.com/Halliwood/) | [npm](https://www.npmjs.com/~taiyosen) | [QQ](http://wpa.qq.com/msgrd?v=3\u0026uin=501251659\u0026site=qq\u0026menu=yes)\n\n## 鼓励作者继续改善\n[1元助力](http://jd.res.fygame.com/testurl/jwcKorea/assets/android/donate.jpg)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalliwood%2Fas2ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalliwood%2Fas2ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalliwood%2Fas2ts/lists"}