quake2ts 0.0.427 → 0.0.429

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.
@@ -88,6 +88,9 @@ var Command = class {
88
88
  var CommandRegistry = class {
89
89
  constructor() {
90
90
  this.commands = /* @__PURE__ */ new Map();
91
+ this.history = [];
92
+ this.historyLimit = 64;
93
+ this.autocompleteProviders = [];
91
94
  }
92
95
  register(name, callback, description) {
93
96
  const command = new Command(name, callback, description);
@@ -97,10 +100,23 @@ var CommandRegistry = class {
97
100
  registerCommand(name, callback) {
98
101
  this.register(name, callback);
99
102
  }
103
+ registerAutocompleteProvider(provider) {
104
+ this.autocompleteProviders.push(provider);
105
+ }
100
106
  get(name) {
101
107
  return this.commands.get(name);
102
108
  }
103
109
  execute(commandString) {
110
+ const trimmed = commandString.trim();
111
+ if (trimmed.length === 0) {
112
+ return false;
113
+ }
114
+ if (this.history.length === 0 || this.history[this.history.length - 1] !== trimmed) {
115
+ this.history.push(trimmed);
116
+ if (this.history.length > this.historyLimit) {
117
+ this.history.shift();
118
+ }
119
+ }
104
120
  const parts = this.tokenize(commandString);
105
121
  if (parts.length === 0) {
106
122
  return false;
@@ -118,6 +134,26 @@ var CommandRegistry = class {
118
134
  executeCommand(cmd) {
119
135
  this.execute(cmd);
120
136
  }
137
+ getHistory() {
138
+ return [...this.history];
139
+ }
140
+ getSuggestions(prefix) {
141
+ const suggestions = /* @__PURE__ */ new Set();
142
+ for (const name of this.commands.keys()) {
143
+ if (name.startsWith(prefix)) {
144
+ suggestions.add(name);
145
+ }
146
+ }
147
+ for (const provider of this.autocompleteProviders) {
148
+ const providerSuggestions = provider();
149
+ for (const suggestion of providerSuggestions) {
150
+ if (suggestion.startsWith(prefix)) {
151
+ suggestions.add(suggestion);
152
+ }
153
+ }
154
+ }
155
+ return Array.from(suggestions).sort();
156
+ }
121
157
  tokenize(text) {
122
158
  const args = [];
123
159
  let currentArg = "";
@@ -1415,6 +1451,9 @@ var EngineHost = class {
1415
1451
  },
1416
1452
  { ...options.loop, startTimeMs: this.startTimeMs }
1417
1453
  );
1454
+ this.commands.registerAutocompleteProvider(() => {
1455
+ return this.cvars.list().map((cvar) => cvar.name);
1456
+ });
1418
1457
  }
1419
1458
  start() {
1420
1459
  if (this.started) return;