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.
- package/package.json +1 -1
- package/packages/cgame/dist/index.cjs +1 -1
- package/packages/cgame/dist/index.cjs.map +1 -1
- package/packages/cgame/dist/index.js +1 -1
- package/packages/cgame/dist/index.js.map +1 -1
- package/packages/client/dist/browser/index.global.js +10 -10
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +39 -0
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +39 -0
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +1 -1
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +39 -0
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +39 -0
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/commands.d.ts +7 -0
- package/packages/engine/dist/types/commands.d.ts.map +1 -1
- package/packages/engine/dist/types/host.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -291,6 +291,9 @@ var Command = class {
|
|
|
291
291
|
var CommandRegistry = class {
|
|
292
292
|
constructor() {
|
|
293
293
|
this.commands = /* @__PURE__ */ new Map();
|
|
294
|
+
this.history = [];
|
|
295
|
+
this.historyLimit = 64;
|
|
296
|
+
this.autocompleteProviders = [];
|
|
294
297
|
}
|
|
295
298
|
register(name, callback, description) {
|
|
296
299
|
const command = new Command(name, callback, description);
|
|
@@ -300,10 +303,23 @@ var CommandRegistry = class {
|
|
|
300
303
|
registerCommand(name, callback) {
|
|
301
304
|
this.register(name, callback);
|
|
302
305
|
}
|
|
306
|
+
registerAutocompleteProvider(provider) {
|
|
307
|
+
this.autocompleteProviders.push(provider);
|
|
308
|
+
}
|
|
303
309
|
get(name) {
|
|
304
310
|
return this.commands.get(name);
|
|
305
311
|
}
|
|
306
312
|
execute(commandString) {
|
|
313
|
+
const trimmed = commandString.trim();
|
|
314
|
+
if (trimmed.length === 0) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (this.history.length === 0 || this.history[this.history.length - 1] !== trimmed) {
|
|
318
|
+
this.history.push(trimmed);
|
|
319
|
+
if (this.history.length > this.historyLimit) {
|
|
320
|
+
this.history.shift();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
307
323
|
const parts = this.tokenize(commandString);
|
|
308
324
|
if (parts.length === 0) {
|
|
309
325
|
return false;
|
|
@@ -321,6 +337,26 @@ var CommandRegistry = class {
|
|
|
321
337
|
executeCommand(cmd) {
|
|
322
338
|
this.execute(cmd);
|
|
323
339
|
}
|
|
340
|
+
getHistory() {
|
|
341
|
+
return [...this.history];
|
|
342
|
+
}
|
|
343
|
+
getSuggestions(prefix) {
|
|
344
|
+
const suggestions = /* @__PURE__ */ new Set();
|
|
345
|
+
for (const name of this.commands.keys()) {
|
|
346
|
+
if (name.startsWith(prefix)) {
|
|
347
|
+
suggestions.add(name);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
for (const provider of this.autocompleteProviders) {
|
|
351
|
+
const providerSuggestions = provider();
|
|
352
|
+
for (const suggestion of providerSuggestions) {
|
|
353
|
+
if (suggestion.startsWith(prefix)) {
|
|
354
|
+
suggestions.add(suggestion);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return Array.from(suggestions).sort();
|
|
359
|
+
}
|
|
324
360
|
tokenize(text) {
|
|
325
361
|
const args = [];
|
|
326
362
|
let currentArg = "";
|
|
@@ -1618,6 +1654,9 @@ var EngineHost = class {
|
|
|
1618
1654
|
},
|
|
1619
1655
|
{ ...options.loop, startTimeMs: this.startTimeMs }
|
|
1620
1656
|
);
|
|
1657
|
+
this.commands.registerAutocompleteProvider(() => {
|
|
1658
|
+
return this.cvars.list().map((cvar) => cvar.name);
|
|
1659
|
+
});
|
|
1621
1660
|
}
|
|
1622
1661
|
start() {
|
|
1623
1662
|
if (this.started) return;
|