luau-obfuscator 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/.github/workflows/release.yml +56 -56
  2. package/dist/index.cjs +2186 -95
  3. package/dist/index.d.cts +34 -2
  4. package/dist/index.d.ts +34 -2
  5. package/dist/index.js +2186 -95
  6. package/generated/grammers.luau +13643 -0
  7. package/generated/tests.luau +5567 -0
  8. package/package.json +2 -2
  9. package/scripts/test.js +24 -8
  10. package/{scripts/example.luau → smoketest/grammers.luau} +1174 -1174
  11. package/smoketest/tests.luau +115 -0
  12. package/src/config.ts +2 -1
  13. package/src/passes/ConstantArray.ts +90 -89
  14. package/src/passes/EncryptNumbers.ts +122 -65
  15. package/src/passes/EncryptStrings.ts +162 -82
  16. package/src/passes/GlobalMapping.ts +193 -193
  17. package/src/passes/InsertJunk.ts +184 -184
  18. package/src/passes/Minify.ts +5 -5
  19. package/src/passes/NumbersToExpressions.ts +183 -2
  20. package/src/passes/RenameVariables.ts +2 -9
  21. package/src/passes/StringsToExpressions.ts +195 -6
  22. package/src/passes/StripTypes.ts +191 -191
  23. package/src/passes/Vmify.ts +87 -0
  24. package/src/passes/WrapInFunction.ts +31 -31
  25. package/src/passes/nodeFactory.ts +36 -1
  26. package/src/passes/vmify/chunk.ts +54 -0
  27. package/src/passes/vmify/compiler.ts +1026 -0
  28. package/src/passes/vmify/names.ts +72 -0
  29. package/src/passes/vmify/opcodes.ts +80 -0
  30. package/src/passes/vmify/registers.ts +63 -0
  31. package/src/passes/vmify/runtime.ts +334 -0
  32. package/src/passes/vmify/scope-walk.ts +175 -0
  33. package/src/passes/vmify/serialize.ts +68 -0
  34. package/src/passes/walk.ts +141 -43
  35. package/src/pipeline.ts +5 -6
  36. package/tsconfig.json +20 -20
  37. package/tsup.config.ts +9 -9
  38. package/generated/final.luau +0 -1029
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "luau-obfuscator",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "luau obfuscator for roblox",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -33,6 +33,6 @@
33
33
  "typescript": "^5.0.4"
34
34
  },
35
35
  "dependencies": {
36
- "luau-parser": "^1.0.2"
36
+ "luau-parser": "^1.0.3"
37
37
  }
38
38
  }
package/scripts/test.js CHANGED
@@ -1,8 +1,24 @@
1
- import fs from 'fs'
2
- import { obfuscate } from '../dist/index.js'
3
-
4
- const exampleScript = fs.readFileSync('./scripts/example.luau', 'utf-8')
5
- const obfuscated = obfuscate(exampleScript, {
6
- Minify: {active: false}
7
- })
8
- fs.writeFileSync('./generated/final.luau', obfuscated)
1
+ import fs from 'fs'
2
+ import { obfuscate } from '../dist/index.js'
3
+ import path from 'path'
4
+
5
+ const smokedir = path.join(process.cwd(), "smoketest")
6
+
7
+ const GENERATE_DIR = path.join(process.cwd(), "generated")
8
+
9
+ fs.rmSync(GENERATE_DIR, { recursive: true, force: true });
10
+ fs.mkdirSync(GENERATE_DIR, { recursive: true });
11
+
12
+
13
+ for(const filename of fs.readdirSync(smokedir)) {
14
+ const content = fs.readFileSync(path.join(smokedir, filename), 'utf-8')
15
+ const timeStart = performance.now()
16
+ const obfuscated = obfuscate(content, {
17
+ Minify: {active: false},
18
+ NumbersToExpressions: {active: false},
19
+ StringsToExpressions: {active: false}
20
+ })
21
+ const timeEnd = performance.now()
22
+ fs.writeFileSync(path.join(GENERATE_DIR, `${filename}`), obfuscated)
23
+ console.log(`obfuscating ${filename} took ${(timeEnd - timeStart) / 1000}s, length: ${content.length} -> ${obfuscated.length}`)
24
+ }