asajs 4.1.3-indev → 4.1.3

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.
@@ -44,7 +44,7 @@ if (!fs.existsSync("asajs.config.js")) {
44
44
  else {
45
45
  fs.writeFileSync("asajs.config.js", [
46
46
  'import { RandomBindingString } from "asajs"\n',
47
- fs.readFileSync("node_modules/asajs/resources/example-config.js", "utf-8"),
47
+ fs.readFileSync(path.join(process.cwd(), "node_modules/asajs/resources/example-config.js"), "utf-8"),
48
48
  ].join("\n"));
49
49
  }
50
50
  }
@@ -11,6 +11,7 @@ export class Parser {
11
11
  genBindings = [];
12
12
  output;
13
13
  tokens;
14
+ static hasError = false;
14
15
  constructor(input, cache = new Map(), tokens) {
15
16
  this.input = input;
16
17
  this.cache = cache;
@@ -330,6 +331,7 @@ export class Parser {
330
331
  expect(kind, err) {
331
332
  const prev = this.at() || this.last();
332
333
  if (!prev || prev.kind !== kind) {
334
+ Parser.hasError = true;
333
335
  throw new Error(`\x1b[31m${this.getPointer(prev)}\n` + `[ERROR]: ${err}\x1b[0m - Expected ${TokenKind[kind]}`);
334
336
  }
335
337
  }
@@ -8,6 +8,7 @@ import { disableRSP, enableRSP } from "./installer.js";
8
8
  import { Log } from "../PreCompile.js";
9
9
  import path from "path";
10
10
  import { API_events } from "../../components/API.js";
11
+ import { Parser } from "../bindings/Parser.js";
11
12
  async function buildUI() {
12
13
  const build = Memory.build();
13
14
  build.set("ui/_ui_defs.json", {
@@ -25,7 +26,7 @@ async function buildUI() {
25
26
  const extend = value.extend;
26
27
  return [extend ? key + String(extend) : key, value];
27
28
  }))), "utf-8")
28
- .then(() => Log("INFO", `${outFile} with ${Object.keys(value).length} elements created!`));
29
+ .then(() => Log("INFO", `${outFile.replace(/\\/g, "/")} with ${Object.keys(value).length} elements created!`));
29
30
  build.delete(file);
30
31
  return file;
31
32
  }));
@@ -40,8 +41,11 @@ async function buildUI() {
40
41
  BuildCache.set("version", version).then(() => Log("INFO", "version set!")),
41
42
  fs
42
43
  .stat(`${buildFolder}/pack_icon.png`)
43
- .catch(() => fs.copyFile(isTestMode ? "resources/pack_icon.png" : "node_modules/asajs/resources/pack_icon.png", `${buildFolder}/pack_icon.png`))
44
- .then(() => Log("INFO", `${buildFolder}/pack_icon.png copied!`))
44
+ .catch(() => fs
45
+ .copyFile(isTestMode
46
+ ? "resources/pack_icon.png"
47
+ : path.join(process.cwd(), "node_modules/asajs/resources/pack_icon.png"), `${buildFolder}/pack_icon.png`)
48
+ .then(() => Log("INFO", `${buildFolder}/pack_icon.png copied!`)))
45
49
  .catch(() => Log("WARN", `cannot copy ${buildFolder}/pack_icon.png!`)),
46
50
  ]).catch(error => console.error(error));
47
51
  return out.length;
@@ -51,6 +55,10 @@ if (isBuildMode) {
51
55
  process.on("beforeExit", async () => {
52
56
  if (first) {
53
57
  first = false;
58
+ if (Parser.hasError) {
59
+ console.error();
60
+ return;
61
+ }
54
62
  await createBuildFolder();
55
63
  await buildUI();
56
64
  if (isLinkMode)
@@ -5,8 +5,14 @@ import { Operation } from "../types/enums/Operation.js";
5
5
  import { Class } from "./Class.js";
6
6
  import { RandomString, ResolveBinding } from "./Utils.js";
7
7
  import { RandomNamespace } from "../compilers/Random.js";
8
+ import nodepath from "path";
8
9
  import util from "node:util";
9
10
  import { config, uiBuildFolder } from "../compilers/Configuration.js";
11
+ const fileExt = config.compiler?.fileExtension
12
+ ? config.compiler.fileExtension.startsWith(".")
13
+ ? config.compiler.fileExtension
14
+ : `.${config.compiler.fileExtension}`
15
+ : ".json";
10
16
  export class UI extends Class {
11
17
  type;
12
18
  path;
@@ -32,7 +38,7 @@ export class UI extends Class {
32
38
  this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16);
33
39
  this.namespace = namespace || RandomNamespace();
34
40
  if (!path)
35
- this.path = `${uiBuildFolder}/${this.namespace}${config.compiler?.fileExtension ? (config.compiler.fileExtension.startsWith(".") ? config.compiler.fileExtension : `.${config.compiler.fileExtension}`) : ".json"}`;
41
+ this.path = nodepath.join(uiBuildFolder, `${this.namespace}${fileExt}`);
36
42
  else
37
43
  this.path = path;
38
44
  this.extendable = this.name.search("/") === -1;
@@ -7,6 +7,7 @@ export declare class Parser {
7
7
  genBindings: GenBinding[];
8
8
  output: Expression;
9
9
  tokens: Token[];
10
+ static hasError: boolean;
10
11
  constructor(input: string, cache?: Map<string, unknown>, tokens?: Token[]);
11
12
  static intToBin(input: string): {
12
13
  ret: `#${string}`;
@@ -15,8 +15,8 @@ export declare class AnimationKeyframe<T extends AnimType> extends Class {
15
15
  clearNext(): this;
16
16
  protected toJsonUI(): KeyframeAnimationProperties<AnimType>;
17
17
  protected toJSON(): (Partial<import("../types/properties/element/Animation.js").DurationAnimation> & import("../types/properties/element/Animation.js").KeyframeAnimationPropertiesItem) | (Partial<import("../types/properties/element/Animation.js").AsepriteFlipBookAnimation> & import("../types/properties/element/Animation.js").KeyframeAnimationPropertiesItem) | {
18
- from?: import("../types/properties/value.js").Value<number> | undefined;
19
- to?: import("../types/properties/value.js").Value<number> | undefined;
18
+ from?: import("../types/properties/value.js").Array2<string | number> | undefined;
19
+ to?: import("../types/properties/value.js").Array2<string | number> | undefined;
20
20
  duration?: import("../types/properties/value.js").Value<number> | undefined;
21
21
  easing?: import("../types/properties/value.js").Value<string | import("../index.js").Easing> | undefined;
22
22
  next?: import("../types/properties/value.js").Value<string | AnimationKeyframe<AnimType> | Animation<AnimType>>;
@@ -33,8 +33,8 @@ export declare class AnimationKeyframe<T extends AnimType> extends Class {
33
33
  wait_until_rendered_to_play?: import("../types/properties/value.js").Value<boolean>;
34
34
  anim_type: T;
35
35
  } | {
36
- from?: import("../types/properties/value.js").Array2<string | number> | undefined;
37
- to?: import("../types/properties/value.js").Array2<string | number> | undefined;
36
+ from?: import("../types/properties/value.js").Value<number> | undefined;
37
+ to?: import("../types/properties/value.js").Value<number> | undefined;
38
38
  duration?: import("../types/properties/value.js").Value<number> | undefined;
39
39
  easing?: import("../types/properties/value.js").Value<string | import("../index.js").Easing> | undefined;
40
40
  next?: import("../types/properties/value.js").Value<string | AnimationKeyframe<AnimType> | Animation<AnimType>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asajs",
3
- "version": "4.1.3-indev",
3
+ "version": "4.1.3",
4
4
  "description": "Create your Minecraft JSON-UI resource packs using JavaScript",
5
5
  "keywords": [
6
6
  "Minecraft",