asajs v4.1.13
This commit is contained in:
parent
2e9de68b55
commit
3dba9225e7
5 changed files with 26 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "asajs",
|
"name": "asajs",
|
||||||
"version": "4.1.8",
|
"version": "4.1.13",
|
||||||
"description": "Create your Minecraft JSON-UI resource packs using JavaScript",
|
"description": "Create your Minecraft JSON-UI resource packs using JavaScript",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Minecraft",
|
"Minecraft",
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,9 @@ export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? tr
|
||||||
export const buildFolder = config.compiler?.buildFolder || "build"
|
export const buildFolder = config.compiler?.buildFolder || "build"
|
||||||
export const uiBuildFolder = config.compiler?.uiBuildFolder || "asajs"
|
export const uiBuildFolder = config.compiler?.uiBuildFolder || "asajs"
|
||||||
export const isNotObfuscate = debugMode || !(config.compiler?.obfuscateStringName ?? false)
|
export const isNotObfuscate = debugMode || !(config.compiler?.obfuscateStringName ?? false)
|
||||||
export const allowRandomStringName = !debugMode || (config.compiler?.allowRandomStringName ?? true)
|
export const allowRandomStringName = !(debugMode || !(config.compiler?.allowRandomStringName ?? true))
|
||||||
export const namespaceCount = debugMode ? 5 : (config.compiler?.namespaceCount ?? 15)
|
export const namespaceCount = config.compiler?.namespaceCount ?? 15
|
||||||
export const forceRandomStringLength = debugMode ? 10 : config.compiler?.forceRandomStringLength
|
export const forceRandomStringLength = config.compiler?.forceRandomStringLength
|
||||||
|
|
||||||
export const bindingFuntions = config.binding_functions
|
export const bindingFuntions = config.binding_functions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export function FormatProperties(properties: any) {
|
||||||
|
|
||||||
if (key.startsWith("$")) {
|
if (key.startsWith("$")) {
|
||||||
const [varName, varType] = key.split("|")
|
const [varName, varType] = key.split("|")
|
||||||
|
if (!varType) break
|
||||||
switch (varType) {
|
switch (varType) {
|
||||||
case "d":
|
case "d":
|
||||||
properties[`${varName}|default`] = value
|
properties[`${varName}|default`] = value
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,21 @@
|
||||||
|
import { config, isNotObfuscate, uiBuildFolder } from "../compilers/Configuration.js"
|
||||||
import { FormatAnimationProperties } from "../compilers/FormatProperties.js"
|
import { FormatAnimationProperties } from "../compilers/FormatProperties.js"
|
||||||
import { Memory } from "../compilers/Memory.js"
|
import { Memory } from "../compilers/Memory.js"
|
||||||
import { AnimType } from "../types/enums/AnimType.js"
|
import { AnimType } from "../types/enums/AnimType.js"
|
||||||
import { KeyframeAnimationProperties } from "../types/properties/element/Animation.js"
|
import { KeyframeAnimationProperties } from "../types/properties/element/Animation.js"
|
||||||
import { Animation } from "./Animation.js"
|
import { Animation } from "./Animation.js"
|
||||||
import { Class } from "./Class.js"
|
import { Class } from "./Class.js"
|
||||||
import { RandomNamespace, RandomString } from "./Utils.js"
|
import { defaultNamespace, RandomNamespace, RandomString } from "./Utils.js"
|
||||||
|
import nodepath from "path"
|
||||||
|
|
||||||
import util from "node:util"
|
import util from "node:util"
|
||||||
|
|
||||||
|
const fileExt = config.compiler?.fileExtension
|
||||||
|
? config.compiler.fileExtension.startsWith(".")
|
||||||
|
? config.compiler.fileExtension
|
||||||
|
: `.${config.compiler.fileExtension}`
|
||||||
|
: ".json"
|
||||||
|
|
||||||
export class AnimationKeyframe<T extends AnimType> extends Class {
|
export class AnimationKeyframe<T extends AnimType> extends Class {
|
||||||
readonly path: string
|
readonly path: string
|
||||||
readonly name: string
|
readonly name: string
|
||||||
|
|
@ -21,6 +29,7 @@ export class AnimationKeyframe<T extends AnimType> extends Class {
|
||||||
name?: string,
|
name?: string,
|
||||||
namespace?: string,
|
namespace?: string,
|
||||||
path?: string,
|
path?: string,
|
||||||
|
allowObfuscate?: boolean,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
|
@ -29,14 +38,16 @@ export class AnimationKeyframe<T extends AnimType> extends Class {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (namespace && !/^\w+$/.test(namespace)) {
|
if (isNotObfuscate || !(allowObfuscate ?? true)) {
|
||||||
console.error(`The '${namespace}' cannot be used as a namespace`)
|
this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16)
|
||||||
process.exit(1)
|
this.namespace = namespace || defaultNamespace || RandomNamespace()
|
||||||
|
} else {
|
||||||
|
this.name = RandomString(16)
|
||||||
|
this.namespace = RandomNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.name = name || RandomString(16)
|
if (!path) this.path = nodepath.join(uiBuildFolder, `${this.namespace}${fileExt}`)
|
||||||
this.namespace = namespace || RandomNamespace()
|
else this.path = path
|
||||||
this.path = path || `asajs/${this.namespace}.json`
|
|
||||||
|
|
||||||
Memory.add(this)
|
Memory.add(this)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -203,9 +203,9 @@ export function RandomBindingString(length: number = 16, base: number = 32, forc
|
||||||
}
|
}
|
||||||
|
|
||||||
let rndVarBind = 1
|
let rndVarBind = 1
|
||||||
export function RandomVariableBinding(length: number = 16, base: number = 32, force?: boolean): Variable {
|
export function RandomVariableString(length: number = 16, base: number = 32, force?: boolean): Variable {
|
||||||
if (force || allowRandomStringName) return `$${GenRandomString(length, base)}`
|
if (force || allowRandomStringName) return `$${GenRandomString(length, base)}`
|
||||||
else return `$${StringID}_binding_${rndVarBind++}`
|
else return `$${StringID}_variable_${rndVarBind++}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const rndMap = new Map<string, string>()
|
const rndMap = new Map<string, string>()
|
||||||
|
|
@ -244,7 +244,7 @@ export function vs(input: Variable): Variable {
|
||||||
else {
|
else {
|
||||||
if (rndMap.has(input)) return <Variable>`${rndMap.get(input)}${mode}`
|
if (rndMap.has(input)) return <Variable>`${rndMap.get(input)}${mode}`
|
||||||
else {
|
else {
|
||||||
const ret = RandomVariableBinding()
|
const ret = RandomVariableString()
|
||||||
rndMap.set(input, ret)
|
rndMap.set(input, ret)
|
||||||
return <Variable>`${ret}${mode}`
|
return <Variable>`${ret}${mode}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue