add all of the testing
Some checks failed
/ build (node-16) (push) Failing after 33s
/ build (windows-node-iron) (push) Failing after 2m26s

This commit is contained in:
Soph :3 2025-10-20 01:23:51 +03:00
parent d5b4341487
commit 91f39a80a7
12 changed files with 485 additions and 69 deletions

View file

@ -8,16 +8,23 @@ export default class CompileTimeJS extends Plugin {
async rewriteFile(file: string, filePath: string): Promise<string> {
let input = file;
const regex = /{&(.+)&}/gms;
const regex = /\{\&([\s\S]*?)\&\}/gms;
let m;
while ((m = regex.exec(file)) !== null) {
while ((m = regex.exec(input)) !== null) {
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
input = file.slice(0, m.index) + eval(m[1]) + file.slice(m.index + m[0].length);
const before = input.slice(0, m.index);
const expr = m[1];
const after = input.slice(m.index + m[0].length);
const result = eval(expr); // You can replace this with Function() for sandboxing
input = before + result + after;
// Reset regex lastIndex since we changed the string
regex.lastIndex = 0;
}
return input;