feat: add builder configuration file

feat: add cocos-service configuration file
feat: add device configuration file
feat: add engine configuration file
feat: add information configuration file
feat: add program configuration file
feat: add project configuration file
feat: add TypeScript configuration file
This commit is contained in:
ZhouXiao
2025-12-22 11:42:51 +08:00
parent 66cfa73345
commit 487c68994d
202 changed files with 57615 additions and 0 deletions

View File

@@ -0,0 +1,181 @@
# CC3.WebEasyObfus
![Static Badge](https://img.shields.io/badge/Version-1.0.4-blue) ![Static Badge](https://img.shields.io/badge/CocosCreator-3.8.x-green) ![Static Badge](https://img.shields.io/badge/Tested_On-web-yellow)
*EN | [中文](/README-CN.md)
<p align="center"><img src="./logo.jpg" width="256"></p>
勾勾、选选就完事WebEasyObfus 混淆項目代码就这样简单。
> *「走過路過,別錯過,點顆星星,支持我!」*
> *(注:对插件的意见反馈请至 [Cocos 中文论坛](https://forum.cocos.org/t/topic/164539)。)*
## 安装方法
1. 下载项目成 ZIP 文件。
2. 解压后将内容复制到 `${your_project_path}/extensions/web-easy-obfus`
3. 打开终端
* 输入 `cd ${your_project_path}/extensions/web-zip-bundle`
* 安装扩展依赖包 `npm install`
* 构建扩展 `npm run build`
4. 到 Editor 菜单 Extension -> Extension Manager -> Installed 启用 `web-easy-obfus`
<p align="center"><img src="doc/img/extension_manager.png" width="450"></p>
>(*注:安装方法也可参考官方文档 [【扩展 安装与分享】](https://docs.cocos.com/creator/3.8/manual/zh/editor/extension/install.html) 。*)
## 如何使用
1. 到 Build Setting 新增 New Build Task 并选择平台 WebMobile/WebDesktop。到 Panel 中下拉找到 web-easy-obfus 选项。
* Enable启用或关闭功能。
* Include All Bundle: 包含所有Bundle
* 启用后,所有 Bundle 内的 JS 档案将进行混淆,否则只有 `assets/main/bundle.js` 下的JS档案将进行混淆。
* Select Obfus Level混淆分为五个等级等级越高混淆程度越彻底但文件体积会增大执行性能可能略受影响。
* 基础 (Minimal),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Disables converting code into a more complex control flow structure.
"controlFlowFlattening": false,
// Disables adding redundant dead code blocks.
"deadCodeInjection": false,
// Keeps global variable names unchanged.
"renameGlobals": false,
// Avoids extracting strings into a separate array for simplicity.
"stringArray": false
}
```
* 标准 (Standard),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 75% of the code.
"controlFlowFlatteningThreshold": 0.75,
// Avoids injecting unnecessary dead code.
"deadCodeInjection": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Applies string array obfuscation to 75% of strings.
"stringArrayThreshold": 0.75
}
```
* 增强 (Enhanced),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 90% of the code.
"controlFlowFlatteningThreshold": 0.9,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 40% of places.
"deadCodeInjectionThreshold": 0.4,
// Keeps global variable names unchanged for compatibility.
"renameGlobals": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using Base64.
"stringArrayEncoding": ["base64"],
// Applies string array obfuscation to 90% of strings.
"stringArrayThreshold": 0.9,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* 安全 (Secure),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 50% of places.
"deadCodeInjectionThreshold": 0.5,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using RC4 encryption.
"stringArrayEncoding": ["rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* 极致 (Ultimate),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in all possible places.
"deadCodeInjectionThreshold": 1,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings using both Base64 and RC4 encryption.
"stringArrayEncoding": ["base64", "rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true,
// Converts characters to Unicode escape sequences for obfuscation.
"unicodeEscapeSequence": true,
// Replaces console output calls with empty functions to hide debugging messages.
"disableConsoleOutput": true
}
```
## CI/CD
本插件天然支持 CI/CD只需從 Build Panel 导出当前平台的构建选项配置为 json 文件,用于[命令行构建](https://docs.cocos.com/creator/3.8/manual/zh/editor/publish/publish-in-command-line.html)。
<p align="center"><img src="./doc/img/build_panel_export.png" width="400"></p>
## 参考文献
* [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator)
* [Cocos Creator 官方的 UI 範例 GitHubCocos UI Example](https://github.com/cocos/cocos-example-ui)

View File

@@ -0,0 +1,173 @@
# CC3.WebEasyObfus
![Static Badge](https://img.shields.io/badge/Version-1.0.4-blue) ![Static Badge](https://img.shields.io/badge/CocosCreator-3.8.x-green) ![Static Badge](https://img.shields.io/badge/Tested_On-web-yellow)
Just check and select, and you're done, Obfuscator code with WebEasyObfus is simple.
> *"Dont just pass by, give it a try—hit a star and show your support!"*
> *NoteIf you have any feedback on the plugin, please go to [Cocos 中文论坛](https://forum.cocos.org/t/topic/163849)*
## Installation
1. Download ZIP package from github.
2. Decompress the file and copy the contents to `${your_project_path}/extensions/web-easy-obfus`.
3. Open the terminal
* `cd ${your_project_path}/extensions/web-zip-bundle`
* Enter `npm install`, install dependency packages.
* Enter `npm run build`, build the extension.
4. Go to the Editor menu `Extension -> Extension Manager -> Installed` to active the extension.
>*NoteYou can also check out the official docs for installation instructions. [【扩展 安装与分享】](https://docs.cocos.com/creator/3.8/manual/zh/editor/extension/install.html).*
## How to Use
1. Go to the Build Setting, add a Ner Build Task, and select the platform as WebModule or WebDesktop. In the Panel, scroll down to find the web-easy=obfus option.
* EnableTurn on/off the extension.
* Include All Bundle
* Check this: all bundle JS files will be obfuscated; otherwhile, only `assets/main/bundle.js` will be obfuscated.
* Select Obfus LevelThere are five levels of obfuscation. The higher the level, the more thorough the obfuscation, but the file size wil increase, and execution performance may be affected.
* MinimalThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Disables converting code into a more complex control flow structure.
"controlFlowFlattening": false,
// Disables adding redundant dead code blocks.
"deadCodeInjection": false,
// Keeps global variable names unchanged.
"renameGlobals": false,
// Avoids extracting strings into a separate array for simplicity.
"stringArray": false
}
```
* StandardThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 75% of the code.
"controlFlowFlatteningThreshold": 0.75,
// Avoids injecting unnecessary dead code.
"deadCodeInjection": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Applies string array obfuscation to 75% of strings.
"stringArrayThreshold": 0.75
}
```
* EnhancedThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 90% of the code.
"controlFlowFlatteningThreshold": 0.9,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 40% of places.
"deadCodeInjectionThreshold": 0.4,
// Keeps global variable names unchanged for compatibility.
"renameGlobals": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using Base64.
"stringArrayEncoding": ["base64"],
// Applies string array obfuscation to 90% of strings.
"stringArrayThreshold": 0.9,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* SecureThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 50% of places.
"deadCodeInjectionThreshold": 0.5,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using RC4 encryption.
"stringArrayEncoding": ["rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* UltimateThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in all possible places.
"deadCodeInjectionThreshold": 1,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings using both Base64 and RC4 encryption.
"stringArrayEncoding": ["base64", "rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true,
// Converts characters to Unicode escape sequences for obfuscation.
"unicodeEscapeSequence": true,
// Replaces console output calls with empty functions to hide debugging messages.
"disableConsoleOutput": true
}
```
## CI/CD
This exrension natively supports CI/CD. Export the current platform's build config as a JSON file from the Build Panel for [命令行构建](https://docs.cocos.com/creator/3.8/manual/zh/editor/publish/publish-in-command-line.html)。
## References
* [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator)
* [Cocos Creator 官方的 UI 範例 GitHubCocos UI Example](https://github.com/cocos/cocos-example-ui)

View File

@@ -0,0 +1,183 @@
# CC3.WebEasyObfus
![Static Badge](https://img.shields.io/badge/Version-1.0.4-blue) ![Static Badge](https://img.shields.io/badge/CocosCreator-3.8.x-green) ![Static Badge](https://img.shields.io/badge/Tested_On-web-yellow)
*EN | [中文](/README-CN.md)
<p align="center"><img src="./logo.jpg" width="256"></p>
Just check and select, and you're done, Obfuscator code with WebEasyObfus is simple.
> *"Dont just pass by, give it a try—hit a star and show your support!"*
> *NoteIf you have any feedback on the plugin, please go to [Cocos 中文论坛](https://forum.cocos.org/t/topic/164539)*
## Installation
1. Download ZIP package from github.
2. Decompress the file and copy the contents to `${your_project_path}/extensions/web-easy-obfus`.
3. Open the terminal
* `cd ${your_project_path}/extensions/web-zip-bundle`
* Enter `npm install`, install dependency packages.
* Enter `npm run build`, build the extension.
4. Go to the Editor menu `Extension -> Extension Manager -> Installed` to active the extension.
<p align="center"><img src="doc/img/extension_manager.png" width="450"></p>
>*NoteYou can also check out the official docs for installation instructions. [【扩展 安装与分享】](https://docs.cocos.com/creator/3.8/manual/zh/editor/extension/install.html).*
## How to Use
1. Go to the Build Setting, add a Ner Build Task, and select the platform as WebModule or WebDesktop. In the Panel, scroll down to find the web-easy=obfus option.
* EnableTurn on/off the extension.
* Include All Bundle
* Check this: all bundle JS files will be obfuscated; otherwhile, only `assets/main/bundle.js` will be obfuscated.
* Select Obfus LevelThere are five levels of obfuscation. The higher the level, the more thorough the obfuscation, but the file size wil increase, and execution performance may be affected.
* MinimalThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Disables converting code into a more complex control flow structure.
"controlFlowFlattening": false,
// Disables adding redundant dead code blocks.
"deadCodeInjection": false,
// Keeps global variable names unchanged.
"renameGlobals": false,
// Avoids extracting strings into a separate array for simplicity.
"stringArray": false
}
```
* StandardThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 75% of the code.
"controlFlowFlatteningThreshold": 0.75,
// Avoids injecting unnecessary dead code.
"deadCodeInjection": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Applies string array obfuscation to 75% of strings.
"stringArrayThreshold": 0.75
}
```
* EnhancedThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 90% of the code.
"controlFlowFlatteningThreshold": 0.9,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 40% of places.
"deadCodeInjectionThreshold": 0.4,
// Keeps global variable names unchanged for compatibility.
"renameGlobals": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using Base64.
"stringArrayEncoding": ["base64"],
// Applies string array obfuscation to 90% of strings.
"stringArrayThreshold": 0.9,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* SecureThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 50% of places.
"deadCodeInjectionThreshold": 0.5,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using RC4 encryption.
"stringArrayEncoding": ["rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* UltimateThe settings for javascript-obfuscator are as folloes:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in all possible places.
"deadCodeInjectionThreshold": 1,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings using both Base64 and RC4 encryption.
"stringArrayEncoding": ["base64", "rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true,
// Converts characters to Unicode escape sequences for obfuscation.
"unicodeEscapeSequence": true,
// Replaces console output calls with empty functions to hide debugging messages.
"disableConsoleOutput": true
}
```
## CI/CD
This exrension natively supports CI/CD. Export the current platform's build config as a JSON file from the Build Panel for [命令行构建](https://docs.cocos.com/creator/3.8/manual/zh/editor/publish/publish-in-command-line.html)。
<p align="center"><img src="./doc/img/build_panel_export.png" width="400"></p>
## References
* [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator)
* [Cocos Creator 官方的 UI 範例 GitHubCocos UI Example](https://github.com/cocos/cocos-example-ui)

View File

@@ -0,0 +1,175 @@
# CC3.WebEasyObfus
![Static Badge](https://img.shields.io/badge/Version-1.0.4-blue) ![Static Badge](https://img.shields.io/badge/CocosCreator-3.8.x-green) ![Static Badge](https://img.shields.io/badge/Tested_On-web-yellow)
虽然 CC 在建置时已经做了些混淆,但为了不让有心人一键带走项目,进一步的保护就成了钢需。与此同时,开发团队的 "老板" 会预期这是简单勾勾、选选就完成事...,这就是 WebEasyObfus 要做的事。
> *「走過路過,別錯過,點顆星星,支持我!」*
> *(注:对插件的意见反馈请至 [Cocos 中文论坛](https://forum.cocos.org/t/topic/163849)。)*
## 安装方法
1. 下载项目成 ZIP 文件。
2. 解压后将内容复制到 `${your_project_path}/extensions/web-easy-obfus`
3. 打开终端
* 输入 `cd ${your_project_path}/extensions/web-zip-bundle`
* 安装扩展依赖包 `npm install`
* 构建扩展 `npm run build`
4. 到 Editor 菜单 Extension -> Extension Manager -> Installed 启用 `web-easy-obfus`
>(*注:安装方法也可参考官方文档 [【扩展 安装与分享】](https://docs.cocos.com/creator/3.8/manual/zh/editor/extension/install.html) 。*)
## 如何使用
1. 到 Build Setting 新增 New Build Task 并选择平台 WebMobile/WebDesktop。到 Panel 中下拉找到 web-easy-obfus 选项。
* Enable启用或关闭功能。
* Include All Bundle: 包含所有Bundle
* 启用后,所有 Bundle 内的 JS 档案将进行混淆,否则只有 `assets/main/bundle.js` 下的JS档案将进行混淆。
* Select Obfus Level混淆分为五个等级等级越高混淆程度越彻底但文件体积会增大执行性能可能略受影响。
* 基础 (Minimal),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Disables converting code into a more complex control flow structure.
"controlFlowFlattening": false,
// Disables adding redundant dead code blocks.
"deadCodeInjection": false,
// Keeps global variable names unchanged.
"renameGlobals": false,
// Avoids extracting strings into a separate array for simplicity.
"stringArray": false
}
```
* 标准 (Standard),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 75% of the code.
"controlFlowFlatteningThreshold": 0.75,
// Avoids injecting unnecessary dead code.
"deadCodeInjection": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Applies string array obfuscation to 75% of strings.
"stringArrayThreshold": 0.75
}
```
* 增强 (Enhanced),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to 90% of the code.
"controlFlowFlatteningThreshold": 0.9,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 40% of places.
"deadCodeInjectionThreshold": 0.4,
// Keeps global variable names unchanged for compatibility.
"renameGlobals": false,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using Base64.
"stringArrayEncoding": ["base64"],
// Applies string array obfuscation to 90% of strings.
"stringArrayThreshold": 0.9,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* 安全 (Secure),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in 50% of places.
"deadCodeInjectionThreshold": 0.5,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings in the array using RC4 encryption.
"stringArrayEncoding": ["rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true
}
```
* 极致 (Ultimate),對 javascript-obfuscator 設定分別為:
```javascript
{
// Minifies the output code to reduce file size.
"compact": true,
// Enables control flow flattening for added complexity.
"controlFlowFlattening": true,
// Applies control flow flattening to all code.
"controlFlowFlatteningThreshold": 1,
// Adds dead code to make reverse engineering harder.
"deadCodeInjection": true,
// Inserts dead code in all possible places.
"deadCodeInjectionThreshold": 1,
// Renames global variables for better obfuscation.
"renameGlobals": true,
// Moves strings into a separate array for obfuscation.
"stringArray": true,
// Encodes strings using both Base64 and RC4 encryption.
"stringArrayEncoding": ["base64", "rc4"],
// Applies string array obfuscation to all strings.
"stringArrayThreshold": 1,
// Obfuscates object keys for added security.
"transformObjectKeys": true,
// Converts characters to Unicode escape sequences for obfuscation.
"unicodeEscapeSequence": true,
// Replaces console output calls with empty functions to hide debugging messages.
"disableConsoleOutput": true
}
```
## CI/CD
本插件天然支持 CI/CD只需從 Build Panel 导出当前平台的构建选项配置为 json 文件,用于[命令行构建](https://docs.cocos.com/creator/3.8/manual/zh/editor/publish/publish-in-command-line.html)。
## 参考文献
* [javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator)
* [Cocos Creator 官方的 UI 範例 GitHubCocos UI Example](https://github.com/cocos/cocos-example-ui)

View File

@@ -0,0 +1,52 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.compressTextures = void 0;
const fs_extra_1 = require("fs-extra");
const compressTextures = (tasks) => __awaiter(void 0, void 0, void 0, function* () {
console.debug(`Execute compress task ${tasks}`);
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
if (task.format !== 'jpg') {
continue;
}
// task.dest should change suffix before compress
task.dest = task.dest.replace('.png', '.jpg');
yield pngToJPG(task.src, task.dest, task.quality);
// The compress task have done needs to be removed from the original tasks
tasks.splice(i, 1);
i--;
}
});
exports.compressTextures = compressTextures;
function pngToJPG(src, dest, quality) {
return __awaiter(this, void 0, void 0, function* () {
const img = yield getImage(src);
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
const imageData = canvas.toDataURL('image/jpeg', quality / 100);
yield (0, fs_extra_1.outputFile)(dest, imageData);
console.debug('pngToJPG', dest);
});
}
function getImage(path) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = function () {
resolve(img);
};
img.onerror = function (err) {
reject(err);
};
img.src = path.replace('#', '%23');
});
}

View File

@@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assetHandlers = exports.configs = exports.unload = exports.load = void 0;
const global_1 = require("./global");
const load = function () {
console.debug(`${global_1.PACKAGE_NAME} load`);
};
exports.load = load;
const unload = function () {
console.debug(`${global_1.PACKAGE_NAME} unload`);
};
exports.unload = unload;
const webEasyObfusConfig = {
hooks: './hooks',
options: {
enable: {
label: `i18n:${global_1.PACKAGE_NAME}.options.enable`,
description: `i18n:${global_1.PACKAGE_NAME}.options.enable`,
default: true,
render: {
ui: 'ui-checkbox',
}
},
includeAllBundle: {
label: `i18n:${global_1.PACKAGE_NAME}.options.includeAllBundle`,
description: `i18n:${global_1.PACKAGE_NAME}.options.includeAllBundle`,
default: true,
render: {
ui: 'ui-checkbox',
}
},
selectObfusLevel: {
label: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevel`,
description: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevelDescription`,
default: 'option2',
render: {
ui: 'ui-select',
items: [
{
label: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevelOptions.option0`,
value: 'option0',
},
{
label: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevelOptions.option1`,
value: 'option1',
},
{
label: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevelOptions.option2`,
value: 'option2',
},
{
label: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevelOptions.option3`,
value: 'option3',
},
{
label: `i18n:${global_1.PACKAGE_NAME}.options.selectObfusLevelOptions.option4`,
value: 'option4',
},
],
},
},
},
};
exports.configs = {
'web-mobile': webEasyObfusConfig,
'web-desktop': webEasyObfusConfig
};
exports.assetHandlers = './asset-handlers';

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PACKAGE_NAME = void 0;
exports.PACKAGE_NAME = 'web-easy-obfus';

190
extensions/web-easy-obfus/dist/hooks.js vendored Normal file
View File

@@ -0,0 +1,190 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.onAfterMake = exports.onBeforeMake = exports.onError = exports.unload = exports.onAfterBuild = exports.onAfterCompressSettings = exports.onBeforeCompressSettings = exports.onBeforeBuild = exports.load = exports.throwError = void 0;
const path_1 = __importDefault(require("path"));
const global_1 = require("./global");
const fs = __importStar(require("fs-extra"));
const javascript_obfuscator_1 = __importDefault(require("javascript-obfuscator"));
exports.throwError = true;
const load = function () {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.load = load;
const onBeforeBuild = function (options, result) {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.onBeforeBuild = onBeforeBuild;
const onBeforeCompressSettings = function (options, result) {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.onBeforeCompressSettings = onBeforeCompressSettings;
const onAfterCompressSettings = function (options, result) {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.onAfterCompressSettings = onAfterCompressSettings;
const onAfterBuild = function (options, result) {
return __awaiter(this, void 0, void 0, function* () {
const pkgOptions = options.packages[global_1.PACKAGE_NAME];
if (pkgOptions.enable) {
let obfuscationOptions = {};
if (pkgOptions.selectObfusLevel === 'option1') {
obfuscationOptions = {
"compact": true,
"controlFlowFlattening": true,
"controlFlowFlatteningThreshold": 0.75,
"deadCodeInjection": false,
"stringArray": true,
"stringArrayThreshold": 0.75 // Applies string array obfuscation to 75% of strings.
};
}
else if (pkgOptions.selectObfusLevel === 'option2') {
obfuscationOptions = {
"compact": true,
"controlFlowFlattening": true,
"controlFlowFlatteningThreshold": 0.9,
"deadCodeInjection": true,
"deadCodeInjectionThreshold": 0.4,
"renameGlobals": false,
"stringArray": true,
"stringArrayEncoding": ["base64"],
"stringArrayThreshold": 0.9,
"transformObjectKeys": true // Obfuscates object keys for added security.
};
}
else if (pkgOptions.selectObfusLevel === 'option3') {
obfuscationOptions = {
"compact": true,
"controlFlowFlattening": true,
"controlFlowFlatteningThreshold": 1,
"deadCodeInjection": true,
"deadCodeInjectionThreshold": 0.5,
"renameGlobals": true,
"stringArray": true,
"stringArrayEncoding": ["rc4"],
"stringArrayThreshold": 1,
"transformObjectKeys": true // Obfuscates object keys for added security.
};
}
else if (pkgOptions.selectObfusLevel === 'option4') {
obfuscationOptions = {
"compact": true,
"controlFlowFlattening": true,
"controlFlowFlatteningThreshold": 1,
"deadCodeInjection": true,
"deadCodeInjectionThreshold": 1,
"renameGlobals": true,
"stringArray": true,
"stringArrayEncoding": ["base64", "rc4"],
"stringArrayThreshold": 1,
"transformObjectKeys": true,
"unicodeEscapeSequence": true,
"disableConsoleOutput": true // Replaces console output calls with empty functions to hide debugging messages.
};
}
else {
obfuscationOptions = {
"compact": true,
"controlFlowFlattening": false,
"deadCodeInjection": false,
"renameGlobals": false,
"stringArray": false // Avoids extracting strings into a separate array for simplicity.
};
}
const BUILD_DEST_DIR = result.dest;
if (pkgOptions.includeAllBundle) {
findAndObfusJSFile(path_1.default.join(BUILD_DEST_DIR, 'assets'), obfuscationOptions);
}
else {
findAndObfusJSFile(path_1.default.join(BUILD_DEST_DIR, 'assets', 'main'), obfuscationOptions);
}
}
});
};
exports.onAfterBuild = onAfterBuild;
const unload = function () {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.unload = unload;
const onError = function (options, result) {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.onError = onError;
const onBeforeMake = function (root, options) {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.onBeforeMake = onBeforeMake;
const onAfterMake = function (root, options) {
return __awaiter(this, void 0, void 0, function* () {
});
};
exports.onAfterMake = onAfterMake;
function findAndObfusJSFile(dir, options) {
const items = fs.readdirSync(dir);
for (const item of items) {
const fullPath = path_1.default.join(dir, item);
if (fs.lstatSync(fullPath).isDirectory()) {
findAndObfusJSFile(fullPath, options);
}
else if (item.endsWith('.js')) {
console.log('Found js-file:', fullPath);
fs.readFile(fullPath, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
const obfuscatedData = javascript_obfuscator_1.default.obfuscate(data, options).getObfuscatedCode();
fs.writeFile(fullPath, obfuscatedData, (err) => {
if (err) {
console.error(err);
return;
}
console.log('Obfuscated:', fullPath);
});
});
return true;
}
}
return false;
}

78
extensions/web-easy-obfus/dist/panel.js vendored Normal file
View File

@@ -0,0 +1,78 @@
'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.close = exports.ready = exports.update = exports.$ = exports.template = exports.style = void 0;
const global_1 = require("./global");
let panel;
exports.style = ``;
exports.template = `
<div class="build-plugin">
<ui-prop>
<ui-label slot="label" value="Hide Link"></ui-label>
<ui-checkbox slot="content"></ui-checkbox>
</ui-prop>
<ui-prop id="link">
<ui-label slot="label" value="Docs"></ui-label>
<ui-link slot="content" value=${Editor.Utils.Url.getDocUrl('editor/publish/custom-build-plugin.html')}></ui-link>
</ui-prop>
</div>
`;
exports.$ = {
root: '.build-plugin',
hideLink: 'ui-checkbox',
link: '#link',
};
/**
* all change of options dispatched will enter here
* @param options
* @param key
* @returns
*/
function update(options, key) {
return __awaiter(this, void 0, void 0, function* () {
if (key) {
return;
}
// when import build options, key will bey ''
init();
});
}
exports.update = update;
function ready(options) {
// @ts-ignore
panel = this;
panel.options = options;
init();
}
exports.ready = ready;
function close() {
panel.$.hideLink.removeEventListener('change', onHideLinkChange);
}
exports.close = close;
function init() {
panel.$.hideLink.value = panel.options.hideLink;
updateLink();
panel.$.hideLink.addEventListener('change', onHideLinkChange);
}
function onHideLinkChange(event) {
panel.options.hideLink = event.target.value;
// Note: dispatch the change to build panel
panel.dispatch('update', `packages.${global_1.PACKAGE_NAME}.hideLink`, panel.options.hideLink);
updateLink();
}
function updateLink() {
if (panel.options.hideLink) {
panel.$.link.style.display = 'none';
}
else {
panel.$.link.style.display = 'block';
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 KiB

View File

@@ -0,0 +1,17 @@
module.exports = {
title: "Web Easy Obfus",
description: "Easily obfuscate the project codebase!",
options: {
enable: "Enable",
includeAllBundle: "Include All Bundle",
selectObfusLevel: "Select Obfus Level",
selectObfusLevelDescription: "",
selectObfusLevelOptions: {
option0: "Minimal",
option1: "Standard",
option2: "Enhanced",
option3: "Secure",
option4: "Ultimate",
}
},
};

View File

@@ -0,0 +1,17 @@
module.exports = {
title: "Web Easy Obfus",
description: "混淆項目代码就这样简单!",
options: {
enable: "启用",
includeAllBundle: "包含所有Bundle",
selectObfusLevel: "选择混淆等级",
selectObfusLevelDescription: "",
selectObfusLevelOptions: {
option0: "基础",
option1: "标准",
option2: "增强",
option3: "安全",
option4: "极致",
}
},
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View File

@@ -0,0 +1,28 @@
{
"$schema": "./@types/schema/package/index.json",
"package_version": 2,
"name": "web-easy-obfus",
"version": "1.0.4",
"author": "ericlin09@gmail.com",
"editor": ">=3.7.1",
"type": "module",
"scripts": {
"preinstall": "node ./scripts/preinstall.js",
"build": "tsc"
},
"title": "i18n:web-easy-obfus.title",
"description": "i18n:web-easy-obfus.description",
"contributions": {
"builder": "./dist/builder.js"
},
"dependencies": {
"fs-extra": "^10.0.0",
"typescript": "^4.3.4"
},
"devDependencies": {
"@cocos/creator-types": "^3.8.3",
"@types/fs-extra": "^5.0.4",
"@types/node": "^18.17.1",
"javascript-obfuscator": "^4.1.1"
}
}