@nekosu/maa-checker 1.0.2 → 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/main.js CHANGED
@@ -2743,18 +2743,19 @@ var BundleManager = class {
2743
2743
  await this.delegate.loadFile(relativePath(this.root, file), file);
2744
2744
  }
2745
2745
  }
2746
- const resolves = this.flushResolve;
2747
- this.flushResolve = [];
2748
2746
  this.duringFlush = false;
2749
- process.nextTick(() => {
2750
- for (const func of resolves) {
2751
- func();
2752
- }
2753
- });
2754
2747
  if (this.needFlush) {
2755
2748
  setTimeout(() => {
2756
2749
  this.flush();
2757
2750
  }, 100);
2751
+ } else {
2752
+ const resolves = this.flushResolve;
2753
+ this.flushResolve = [];
2754
+ process.nextTick(() => {
2755
+ for (const func of resolves) {
2756
+ func();
2757
+ }
2758
+ });
2758
2759
  }
2759
2760
  }
2760
2761
  dispatchFlush(timeout = 100) {
@@ -4706,6 +4707,82 @@ function extractTaskRef(r) {
4706
4707
  // pkgs/pipeline-manager/src/diagnostic/diagnostic.ts
4707
4708
  function checkInterface(bundle) {
4708
4709
  const result = [];
4710
+ const layer = bundle.topLayer;
4711
+ if (layer.type === "interface") {
4712
+ const realTasks = new Set(layer.parent?.getTaskListNotUnique() ?? []);
4713
+ for (const ref of layer.mergedRefs) {
4714
+ if (ref.type === "task.entry") {
4715
+ if (!realTasks.has(ref.target)) {
4716
+ result.push({
4717
+ level: "error",
4718
+ file: ref.file,
4719
+ offset: ref.location.offset,
4720
+ length: ref.location.length,
4721
+ type: "int-unknown-entry-task",
4722
+ task: ref.target
4723
+ });
4724
+ }
4725
+ }
4726
+ }
4727
+ for (const decl of layer.mergedDecls) {
4728
+ if (decl.type === "task.decl") {
4729
+ if (!realTasks.has(decl.task)) {
4730
+ result.push({
4731
+ level: "error",
4732
+ file: decl.file,
4733
+ offset: decl.location.offset,
4734
+ length: decl.location.length,
4735
+ type: "int-override-unknown-task",
4736
+ task: decl.task
4737
+ });
4738
+ }
4739
+ }
4740
+ }
4741
+ }
4742
+ const ctrlDecls = bundle.info.decls.filter((decl) => decl.type === "interface.controller");
4743
+ const ctrls = /* @__PURE__ */ new Map();
4744
+ for (const decl of ctrlDecls) {
4745
+ if (ctrls.has(decl.name)) {
4746
+ const prev = ctrls.get(decl.name);
4747
+ result.push({
4748
+ level: "error",
4749
+ file: decl.file,
4750
+ offset: decl.location.offset,
4751
+ length: decl.location.length,
4752
+ type: "int-conflict-controller",
4753
+ ctrl: decl.name,
4754
+ previous: {
4755
+ file: prev.file,
4756
+ offset: prev.location.offset,
4757
+ length: prev.location.length
4758
+ }
4759
+ });
4760
+ } else {
4761
+ ctrls.set(decl.name, decl);
4762
+ }
4763
+ }
4764
+ const resDecls = bundle.info.decls.filter((decl) => decl.type === "interface.resource");
4765
+ const ress = /* @__PURE__ */ new Map();
4766
+ for (const decl of resDecls) {
4767
+ if (ress.has(decl.name)) {
4768
+ const prev = ress.get(decl.name);
4769
+ result.push({
4770
+ level: "error",
4771
+ file: decl.file,
4772
+ offset: decl.location.offset,
4773
+ length: decl.location.length,
4774
+ type: "int-conflict-resource",
4775
+ res: decl.name,
4776
+ previous: {
4777
+ file: prev.file,
4778
+ offset: prev.location.offset,
4779
+ length: prev.location.length
4780
+ }
4781
+ });
4782
+ } else {
4783
+ ress.set(decl.name, decl);
4784
+ }
4785
+ }
4709
4786
  const optDecls = bundle.info.decls.filter((decl) => decl.type === "interface.option");
4710
4787
  const options = /* @__PURE__ */ new Map();
4711
4788
  for (const decl of optDecls) {
@@ -4726,18 +4803,132 @@ function checkInterface(bundle) {
4726
4803
  });
4727
4804
  } else {
4728
4805
  options.set(decl.name, decl);
4806
+ if (!decl.optionType || decl.optionType === "select" || decl.optionType === "switch") {
4807
+ const caseDecls = bundle.info.decls.filter(
4808
+ (decl2) => decl2.type === "interface.case" && decl2.option === decl.name
4809
+ );
4810
+ const cases = /* @__PURE__ */ new Map();
4811
+ for (const decl2 of caseDecls) {
4812
+ if (cases.has(decl2.name)) {
4813
+ const prev = cases.get(decl2.name);
4814
+ result.push({
4815
+ level: "error",
4816
+ file: decl2.file,
4817
+ offset: decl2.location.offset,
4818
+ length: decl2.location.length,
4819
+ type: "int-conflict-case",
4820
+ option: decl.name,
4821
+ case: decl2.name,
4822
+ previous: {
4823
+ file: prev.file,
4824
+ offset: prev.location.offset,
4825
+ length: prev.location.length
4826
+ }
4827
+ });
4828
+ } else {
4829
+ cases.set(decl2.name, decl2);
4830
+ }
4831
+ }
4832
+ const caseRefs = bundle.info.refs.filter((ref) => ref.type === "interface.case").filter((ref) => ref.option === decl.name);
4833
+ for (const ref of caseRefs) {
4834
+ if (!cases.has(ref.target)) {
4835
+ result.push({
4836
+ level: "error",
4837
+ file: ref.file,
4838
+ offset: ref.location.offset,
4839
+ length: ref.location.length,
4840
+ type: "int-unknown-case",
4841
+ option: decl.name,
4842
+ case: ref.target
4843
+ });
4844
+ }
4845
+ }
4846
+ if (decl.optionType === "switch") {
4847
+ let missingYes = true;
4848
+ let missingNo = true;
4849
+ for (const [name, decl2] of cases) {
4850
+ if (name === "Yes") {
4851
+ missingYes = false;
4852
+ } else if (name === "No") {
4853
+ missingNo = false;
4854
+ } else if (name.toLowerCase() === "yes") {
4855
+ missingYes = false;
4856
+ result.push({
4857
+ level: "warning",
4858
+ file: decl2.file,
4859
+ offset: decl2.location.offset,
4860
+ length: decl2.location.length,
4861
+ type: "int-switch-should-fixed"
4862
+ });
4863
+ } else if (name.toLowerCase() === "no") {
4864
+ missingNo = false;
4865
+ result.push({
4866
+ level: "warning",
4867
+ file: decl2.file,
4868
+ offset: decl2.location.offset,
4869
+ length: decl2.location.length,
4870
+ type: "int-switch-should-fixed"
4871
+ });
4872
+ } else {
4873
+ result.push({
4874
+ level: "error",
4875
+ file: decl2.file,
4876
+ offset: decl2.location.offset,
4877
+ length: decl2.location.length,
4878
+ type: "int-switch-name-invalid"
4879
+ });
4880
+ }
4881
+ }
4882
+ if (missingYes || missingNo) {
4883
+ result.push({
4884
+ level: "error",
4885
+ file: decl.file,
4886
+ offset: decl.location.offset,
4887
+ length: decl.location.length,
4888
+ type: "int-switch-missing",
4889
+ option: decl.name,
4890
+ missingYes,
4891
+ missingNo
4892
+ });
4893
+ }
4894
+ }
4895
+ }
4729
4896
  }
4730
4897
  }
4731
- for (const ref of bundle.info.refs.filter((ref2) => ref2.type === "interface.option")) {
4732
- if (!options.has(ref.target)) {
4733
- result.push({
4734
- level: "error",
4735
- file: ref.file,
4736
- offset: ref.location.offset,
4737
- length: ref.location.length,
4738
- type: "int-unknown-option",
4739
- option: ref.target
4740
- });
4898
+ for (const ref of bundle.info.refs) {
4899
+ if (ref.type === "interface.controller") {
4900
+ if (!ctrls.has(ref.target)) {
4901
+ result.push({
4902
+ level: "error",
4903
+ file: ref.file,
4904
+ offset: ref.location.offset,
4905
+ length: ref.location.length,
4906
+ type: "int-unknown-controller",
4907
+ ctrl: ref.target
4908
+ });
4909
+ }
4910
+ } else if (ref.type === "interface.resource") {
4911
+ if (!ctrls.has(ref.target)) {
4912
+ result.push({
4913
+ level: "error",
4914
+ file: ref.file,
4915
+ offset: ref.location.offset,
4916
+ length: ref.location.length,
4917
+ type: "int-unknown-resource",
4918
+ res: ref.target
4919
+ });
4920
+ }
4921
+ } else if (ref.type === "interface.option") {
4922
+ if (!options.has(ref.target)) {
4923
+ result.push({
4924
+ level: "error",
4925
+ file: ref.file,
4926
+ offset: ref.location.offset,
4927
+ length: ref.location.length,
4928
+ type: "int-unknown-option",
4929
+ option: ref.target
4930
+ });
4931
+ }
4741
4932
  }
4742
4933
  }
4743
4934
  return result;
@@ -4899,37 +5090,6 @@ function performDiagnostic(bundle) {
4899
5090
  }
4900
5091
  }
4901
5092
  }
4902
- if (layer.type === "interface") {
4903
- const realTasks = new Set(layer.parent?.getTaskListNotUnique() ?? []);
4904
- for (const ref of refs) {
4905
- if (ref.type === "task.entry") {
4906
- if (!realTasks.has(ref.target)) {
4907
- result.push({
4908
- level: "error",
4909
- file: ref.file,
4910
- offset: ref.location.offset,
4911
- length: ref.location.length,
4912
- type: "int-unknown-entry-task",
4913
- task: ref.target
4914
- });
4915
- }
4916
- }
4917
- }
4918
- for (const decl of layer.mergedDecls) {
4919
- if (decl.type === "task.decl") {
4920
- if (!realTasks.has(decl.task)) {
4921
- result.push({
4922
- level: "error",
4923
- file: decl.file,
4924
- offset: decl.location.offset,
4925
- length: decl.location.length,
4926
- type: "int-override-unknown-task",
4927
- task: decl.task
4928
- });
4929
- }
4930
- }
4931
- }
4932
- }
4933
5093
  }
4934
5094
  result.push(...checkInterface(bundle));
4935
5095
  return result;
@@ -5134,10 +5294,18 @@ function parseInputRef(node, info, option, names, ctx) {
5134
5294
  }
5135
5295
  }
5136
5296
  function parseOptionSec(node, info, option, ctx) {
5297
+ let type = void 0;
5137
5298
  let inputNames = [];
5138
5299
  let overrideNode = null;
5139
5300
  for (const [key, obj] of parseObject(node)) {
5140
5301
  switch (key) {
5302
+ case "type":
5303
+ if (isString(obj)) {
5304
+ if (["select", "switch", "input"].includes(obj.value)) {
5305
+ type = obj.value;
5306
+ }
5307
+ }
5308
+ break;
5141
5309
  case "cases":
5142
5310
  parseCases(obj, info, option, ctx);
5143
5311
  break;
@@ -5168,16 +5336,18 @@ function parseOptionSec(node, info, option, ctx) {
5168
5336
  parseInputRef(overrideNode, info, option, names, ctx);
5169
5337
  parseOverride(overrideNode, info, ctx);
5170
5338
  }
5339
+ return type;
5171
5340
  }
5172
5341
  function parseOption(node, info, ctx) {
5173
5342
  for (const [key, obj, prop] of parseObject(node)) {
5343
+ const type = parseOptionSec(obj, info, key, ctx);
5174
5344
  info.decls.push({
5175
5345
  file: ctx.file,
5176
5346
  location: prop,
5177
5347
  type: "interface.option",
5178
- name: key
5348
+ name: key,
5349
+ optionType: type
5179
5350
  });
5180
- parseOptionSec(obj, info, key, ctx);
5181
5351
  }
5182
5352
  }
5183
5353
 
@@ -5664,7 +5834,7 @@ var InterfaceBundle = class extends import_node_events3.default {
5664
5834
  // pkgs/maa-checker/package.json
5665
5835
  var package_default = {
5666
5836
  name: "@nekosu/maa-checker",
5667
- version: "1.0.2",
5837
+ version: "1.0.4",
5668
5838
  bin: {
5669
5839
  "maa-checker": "bin/maa-checker"
5670
5840
  },
@@ -5780,6 +5950,24 @@ async function main() {
5780
5950
  case "unknown-attr":
5781
5951
  brief = `Unknown attribute \`${diag.attr}\``;
5782
5952
  break;
5953
+ case "int-conflict-controller": {
5954
+ const prelative2 = path5.relative(bundle.root, diag.previous.file);
5955
+ const [pline, pcol] = await locate(diag.previous.file, diag.previous.offset);
5956
+ brief = `Conflict controller \`${diag.ctrl}\`, previous defined in ${prelative2}:${pline}:${pcol}`;
5957
+ break;
5958
+ }
5959
+ case "int-unknown-controller":
5960
+ brief = `Unknown controlle \`${diag.ctrl}\``;
5961
+ break;
5962
+ case "int-conflict-resource": {
5963
+ const prelative2 = path5.relative(bundle.root, diag.previous.file);
5964
+ const [pline, pcol] = await locate(diag.previous.file, diag.previous.offset);
5965
+ brief = `Conflict resource \`${diag.res}\`, previous defined in ${prelative2}:${pline}:${pcol}`;
5966
+ break;
5967
+ }
5968
+ case "int-unknown-resource":
5969
+ brief = `Unknown resource \`${diag.res}\``;
5970
+ break;
5783
5971
  case "int-conflict-option": {
5784
5972
  const prelative2 = path5.relative(bundle.root, diag.previous.file);
5785
5973
  const [pline, pcol] = await locate(diag.previous.file, diag.previous.offset);
@@ -5789,6 +5977,30 @@ async function main() {
5789
5977
  case "int-unknown-option":
5790
5978
  brief = `Unknown option \`${diag.option}\``;
5791
5979
  break;
5980
+ case "int-conflict-case": {
5981
+ const prelative2 = path5.relative(bundle.root, diag.previous.file);
5982
+ const [pline, pcol] = await locate(diag.previous.file, diag.previous.offset);
5983
+ brief = `Conflict case \`${diag.case}\` for option \`${diag.option}\`, previous defined in ${prelative2}:${pline}:${pcol}`;
5984
+ break;
5985
+ }
5986
+ case "int-unknown-case":
5987
+ brief = `Unknown case \`${diag.case}\` for option \`${diag.option}\``;
5988
+ break;
5989
+ case "int-switch-name-invalid":
5990
+ brief = `Switch name invalid`;
5991
+ break;
5992
+ case "int-switch-missing":
5993
+ if (diag.missingYes && diag.missingNo) {
5994
+ brief = `Switch option missing \`Yes\` and \`No\``;
5995
+ } else if (diag.missingYes) {
5996
+ brief = `Switch option missing \`Yes\``;
5997
+ } else {
5998
+ brief = `Switch option missing \`No\``;
5999
+ }
6000
+ break;
6001
+ case "int-switch-should-fixed":
6002
+ brief = `Switch name should use \`Yes\` or \`No\``;
6003
+ break;
5792
6004
  case "int-unknown-entry-task":
5793
6005
  brief = `Unknown entry task \`${diag.task}\``;
5794
6006
  break;