config
This commit is contained in:
parent
41d402625b
commit
af3c42f7e8
10 changed files with 170 additions and 75 deletions
|
|
@ -58,12 +58,17 @@ if (!fs.existsSync("asajs.config.js")) {
|
|||
}
|
||||
|
||||
export const config: Config = createRequire(import.meta.url)(path.resolve(process.cwd(), "asajs.config.js")).config
|
||||
export const debugMode = options["debug"] ?? false
|
||||
|
||||
export const isBuildMode = options["build"] ?? config.compiler?.enabled ?? false
|
||||
export const isLinkMode = options["link"] ?? config.compiler?.autoImport ?? false
|
||||
export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? true)
|
||||
export const buildFolder = config.compiler?.buildFolder || "build"
|
||||
export const uiBuildFolder = config.compiler?.uiBuildFolder || "asajs"
|
||||
export const isNotObfuscate = debugMode || !(config.compiler?.obfuscateStringName ?? false)
|
||||
export const allowRandomStringName = !debugMode || (config.compiler?.allowRandomStringName ?? true)
|
||||
export const namespaceCount = debugMode ? 5 : (config.compiler?.namespaceCount ?? 15)
|
||||
export const forceRandomStringLength = debugMode ? 10 : config.compiler?.forceRandomStringLength
|
||||
|
||||
export const bindingFuntions = config.binding_functions
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
import { RandomString } from "../components/Utils.js"
|
||||
|
||||
const namespaces = Array.from({ length: 15 }, () => RandomString(16))
|
||||
|
||||
export function RandomNamespace() {
|
||||
return namespaces[Math.floor(Math.random() * namespaces.length)]
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { RandomBindingString, RandomString, ResolveBinding } from "../../components/Utils.js"
|
||||
import { bs, RandomBindingString, RandomString, ResolveBinding } from "../../components/Utils.js"
|
||||
import { BindingItem } from "../../types/properties/value.js"
|
||||
import { bindingFuntions } from "../Configuration.js"
|
||||
import { isBinding, isNumber, isString } from "./Checker.js"
|
||||
|
|
@ -6,6 +6,7 @@ import { Expression, GenBinding } from "./types.js"
|
|||
|
||||
type CallbackRet = {
|
||||
genBindings?: GenBinding[]
|
||||
doNotAddParentesis?: boolean
|
||||
value: Expression
|
||||
}
|
||||
type Callback = (...args: Expression[]) => CallbackRet
|
||||
|
|
@ -239,6 +240,14 @@ export const defaultFunctions = {
|
|||
}
|
||||
},
|
||||
|
||||
bs: input_binding => {
|
||||
if (!isBinding(input_binding)) throw new Error("Invalid input binding")
|
||||
return {
|
||||
doNotAddParentesis: true,
|
||||
value: bs(<`#${string}`>input_binding),
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a translatable string
|
||||
* @param key
|
||||
|
|
|
|||
|
|
@ -407,9 +407,9 @@ export class Parser {
|
|||
if (!func) {
|
||||
return this.expect(TokenKind.WORD, "Function not found!")!
|
||||
} else {
|
||||
const { genBindings, value } = func(...params)
|
||||
const { genBindings, value, doNotAddParentesis } = func(...params)
|
||||
if (genBindings) this.genBindings.push(...genBindings)
|
||||
return `(${value})`
|
||||
return doNotAddParentesis ? value : `(${value})`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue