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
|
@@ -1850,6 +1850,9 @@ var Command = class {
|
|
|
1850
1850
|
var CommandRegistry = class {
|
|
1851
1851
|
constructor() {
|
|
1852
1852
|
this.commands = /* @__PURE__ */ new Map();
|
|
1853
|
+
this.history = [];
|
|
1854
|
+
this.historyLimit = 64;
|
|
1855
|
+
this.autocompleteProviders = [];
|
|
1853
1856
|
}
|
|
1854
1857
|
register(name, callback, description) {
|
|
1855
1858
|
const command = new Command(name, callback, description);
|
|
@@ -1859,10 +1862,23 @@ var CommandRegistry = class {
|
|
|
1859
1862
|
registerCommand(name, callback) {
|
|
1860
1863
|
this.register(name, callback);
|
|
1861
1864
|
}
|
|
1865
|
+
registerAutocompleteProvider(provider) {
|
|
1866
|
+
this.autocompleteProviders.push(provider);
|
|
1867
|
+
}
|
|
1862
1868
|
get(name) {
|
|
1863
1869
|
return this.commands.get(name);
|
|
1864
1870
|
}
|
|
1865
1871
|
execute(commandString) {
|
|
1872
|
+
const trimmed = commandString.trim();
|
|
1873
|
+
if (trimmed.length === 0) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
if (this.history.length === 0 || this.history[this.history.length - 1] !== trimmed) {
|
|
1877
|
+
this.history.push(trimmed);
|
|
1878
|
+
if (this.history.length > this.historyLimit) {
|
|
1879
|
+
this.history.shift();
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1866
1882
|
const parts = this.tokenize(commandString);
|
|
1867
1883
|
if (parts.length === 0) {
|
|
1868
1884
|
return false;
|
|
@@ -1880,6 +1896,26 @@ var CommandRegistry = class {
|
|
|
1880
1896
|
executeCommand(cmd) {
|
|
1881
1897
|
this.execute(cmd);
|
|
1882
1898
|
}
|
|
1899
|
+
getHistory() {
|
|
1900
|
+
return [...this.history];
|
|
1901
|
+
}
|
|
1902
|
+
getSuggestions(prefix) {
|
|
1903
|
+
const suggestions = /* @__PURE__ */ new Set();
|
|
1904
|
+
for (const name of this.commands.keys()) {
|
|
1905
|
+
if (name.startsWith(prefix)) {
|
|
1906
|
+
suggestions.add(name);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
for (const provider of this.autocompleteProviders) {
|
|
1910
|
+
const providerSuggestions = provider();
|
|
1911
|
+
for (const suggestion of providerSuggestions) {
|
|
1912
|
+
if (suggestion.startsWith(prefix)) {
|
|
1913
|
+
suggestions.add(suggestion);
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
return Array.from(suggestions).sort();
|
|
1918
|
+
}
|
|
1883
1919
|
tokenize(text) {
|
|
1884
1920
|
const args = [];
|
|
1885
1921
|
let currentArg = "";
|
|
@@ -3065,6 +3101,9 @@ var EngineHost = class {
|
|
|
3065
3101
|
},
|
|
3066
3102
|
{ ...options.loop, startTimeMs: this.startTimeMs }
|
|
3067
3103
|
);
|
|
3104
|
+
this.commands.registerAutocompleteProvider(() => {
|
|
3105
|
+
return this.cvars.list().map((cvar) => cvar.name);
|
|
3106
|
+
});
|
|
3068
3107
|
}
|
|
3069
3108
|
start() {
|
|
3070
3109
|
if (this.started) return;
|