lua-obfuscator 1.0.3 → 1.0.4
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.
- package/dist/index.js +8 -3
- package/package.json +1 -1
- package/src/index.ts +7 -3
package/dist/index.js
CHANGED
|
@@ -4,7 +4,12 @@ import path from 'path';
|
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
const prometheusPath = path.join(__dirname, '../dist/prometheus');
|
|
7
|
-
|
|
7
|
+
let factory = null;
|
|
8
|
+
function getFactory() {
|
|
9
|
+
if (!factory)
|
|
10
|
+
factory = new LuaFactory();
|
|
11
|
+
return factory;
|
|
12
|
+
}
|
|
8
13
|
let mountPromise = null;
|
|
9
14
|
async function mountDirectory(dir, prefix = '') {
|
|
10
15
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
@@ -15,7 +20,7 @@ async function mountDirectory(dir, prefix = '') {
|
|
|
15
20
|
await mountDirectory(fullPath, luaPath);
|
|
16
21
|
}
|
|
17
22
|
else if (entry.name.endsWith('.lua')) {
|
|
18
|
-
await
|
|
23
|
+
await getFactory().mountFile(luaPath, fs.readFileSync(fullPath));
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|
|
@@ -30,7 +35,7 @@ function ensureMounted() {
|
|
|
30
35
|
}
|
|
31
36
|
export async function obfuscate(text, config = 'Strong', luaVersion) {
|
|
32
37
|
await ensureMounted();
|
|
33
|
-
const lua = await
|
|
38
|
+
const lua = await getFactory().createEngine();
|
|
34
39
|
try {
|
|
35
40
|
await lua.doString(`arg = {}`);
|
|
36
41
|
lua.global.set('__input_code', text);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,7 +6,11 @@ import { fileURLToPath } from 'url'
|
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
7
|
const prometheusPath = path.join(__dirname, '../dist/prometheus')
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let factory: LuaFactory | null = null
|
|
10
|
+
function getFactory(): LuaFactory {
|
|
11
|
+
if (!factory) factory = new LuaFactory()
|
|
12
|
+
return factory
|
|
13
|
+
}
|
|
10
14
|
|
|
11
15
|
let mountPromise: Promise<void> | null = null
|
|
12
16
|
|
|
@@ -18,7 +22,7 @@ async function mountDirectory(dir: string, prefix: string = ''): Promise<void> {
|
|
|
18
22
|
if (entry.isDirectory()) {
|
|
19
23
|
await mountDirectory(fullPath, luaPath)
|
|
20
24
|
} else if (entry.name.endsWith('.lua')) {
|
|
21
|
-
await
|
|
25
|
+
await getFactory().mountFile(luaPath, fs.readFileSync(fullPath))
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
}
|
|
@@ -51,7 +55,7 @@ export async function obfuscate(
|
|
|
51
55
|
): Promise<string> {
|
|
52
56
|
await ensureMounted()
|
|
53
57
|
|
|
54
|
-
const lua = await
|
|
58
|
+
const lua = await getFactory().createEngine()
|
|
55
59
|
try {
|
|
56
60
|
await lua.doString(`arg = {}`)
|
|
57
61
|
lua.global.set('__input_code', text)
|