@wq2/brigadier-ts 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.
Files changed (87) hide show
  1. package/README.md +4 -3
  2. package/dist/Command.d.ts +1 -1
  3. package/dist/CommandDispatcher.d.ts +1 -1
  4. package/dist/ParseResults.d.ts +1 -1
  5. package/dist/arguments/ArgumentType.d.ts +5 -2
  6. package/dist/arguments/ArgumentType.js +2 -2
  7. package/dist/arguments/BoolArgumentType.d.ts +4 -4
  8. package/dist/arguments/BoolArgumentType.js +3 -5
  9. package/dist/arguments/FloatArgumentType.d.ts +2 -1
  10. package/dist/arguments/FloatArgumentType.js +5 -4
  11. package/dist/arguments/IntegerArgumentType.d.ts +2 -1
  12. package/dist/arguments/IntegerArgumentType.js +5 -4
  13. package/dist/arguments/LongArgumentType.d.ts +2 -1
  14. package/dist/arguments/LongArgumentType.js +5 -4
  15. package/dist/arguments/NumberArgumentType.d.ts +3 -1
  16. package/dist/arguments/NumberArgumentType.js +2 -2
  17. package/dist/arguments/StringArgumentType.d.ts +2 -1
  18. package/dist/arguments/StringArgumentType.js +2 -2
  19. package/dist/builder/ArgumentBuilder.d.ts +5 -2
  20. package/dist/builder/ArgumentBuilder.js +4 -3
  21. package/dist/builder/LiteralArgumentBuilder.d.ts +3 -2
  22. package/dist/builder/LiteralArgumentBuilder.js +4 -3
  23. package/dist/builder/RequiredArgumentBuilder.d.ts +4 -2
  24. package/dist/builder/RequiredArgumentBuilder.js +4 -3
  25. package/dist/context/CommandContext.d.ts +8 -3
  26. package/dist/context/CommandContextBuilder.d.ts +10 -3
  27. package/dist/context/CommandContextBuilder.js +12 -9
  28. package/dist/context/ParsedArgument.d.ts +1 -1
  29. package/dist/context/ParsedArgument.js +2 -2
  30. package/dist/context/ParsedCommandNode.d.ts +2 -1
  31. package/dist/context/SuggestionContext.d.ts +1 -1
  32. package/dist/exceptions/CommandErrorType.d.ts +3 -2
  33. package/dist/exceptions/CommandErrorType.js +3 -3
  34. package/dist/exceptions/CommandSyntaxError.d.ts +1 -1
  35. package/dist/exceptions/CommandSyntaxError.js +23 -23
  36. package/dist/index.d.ts +18 -18
  37. package/dist/index.js +18 -18
  38. package/dist/suggestion/Suggestion.d.ts +1 -1
  39. package/dist/suggestion/Suggestions.d.ts +2 -1
  40. package/dist/suggestion/Suggestions.js +3 -3
  41. package/dist/suggestion/SuggestionsBuilder.d.ts +1 -1
  42. package/dist/suggestion/SuggestionsBuilder.js +5 -3
  43. package/dist/tree/ArgumentCommandNode.d.ts +12 -1
  44. package/dist/tree/ArgumentCommandNode.js +6 -3
  45. package/dist/tree/CommandNode.d.ts +16 -1
  46. package/dist/tree/CommandNode.js +10 -3
  47. package/dist/tree/LiteralCommandNode.d.ts +11 -1
  48. package/dist/tree/LiteralCommandNode.js +10 -5
  49. package/dist/tree/RootCommandNode.d.ts +6 -1
  50. package/dist/tree/RootCommandNode.js +4 -3
  51. package/dist/tree/internal.d.ts +3 -0
  52. package/dist/tree/internal.js +7 -0
  53. package/dist/tree/internal2.d.ts +6 -0
  54. package/dist/tree/internal2.js +10 -0
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +1 -1
  57. package/src/Command.ts +1 -1
  58. package/src/CommandDispatcher.ts +5 -5
  59. package/src/ParseResults.ts +1 -1
  60. package/src/arguments/ArgumentType.ts +5 -7
  61. package/src/arguments/BoolArgumentType.ts +6 -7
  62. package/src/arguments/FloatArgumentType.ts +3 -1
  63. package/src/arguments/IntegerArgumentType.ts +3 -1
  64. package/src/arguments/LongArgumentType.ts +3 -1
  65. package/src/arguments/NumberArgumentType.ts +3 -1
  66. package/src/arguments/StringArgumentType.ts +2 -1
  67. package/src/builder/ArgumentBuilder.ts +8 -8
  68. package/src/builder/LiteralArgumentBuilder.ts +3 -2
  69. package/src/builder/RequiredArgumentBuilder.ts +4 -2
  70. package/src/context/CommandContext.ts +10 -12
  71. package/src/context/CommandContextBuilder.ts +12 -14
  72. package/src/context/ParsedArgument.ts +1 -1
  73. package/src/context/ParsedCommandNode.ts +2 -1
  74. package/src/context/SuggestionContext.ts +1 -1
  75. package/src/exceptions/CommandErrorType.ts +3 -2
  76. package/src/exceptions/CommandSyntaxError.ts +1 -1
  77. package/src/index.ts +18 -18
  78. package/src/suggestion/Suggestion.ts +1 -1
  79. package/src/suggestion/Suggestions.ts +2 -1
  80. package/src/suggestion/SuggestionsBuilder.ts +3 -1
  81. package/src/tree/ArgumentCommandNode.ts +13 -13
  82. package/src/tree/CommandNode.ts +25 -17
  83. package/src/tree/LiteralCommandNode.ts +13 -13
  84. package/src/tree/RootCommandNode.ts +6 -8
  85. package/src/tree/internal.ts +9 -0
  86. package/src/tree/internal2.ts +6 -0
  87. package/test/Arguments.test.ts +3 -4
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandSyntaxError = void 0;
4
- const __1 = require("..");
4
+ const CommandErrorType_1 = require("./CommandErrorType");
5
5
  const CONTEXT_AMOUNT = 10;
6
6
  class CommandSyntaxError extends Error {
7
7
  constructor(message, input, cursor) {
@@ -19,25 +19,25 @@ class CommandSyntaxError extends Error {
19
19
  }
20
20
  }
21
21
  exports.CommandSyntaxError = CommandSyntaxError;
22
- CommandSyntaxError.DOUBLE_TOO_SMALL = new __1.CommandErrorType((found, min) => `Double must not be less than ${min}, found ${found}`);
23
- CommandSyntaxError.DOUBLE_TOO_BIG = new __1.CommandErrorType((found, max) => `Double must not be more than ${max}, found ${found}`);
24
- CommandSyntaxError.FLOAT_TOO_SMALL = new __1.CommandErrorType((found, min) => `Float must not be less than ${min}, found ${found}`);
25
- CommandSyntaxError.FLOAT_TOO_BIG = new __1.CommandErrorType((found, max) => `Float must not be more than ${max}, found ${found}`);
26
- CommandSyntaxError.INTEGER_TOO_SMALL = new __1.CommandErrorType((found, min) => `Integer must not be less than ${min}, found ${found}`);
27
- CommandSyntaxError.INTEGER_TOO_BIG = new __1.CommandErrorType((found, max) => `Integer must not be more than ${max}, found ${found}`);
28
- CommandSyntaxError.LONG_TOO_SMALL = new __1.CommandErrorType((found, min) => `Long must not be less than ${min}, found ${found}`);
29
- CommandSyntaxError.LONG_TOO_BIG = new __1.CommandErrorType((found, max) => `Long must not be more than ${max}, found ${found}`);
30
- CommandSyntaxError.LITERAL_INCORRECT = new __1.CommandErrorType((expected) => `Expected literal ${expected}`);
31
- CommandSyntaxError.READER_EXPECTED_START_OF_QUOTE = new __1.CommandErrorType(() => `Expected quote to start a string`);
32
- CommandSyntaxError.READER_EXPECTED_END_OF_QUOTE = new __1.CommandErrorType(() => `Unclosed quoted string`);
33
- CommandSyntaxError.READER_INVALID_ESCAPE = new __1.CommandErrorType((character) => `Invalid escape sequence '${character}' in quoted string`);
34
- CommandSyntaxError.READER_INVALID_BOOL = new __1.CommandErrorType((value) => `Invalid bool, expected true or false but found '${value}'`);
35
- CommandSyntaxError.READER_EXPECTED_BOOL = new __1.CommandErrorType(() => `Expected bool`);
36
- CommandSyntaxError.READER_INVALID_INT = new __1.CommandErrorType((value) => `Invalid integer '${value}'`);
37
- CommandSyntaxError.READER_EXPECTED_INT = new __1.CommandErrorType(() => `Expected integer`);
38
- CommandSyntaxError.READER_INVALID_FLOAT = new __1.CommandErrorType((value) => `Invalid float '${value}'`);
39
- CommandSyntaxError.READER_EXPECTED_FLOAT = new __1.CommandErrorType(() => `Expected float`);
40
- CommandSyntaxError.DISPATCHER_UNKNOWN_COMMAND = new __1.CommandErrorType(() => `Unknown Command`);
41
- CommandSyntaxError.DISPATCHER_UNKNOWN_ARGUMENT = new __1.CommandErrorType(() => `Incorrect argument for command`);
42
- CommandSyntaxError.DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR = new __1.CommandErrorType(() => `Expected whitespace to end one argument, but found trailing data`);
43
- CommandSyntaxError.DISPATCHER_PARSE_ERROR = new __1.CommandErrorType((message) => `Could not parse command: ${message}`);
22
+ CommandSyntaxError.DOUBLE_TOO_SMALL = new CommandErrorType_1.CommandErrorType((found, min) => `Double must not be less than ${min}, found ${found}`);
23
+ CommandSyntaxError.DOUBLE_TOO_BIG = new CommandErrorType_1.CommandErrorType((found, max) => `Double must not be more than ${max}, found ${found}`);
24
+ CommandSyntaxError.FLOAT_TOO_SMALL = new CommandErrorType_1.CommandErrorType((found, min) => `Float must not be less than ${min}, found ${found}`);
25
+ CommandSyntaxError.FLOAT_TOO_BIG = new CommandErrorType_1.CommandErrorType((found, max) => `Float must not be more than ${max}, found ${found}`);
26
+ CommandSyntaxError.INTEGER_TOO_SMALL = new CommandErrorType_1.CommandErrorType((found, min) => `Integer must not be less than ${min}, found ${found}`);
27
+ CommandSyntaxError.INTEGER_TOO_BIG = new CommandErrorType_1.CommandErrorType((found, max) => `Integer must not be more than ${max}, found ${found}`);
28
+ CommandSyntaxError.LONG_TOO_SMALL = new CommandErrorType_1.CommandErrorType((found, min) => `Long must not be less than ${min}, found ${found}`);
29
+ CommandSyntaxError.LONG_TOO_BIG = new CommandErrorType_1.CommandErrorType((found, max) => `Long must not be more than ${max}, found ${found}`);
30
+ CommandSyntaxError.LITERAL_INCORRECT = new CommandErrorType_1.CommandErrorType((expected) => `Expected literal ${expected}`);
31
+ CommandSyntaxError.READER_EXPECTED_START_OF_QUOTE = new CommandErrorType_1.CommandErrorType(() => `Expected quote to start a string`);
32
+ CommandSyntaxError.READER_EXPECTED_END_OF_QUOTE = new CommandErrorType_1.CommandErrorType(() => `Unclosed quoted string`);
33
+ CommandSyntaxError.READER_INVALID_ESCAPE = new CommandErrorType_1.CommandErrorType((character) => `Invalid escape sequence '${character}' in quoted string`);
34
+ CommandSyntaxError.READER_INVALID_BOOL = new CommandErrorType_1.CommandErrorType((value) => `Invalid bool, expected true or false but found '${value}'`);
35
+ CommandSyntaxError.READER_EXPECTED_BOOL = new CommandErrorType_1.CommandErrorType(() => `Expected bool`);
36
+ CommandSyntaxError.READER_INVALID_INT = new CommandErrorType_1.CommandErrorType((value) => `Invalid integer '${value}'`);
37
+ CommandSyntaxError.READER_EXPECTED_INT = new CommandErrorType_1.CommandErrorType(() => `Expected integer`);
38
+ CommandSyntaxError.READER_INVALID_FLOAT = new CommandErrorType_1.CommandErrorType((value) => `Invalid float '${value}'`);
39
+ CommandSyntaxError.READER_EXPECTED_FLOAT = new CommandErrorType_1.CommandErrorType(() => `Expected float`);
40
+ CommandSyntaxError.DISPATCHER_UNKNOWN_COMMAND = new CommandErrorType_1.CommandErrorType(() => `Unknown Command`);
41
+ CommandSyntaxError.DISPATCHER_UNKNOWN_ARGUMENT = new CommandErrorType_1.CommandErrorType(() => `Incorrect argument for command`);
42
+ CommandSyntaxError.DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR = new CommandErrorType_1.CommandErrorType(() => `Expected whitespace to end one argument, but found trailing data`);
43
+ CommandSyntaxError.DISPATCHER_PARSE_ERROR = new CommandErrorType_1.CommandErrorType((message) => `Could not parse command: ${message}`);
package/dist/index.d.ts CHANGED
@@ -1,30 +1,30 @@
1
- export * from "./Command";
2
- export * from "./Predicate";
3
- export * from "./context/StringRange";
4
- export * from "./exceptions/CommandErrorType";
5
- export * from "./exceptions/CommandSyntaxError";
6
- export * from "./StringReader";
7
- export * from "./suggestion/Suggestion";
8
- export * from "./suggestion/Suggestions";
9
- export * from "./suggestion/SuggestionsBuilder";
10
- export * from "./tree/CommandNode";
11
- export * from "./tree/LiteralCommandNode";
12
- export * from "./tree/ArgumentCommandNode";
13
- export * from "./tree/RootCommandNode";
14
1
  export * from "./arguments/ArgumentType";
15
- export * from "./arguments/NumberArgumentType";
2
+ export * from "./arguments/BoolArgumentType";
16
3
  export * from "./arguments/FloatArgumentType";
17
4
  export * from "./arguments/IntegerArgumentType";
18
5
  export * from "./arguments/LongArgumentType";
19
- export * from "./arguments/BoolArgumentType";
6
+ export * from "./arguments/NumberArgumentType";
20
7
  export * from "./arguments/StringArgumentType";
21
8
  export * from "./builder/ArgumentBuilder";
22
9
  export * from "./builder/LiteralArgumentBuilder";
23
10
  export * from "./builder/RequiredArgumentBuilder";
24
- export * from "./context/ParsedArgument";
25
- export * from "./context/ParsedCommandNode";
11
+ export * from "./Command";
12
+ export * from "./CommandDispatcher";
26
13
  export * from "./context/CommandContext";
27
14
  export * from "./context/CommandContextBuilder";
15
+ export * from "./context/ParsedArgument";
16
+ export * from "./context/ParsedCommandNode";
17
+ export * from "./context/StringRange";
28
18
  export * from "./context/SuggestionContext";
19
+ export * from "./exceptions/CommandErrorType";
20
+ export * from "./exceptions/CommandSyntaxError";
29
21
  export * from "./ParseResults";
30
- export * from "./CommandDispatcher";
22
+ export * from "./Predicate";
23
+ export * from "./StringReader";
24
+ export * from "./suggestion/Suggestion";
25
+ export * from "./suggestion/Suggestions";
26
+ export * from "./suggestion/SuggestionsBuilder";
27
+ export * from "./tree/ArgumentCommandNode";
28
+ export * from "./tree/CommandNode";
29
+ export * from "./tree/LiteralCommandNode";
30
+ export * from "./tree/RootCommandNode";
package/dist/index.js CHANGED
@@ -14,33 +14,33 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Command"), exports);
18
- __exportStar(require("./Predicate"), exports);
19
- __exportStar(require("./context/StringRange"), exports);
20
- __exportStar(require("./exceptions/CommandErrorType"), exports);
21
- __exportStar(require("./exceptions/CommandSyntaxError"), exports);
22
- __exportStar(require("./StringReader"), exports);
23
- __exportStar(require("./suggestion/Suggestion"), exports);
24
- __exportStar(require("./suggestion/Suggestions"), exports);
25
- __exportStar(require("./suggestion/SuggestionsBuilder"), exports);
26
- __exportStar(require("./tree/CommandNode"), exports);
27
- __exportStar(require("./tree/LiteralCommandNode"), exports);
28
- __exportStar(require("./tree/ArgumentCommandNode"), exports);
29
- __exportStar(require("./tree/RootCommandNode"), exports);
30
17
  __exportStar(require("./arguments/ArgumentType"), exports);
31
- __exportStar(require("./arguments/NumberArgumentType"), exports);
18
+ __exportStar(require("./arguments/BoolArgumentType"), exports);
32
19
  __exportStar(require("./arguments/FloatArgumentType"), exports);
33
20
  __exportStar(require("./arguments/IntegerArgumentType"), exports);
34
21
  __exportStar(require("./arguments/LongArgumentType"), exports);
35
- __exportStar(require("./arguments/BoolArgumentType"), exports);
22
+ __exportStar(require("./arguments/NumberArgumentType"), exports);
36
23
  __exportStar(require("./arguments/StringArgumentType"), exports);
37
24
  __exportStar(require("./builder/ArgumentBuilder"), exports);
38
25
  __exportStar(require("./builder/LiteralArgumentBuilder"), exports);
39
26
  __exportStar(require("./builder/RequiredArgumentBuilder"), exports);
40
- __exportStar(require("./context/ParsedArgument"), exports);
41
- __exportStar(require("./context/ParsedCommandNode"), exports);
27
+ __exportStar(require("./Command"), exports);
28
+ __exportStar(require("./CommandDispatcher"), exports);
42
29
  __exportStar(require("./context/CommandContext"), exports);
43
30
  __exportStar(require("./context/CommandContextBuilder"), exports);
31
+ __exportStar(require("./context/ParsedArgument"), exports);
32
+ __exportStar(require("./context/ParsedCommandNode"), exports);
33
+ __exportStar(require("./context/StringRange"), exports);
44
34
  __exportStar(require("./context/SuggestionContext"), exports);
35
+ __exportStar(require("./exceptions/CommandErrorType"), exports);
36
+ __exportStar(require("./exceptions/CommandSyntaxError"), exports);
45
37
  __exportStar(require("./ParseResults"), exports);
46
- __exportStar(require("./CommandDispatcher"), exports);
38
+ __exportStar(require("./Predicate"), exports);
39
+ __exportStar(require("./StringReader"), exports);
40
+ __exportStar(require("./suggestion/Suggestion"), exports);
41
+ __exportStar(require("./suggestion/Suggestions"), exports);
42
+ __exportStar(require("./suggestion/SuggestionsBuilder"), exports);
43
+ __exportStar(require("./tree/ArgumentCommandNode"), exports);
44
+ __exportStar(require("./tree/CommandNode"), exports);
45
+ __exportStar(require("./tree/LiteralCommandNode"), exports);
46
+ __exportStar(require("./tree/RootCommandNode"), exports);
@@ -1,4 +1,4 @@
1
- import type { StringRange } from "..";
1
+ import type { StringRange } from "../context/StringRange";
2
2
  export declare class Suggestion {
3
3
  private range;
4
4
  private text;
@@ -1,4 +1,5 @@
1
- import { StringRange, type Suggestion } from "..";
1
+ import { StringRange } from "../context/StringRange";
2
+ import type { Suggestion } from "./Suggestion";
2
3
  export declare class Suggestions {
3
4
  static EMPTY: Suggestions;
4
5
  private range;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Suggestions = void 0;
4
- const __1 = require("..");
4
+ const StringRange_1 = require("../context/StringRange");
5
5
  class Suggestions {
6
6
  constructor(range, suggestions) {
7
7
  this.range = range;
@@ -44,7 +44,7 @@ class Suggestions {
44
44
  start = Math.min(suggestion.getRange().getStart(), start);
45
45
  end = Math.max(suggestion.getRange().getEnd(), end);
46
46
  }
47
- const range = new __1.StringRange(start, end);
47
+ const range = new StringRange_1.StringRange(start, end);
48
48
  const texts = [];
49
49
  for (const suggestion of suggestions) {
50
50
  texts.push(suggestion.expand(command, range));
@@ -53,4 +53,4 @@ class Suggestions {
53
53
  }
54
54
  }
55
55
  exports.Suggestions = Suggestions;
56
- Suggestions.EMPTY = new Suggestions(__1.StringRange.at(0), []);
56
+ Suggestions.EMPTY = new Suggestions(StringRange_1.StringRange.at(0), []);
@@ -1,4 +1,4 @@
1
- import { Suggestions } from "..";
1
+ import { Suggestions } from "./Suggestions";
2
2
  export declare class SuggestionsBuilder {
3
3
  private input;
4
4
  private start;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SuggestionsBuilder = void 0;
4
- const __1 = require("..");
4
+ const StringRange_1 = require("../context/StringRange");
5
+ const Suggestion_1 = require("./Suggestion");
6
+ const Suggestions_1 = require("./Suggestions");
5
7
  class SuggestionsBuilder {
6
8
  constructor(input, start) {
7
9
  this.input = input;
@@ -19,7 +21,7 @@ class SuggestionsBuilder {
19
21
  return this.remaining;
20
22
  }
21
23
  build() {
22
- return __1.Suggestions.create(this.input, this.result);
24
+ return Suggestions_1.Suggestions.create(this.input, this.result);
23
25
  }
24
26
  buildPromise() {
25
27
  return Promise.resolve(this.build());
@@ -28,7 +30,7 @@ class SuggestionsBuilder {
28
30
  if (text === this.remaining) {
29
31
  return this;
30
32
  }
31
- this.result.push(new __1.Suggestion(new __1.StringRange(this.start, this.input.length), text, tooltip));
33
+ this.result.push(new Suggestion_1.Suggestion(new StringRange_1.StringRange(this.start, this.input.length), text, tooltip));
32
34
  return this;
33
35
  }
34
36
  add(other) {
@@ -1,7 +1,18 @@
1
- import { type ArgumentType, CommandNode, type StringReader, type Command, type CommandContext, type CommandContextBuilder, type Predicate, type RedirectModifier, type Suggestions, type SuggestionsBuilder } from "..";
1
+ import type { ArgumentType } from "../arguments/ArgumentType";
2
+ import type { RedirectModifier } from "../builder/ArgumentBuilder";
3
+ import type { Command } from "../Command";
4
+ import type { CommandContext } from "../context/CommandContext";
5
+ import type { CommandContextBuilder } from "../context/CommandContextBuilder";
6
+ import type { Predicate } from "../Predicate";
7
+ import type { StringReader } from "../StringReader";
8
+ import type { Suggestions } from "../suggestion/Suggestions";
9
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
10
+ import { CommandNode } from "./CommandNode";
11
+ import CommandNodeThing from "./internal2";
2
12
  export declare class ArgumentCommandNode<S, T> extends CommandNode<S> {
3
13
  name: string;
4
14
  type: ArgumentType<T>;
15
+ _thing: CommandNodeThing;
5
16
  constructor(name: string, type: ArgumentType<T>, command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean);
6
17
  getType(): ArgumentType<T>;
7
18
  parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArgumentCommandNode = void 0;
4
- const __1 = require("..");
5
- class ArgumentCommandNode extends __1.CommandNode {
4
+ const ParsedArgument_1 = require("../context/ParsedArgument");
5
+ const CommandNode_1 = require("./CommandNode");
6
+ const internal2_1 = require("./internal2");
7
+ class ArgumentCommandNode extends CommandNode_1.CommandNode {
6
8
  constructor(name, type, command, requirement, redirect, modifier, forks) {
7
9
  super(command, requirement, redirect, modifier, forks);
10
+ this._thing = internal2_1.default.ARGUMENT;
8
11
  this.name = name;
9
12
  this.type = type;
10
13
  }
@@ -14,7 +17,7 @@ class ArgumentCommandNode extends __1.CommandNode {
14
17
  parse(reader, contextBuilder) {
15
18
  const start = reader.getCursor();
16
19
  const result = this.type.parse(reader);
17
- const parsed = new __1.ParsedArgument(start, reader.getCursor(), result);
20
+ const parsed = new ParsedArgument_1.ParsedArgument(start, reader.getCursor(), result);
18
21
  contextBuilder.withArgument(this.name, parsed);
19
22
  contextBuilder.withNode(this, parsed.getRange());
20
23
  }
@@ -1,4 +1,12 @@
1
- import { type StringReader, type Command, type CommandContext, type CommandContextBuilder, type Predicate, type RedirectModifier, type SuggestionsBuilder, type Suggestions } from "..";
1
+ import type { RedirectModifier } from "../builder/ArgumentBuilder";
2
+ import type { Command } from "../Command";
3
+ import type { CommandContext } from "../context/CommandContext";
4
+ import type { CommandContextBuilder } from "../context/CommandContextBuilder";
5
+ import type { Predicate } from "../Predicate";
6
+ import type { StringReader } from "../StringReader";
7
+ import type { Suggestions } from "../suggestion/Suggestions";
8
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
9
+ import CommandNodeThing from "./internal2";
2
10
  export declare abstract class CommandNode<S> {
3
11
  private children;
4
12
  private literals;
@@ -8,6 +16,13 @@ export declare abstract class CommandNode<S> {
8
16
  private redirect;
9
17
  private modifier;
10
18
  private forks;
19
+ /**
20
+ * This is used for detecting what type of command node this is, without having circular dependencies.
21
+ * @internal
22
+ * @hidden
23
+ * @protected
24
+ */
25
+ _thing: CommandNodeThing;
11
26
  constructor(command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean);
12
27
  getCommand(): Command<S>;
13
28
  getChildren(): CommandNode<S>[];
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandNode = void 0;
4
- const __1 = require("..");
4
+ const internal2_1 = require("./internal2");
5
5
  class CommandNode {
6
6
  constructor(command, requirement, redirect, modifier, forks) {
7
+ /**
8
+ * This is used for detecting what type of command node this is, without having circular dependencies.
9
+ * @internal
10
+ * @hidden
11
+ * @protected
12
+ */
13
+ this._thing = internal2_1.default.UNSPECIFIED;
7
14
  this.children = new Map();
8
15
  this.literals = new Map();
9
16
  this.arguments = new Map();
@@ -46,10 +53,10 @@ class CommandNode {
46
53
  }
47
54
  else {
48
55
  this.children.set(node.getName(), node);
49
- if (node instanceof __1.LiteralCommandNode) {
56
+ if (node._thing === internal2_1.default.LITERAL) {
50
57
  this.literals.set(node.getName(), node);
51
58
  }
52
- else if (node instanceof __1.ArgumentCommandNode) {
59
+ else if (node._thing === internal2_1.default.ARGUMENT) {
53
60
  this.arguments.set(node.getName(), node);
54
61
  }
55
62
  }
@@ -1,6 +1,16 @@
1
- import { CommandNode, type StringReader, type Command, type CommandContext, type CommandContextBuilder, type Predicate, type RedirectModifier, Suggestions, type SuggestionsBuilder } from "..";
1
+ import type { RedirectModifier } from "../builder/ArgumentBuilder";
2
+ import type { Command } from "../Command";
3
+ import type { CommandContext } from "../context/CommandContext";
4
+ import type { CommandContextBuilder } from "../context/CommandContextBuilder";
5
+ import type { Predicate } from "../Predicate";
6
+ import type { StringReader } from "../StringReader";
7
+ import { Suggestions } from "../suggestion/Suggestions";
8
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
9
+ import { CommandNode } from "./CommandNode";
10
+ import CommandNodeThing from "./internal2";
2
11
  export declare class LiteralCommandNode<S> extends CommandNode<S> {
3
12
  private literal;
13
+ _thing: CommandNodeThing;
4
14
  constructor(literal: string, command: Command<S>, requirement: Predicate<S>, redirect: CommandNode<S>, modifier: RedirectModifier<S>, forks: boolean);
5
15
  parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
6
16
  private parseInternal;
@@ -1,20 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LiteralCommandNode = void 0;
4
- const __1 = require("..");
5
- class LiteralCommandNode extends __1.CommandNode {
4
+ const StringRange_1 = require("../context/StringRange");
5
+ const CommandSyntaxError_1 = require("../exceptions/CommandSyntaxError");
6
+ const Suggestions_1 = require("../suggestion/Suggestions");
7
+ const CommandNode_1 = require("./CommandNode");
8
+ const internal2_1 = require("./internal2");
9
+ class LiteralCommandNode extends CommandNode_1.CommandNode {
6
10
  constructor(literal, command, requirement, redirect, modifier, forks) {
7
11
  super(command, requirement, redirect, modifier, forks);
12
+ this._thing = internal2_1.default.LITERAL;
8
13
  this.literal = literal;
9
14
  }
10
15
  parse(reader, contextBuilder) {
11
16
  const start = reader.getCursor();
12
17
  const end = this.parseInternal(reader);
13
18
  if (end > -1) {
14
- contextBuilder.withNode(this, new __1.StringRange(start, end));
19
+ contextBuilder.withNode(this, new StringRange_1.StringRange(start, end));
15
20
  return;
16
21
  }
17
- throw __1.CommandSyntaxError.LITERAL_INCORRECT.createWithContext(reader, this.literal);
22
+ throw CommandSyntaxError_1.CommandSyntaxError.LITERAL_INCORRECT.createWithContext(reader, this.literal);
18
23
  }
19
24
  parseInternal(reader) {
20
25
  const start = reader.getCursor();
@@ -48,7 +53,7 @@ class LiteralCommandNode extends __1.CommandNode {
48
53
  return builder.suggest(this.literal).buildPromise();
49
54
  }
50
55
  else {
51
- return __1.Suggestions.empty();
56
+ return Suggestions_1.Suggestions.empty();
52
57
  }
53
58
  }
54
59
  }
@@ -1,4 +1,9 @@
1
- import { CommandNode, type StringReader, type CommandContextBuilder, type CommandContext, Suggestions, type SuggestionsBuilder } from "..";
1
+ import type { CommandContext } from "../context/CommandContext";
2
+ import type { CommandContextBuilder } from "../context/CommandContextBuilder";
3
+ import type { StringReader } from "../StringReader";
4
+ import { Suggestions } from "../suggestion/Suggestions";
5
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
6
+ import { CommandNode } from "./CommandNode";
2
7
  export declare class RootCommandNode<S> extends CommandNode<S> {
3
8
  constructor();
4
9
  parse(reader: StringReader, contextBuilder: CommandContextBuilder<S>): void;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RootCommandNode = void 0;
4
- const __1 = require("..");
5
- class RootCommandNode extends __1.CommandNode {
4
+ const Suggestions_1 = require("../suggestion/Suggestions");
5
+ const CommandNode_1 = require("./CommandNode");
6
+ class RootCommandNode extends CommandNode_1.CommandNode {
6
7
  constructor() {
7
8
  super(null, async (_) => true, null, (_) => null, false);
8
9
  }
@@ -19,7 +20,7 @@ class RootCommandNode extends __1.CommandNode {
19
20
  context,
20
21
  // biome-ignore lint/correctness/noUnusedFunctionParameters: no-op
21
22
  builder) {
22
- return __1.Suggestions.empty();
23
+ return Suggestions_1.Suggestions.empty();
23
24
  }
24
25
  }
25
26
  exports.RootCommandNode = RootCommandNode;
@@ -0,0 +1,3 @@
1
+ import type { ArgumentCommandNode } from "./ArgumentCommandNode";
2
+ import type { CommandNode } from "./CommandNode";
3
+ export declare function isArgumentNode<A>(n: CommandNode<A>): n is ArgumentCommandNode<A, unknown>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArgumentNode = isArgumentNode;
4
+ const internal2_1 = require("./internal2");
5
+ function isArgumentNode(n) {
6
+ return n._thing === internal2_1.default.ARGUMENT;
7
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum CommandNodeThing {
2
+ UNSPECIFIED = 0,
3
+ ARGUMENT = 1,
4
+ LITERAL = 2
5
+ }
6
+ export default CommandNodeThing;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandNodeThing = void 0;
4
+ var CommandNodeThing;
5
+ (function (CommandNodeThing) {
6
+ CommandNodeThing[CommandNodeThing["UNSPECIFIED"] = 0] = "UNSPECIFIED";
7
+ CommandNodeThing[CommandNodeThing["ARGUMENT"] = 1] = "ARGUMENT";
8
+ CommandNodeThing[CommandNodeThing["LITERAL"] = 2] = "LITERAL";
9
+ })(CommandNodeThing || (exports.CommandNodeThing = CommandNodeThing = {}));
10
+ exports.default = CommandNodeThing;
@@ -1 +1 @@
1
- {"root":["../src/Command.ts","../src/CommandDispatcher.ts","../src/ParseResults.ts","../src/Predicate.ts","../src/StringReader.ts","../src/index.ts","../src/arguments/ArgumentType.ts","../src/arguments/BoolArgumentType.ts","../src/arguments/FloatArgumentType.ts","../src/arguments/IntegerArgumentType.ts","../src/arguments/LongArgumentType.ts","../src/arguments/NumberArgumentType.ts","../src/arguments/StringArgumentType.ts","../src/builder/ArgumentBuilder.ts","../src/builder/LiteralArgumentBuilder.ts","../src/builder/RequiredArgumentBuilder.ts","../src/context/CommandContext.ts","../src/context/CommandContextBuilder.ts","../src/context/ParsedArgument.ts","../src/context/ParsedCommandNode.ts","../src/context/StringRange.ts","../src/context/SuggestionContext.ts","../src/exceptions/CommandErrorType.ts","../src/exceptions/CommandSyntaxError.ts","../src/suggestion/Suggestion.ts","../src/suggestion/Suggestions.ts","../src/suggestion/SuggestionsBuilder.ts","../src/tree/ArgumentCommandNode.ts","../src/tree/CommandNode.ts","../src/tree/LiteralCommandNode.ts","../src/tree/RootCommandNode.ts"],"version":"5.9.3"}
1
+ {"root":["../src/Command.ts","../src/CommandDispatcher.ts","../src/ParseResults.ts","../src/Predicate.ts","../src/StringReader.ts","../src/index.ts","../src/arguments/ArgumentType.ts","../src/arguments/BoolArgumentType.ts","../src/arguments/FloatArgumentType.ts","../src/arguments/IntegerArgumentType.ts","../src/arguments/LongArgumentType.ts","../src/arguments/NumberArgumentType.ts","../src/arguments/StringArgumentType.ts","../src/builder/ArgumentBuilder.ts","../src/builder/LiteralArgumentBuilder.ts","../src/builder/RequiredArgumentBuilder.ts","../src/context/CommandContext.ts","../src/context/CommandContextBuilder.ts","../src/context/ParsedArgument.ts","../src/context/ParsedCommandNode.ts","../src/context/StringRange.ts","../src/context/SuggestionContext.ts","../src/exceptions/CommandErrorType.ts","../src/exceptions/CommandSyntaxError.ts","../src/suggestion/Suggestion.ts","../src/suggestion/Suggestions.ts","../src/suggestion/SuggestionsBuilder.ts","../src/tree/ArgumentCommandNode.ts","../src/tree/CommandNode.ts","../src/tree/LiteralCommandNode.ts","../src/tree/RootCommandNode.ts","../src/tree/internal.ts","../src/tree/internal2.ts"],"version":"5.9.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wq2/brigadier-ts",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Fork of brigadier-ts with some extra changes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Command.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CommandContext } from "./";
1
+ import type { CommandContext } from "./context/CommandContext";
2
2
 
3
3
  // biome-ignore lint/suspicious/noConfusingVoidType: `return undefined` :sob:
4
4
  export type Command<S> = (c: CommandContext<S>) => Promise<number | void>;
@@ -1,12 +1,12 @@
1
1
  import {
2
- RootCommandNode,
3
- type LiteralCommandNode,
4
- StringReader,
5
- type LiteralArgumentBuilder,
6
2
  CommandContextBuilder,
7
3
  type CommandNode,
8
- ParseResults,
9
4
  CommandSyntaxError,
5
+ type LiteralArgumentBuilder,
6
+ type LiteralCommandNode,
7
+ ParseResults,
8
+ RootCommandNode,
9
+ StringReader,
10
10
  Suggestions,
11
11
  SuggestionsBuilder,
12
12
  } from ".";
@@ -1,8 +1,8 @@
1
1
  import type {
2
2
  CommandContextBuilder,
3
- StringReader,
4
3
  CommandNode,
5
4
  CommandSyntaxError,
5
+ StringReader,
6
6
  } from ".";
7
7
 
8
8
  export class ParseResults<S> {
@@ -1,16 +1,14 @@
1
- import {
2
- type StringReader,
3
- type CommandContext,
4
- Suggestions,
5
- type SuggestionsBuilder,
6
- } from "..";
1
+ import type { CommandContext } from "../context/CommandContext";
2
+ import type { StringReader } from "../StringReader";
3
+ import { Suggestions } from "../suggestion/Suggestions";
4
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
7
5
 
8
6
  export abstract class ArgumentType<T> {
9
7
  abstract parse(reader: StringReader): T;
10
8
 
11
9
  listSuggestions(
12
10
  // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
13
- context: CommandContext<any>,
11
+ context: CommandContext<unknown>,
14
12
  // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
15
13
  builder: SuggestionsBuilder,
16
14
  ): Promise<Suggestions> {
@@ -1,8 +1,8 @@
1
- import { ArgumentType } from "./ArgumentType";
2
- import type { StringReader } from "../StringReader";
3
1
  import type { CommandContext } from "../context/CommandContext";
4
- import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
2
+ import type { StringReader } from "../StringReader";
5
3
  import type { Suggestions } from "../suggestion/Suggestions";
4
+ import type { SuggestionsBuilder } from "../suggestion/SuggestionsBuilder";
5
+ import { ArgumentType } from "./ArgumentType";
6
6
 
7
7
  export class BoolArgumentType extends ArgumentType<boolean> {
8
8
  parse(reader: StringReader): boolean {
@@ -10,15 +10,14 @@ export class BoolArgumentType extends ArgumentType<boolean> {
10
10
  }
11
11
 
12
12
  listSuggestions(
13
- // biome-ignore lint/correctness/noUnusedFunctionParameters: optional override
14
- context: CommandContext<any>,
13
+ _ctx: CommandContext<unknown>,
15
14
  builder: SuggestionsBuilder,
16
15
  ): Promise<Suggestions> {
17
16
  if ("true".startsWith(builder.getRemaining().toLowerCase())) {
18
- builder.suggest("true");
17
+ return builder.suggest("true").buildPromise();
19
18
  }
20
19
  if ("false".startsWith(builder.getRemaining().toLowerCase())) {
21
- builder.suggest("false");
20
+ return builder.suggest("false").buildPromise();
22
21
  }
23
22
  return builder.buildPromise();
24
23
  }
@@ -1,4 +1,6 @@
1
- import { type StringReader, NumberArgumentType, CommandSyntaxError } from "..";
1
+ import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
2
+ import type { StringReader } from "../StringReader";
3
+ import { NumberArgumentType } from "./NumberArgumentType";
2
4
 
3
5
  export class FloatArgumentType extends NumberArgumentType {
4
6
  constructor(minimum = -Infinity, maximum = Infinity) {
@@ -1,4 +1,6 @@
1
- import { type StringReader, NumberArgumentType, CommandSyntaxError } from "..";
1
+ import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
2
+ import type { StringReader } from "../StringReader";
3
+ import { NumberArgumentType } from "./NumberArgumentType";
2
4
 
3
5
  export class IntegerArgumentType extends NumberArgumentType {
4
6
  constructor(minimum = -2147483648, maximum = 2147483647) {
@@ -1,4 +1,6 @@
1
- import { type StringReader, NumberArgumentType, CommandSyntaxError } from "..";
1
+ import { CommandSyntaxError } from "../exceptions/CommandSyntaxError";
2
+ import type { StringReader } from "../StringReader";
3
+ import { NumberArgumentType } from "./NumberArgumentType";
2
4
 
3
5
  export class LongArgumentType extends NumberArgumentType<bigint> {
4
6
  private static readonly MIN = -9223372036854775808n;
@@ -1,4 +1,6 @@
1
- import { ArgumentType, type StringReader, type CommandErrorType } from "..";
1
+ import type { CommandErrorType } from "../exceptions/CommandErrorType";
2
+ import type { StringReader } from "../StringReader";
3
+ import { ArgumentType } from "./ArgumentType";
2
4
 
3
5
  export abstract class NumberArgumentType<
4
6
  N extends number | bigint = number,
@@ -1,4 +1,5 @@
1
- import { ArgumentType, type StringReader } from "..";
1
+ import type { StringReader } from "../StringReader";
2
+ import { ArgumentType } from "./ArgumentType";
2
3
 
3
4
  type StringType = "single_word" | "quotable_phrase" | "greedy_phrase";
4
5