minercon 3.0.0
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/CHANGELOG.md +439 -0
- package/LICENSE +22 -0
- package/README.md +401 -0
- package/images/icon.png +0 -0
- package/out/ansi.js +123 -0
- package/out/argumentHint.js +43 -0
- package/out/bukkitHelpParsing.js +62 -0
- package/out/cli.js +253 -0
- package/out/cliConfig.js +141 -0
- package/out/commandLine.js +28 -0
- package/out/commandSuggestions.js +202 -0
- package/out/commandTree.js +46 -0
- package/out/commandTreeCache.js +171 -0
- package/out/commandTreeCrawler.js +583 -0
- package/out/commandTreeParsingBrigadier.js +426 -0
- package/out/commandTreeParsingBukkit.js +116 -0
- package/out/commandTreeSuggestions.js +142 -0
- package/out/completionBackend.js +94 -0
- package/out/completionEngine.js +376 -0
- package/out/completionQueries.js +86 -0
- package/out/completionsBackend.js +97 -0
- package/out/connectionManager.js +209 -0
- package/out/displayArgumentHint.js +43 -0
- package/out/displayCommandTree.js +115 -0
- package/out/displaySuggestion.js +282 -0
- package/out/extension.js +190 -0
- package/out/helpTextParsing.js +445 -0
- package/out/historySearch.js +46 -0
- package/out/historyStore.js +126 -0
- package/out/lineEditor.js +525 -0
- package/out/localCommandTree.js +541 -0
- package/out/logger.js +14 -0
- package/out/minercon +253 -0
- package/out/pager.js +168 -0
- package/out/pagination.js +142 -0
- package/out/rconClient.js +97 -0
- package/out/rconConnectionManager.js +238 -0
- package/out/rconProtocol.js +421 -0
- package/out/rconSession.js +920 -0
- package/out/rconTerminal.js +80 -0
- package/out/suggestionDisplay.js +286 -0
- package/out/terminalOutput.js +110 -0
- package/out/unpaginate.js +30 -0
- package/package.json +138 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/commandTreeCache.ts
|
|
3
|
+
//
|
|
4
|
+
// On-disk persistence for the command tree `CommandTreeCrawler` builds by
|
|
5
|
+
// crawling a server's `/help` output — versioned, server-scoped, and aged out
|
|
6
|
+
// after a week so a stale tree doesn't outlive a server's command set.
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.CommandTreeCache = void 0;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
class CommandTreeCache {
|
|
45
|
+
logger;
|
|
46
|
+
report;
|
|
47
|
+
cacheDir;
|
|
48
|
+
cacheFile;
|
|
49
|
+
cacheVersion = '2.4.0'; // Bumped: Parameter is now a discriminated union (subcommands drop redundant `literal`; nodes carry optional/position)
|
|
50
|
+
serverIdentifier;
|
|
51
|
+
constructor(cacheDir, serverHost, serverPort, logger, report) {
|
|
52
|
+
this.logger = logger;
|
|
53
|
+
this.report = report;
|
|
54
|
+
this.serverIdentifier = `${serverHost}:${serverPort}`;
|
|
55
|
+
this.cacheDir = cacheDir;
|
|
56
|
+
this.cacheFile = path.join(this.cacheDir, `${serverHost}_${serverPort}.json`);
|
|
57
|
+
if (!fs.existsSync(this.cacheDir)) {
|
|
58
|
+
fs.mkdirSync(this.cacheDir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Save commands to cache
|
|
63
|
+
*/
|
|
64
|
+
save(rootCommands) {
|
|
65
|
+
try {
|
|
66
|
+
const cache = {
|
|
67
|
+
version: this.cacheVersion,
|
|
68
|
+
serverIdentifier: this.serverIdentifier,
|
|
69
|
+
lastUpdated: new Date().toISOString(),
|
|
70
|
+
commands: {}
|
|
71
|
+
};
|
|
72
|
+
rootCommands.forEach((node, name) => {
|
|
73
|
+
cache.commands[name] = node;
|
|
74
|
+
});
|
|
75
|
+
fs.writeFileSync(this.cacheFile, JSON.stringify(cache, null, 2));
|
|
76
|
+
this.report(`Command cache saved to ${this.cacheFile}`);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
this.logger.error(`Error saving cache: ${error}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Load commands from cache. Returns null if there's no usable cache
|
|
84
|
+
* (missing, version/server mismatch, or too old).
|
|
85
|
+
*/
|
|
86
|
+
load() {
|
|
87
|
+
try {
|
|
88
|
+
if (!fs.existsSync(this.cacheFile)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const cacheContent = fs.readFileSync(this.cacheFile, 'utf-8');
|
|
92
|
+
const cache = JSON.parse(cacheContent);
|
|
93
|
+
// Check cache validity
|
|
94
|
+
if (cache.version !== this.cacheVersion ||
|
|
95
|
+
cache.serverIdentifier !== this.serverIdentifier) {
|
|
96
|
+
this.report('Cache version or server mismatch, will refresh');
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
// Check age (optional - could add max age check here)
|
|
100
|
+
const cacheAge = Date.now() - new Date(cache.lastUpdated).getTime();
|
|
101
|
+
const maxAge = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
102
|
+
if (cacheAge > maxAge) {
|
|
103
|
+
this.report('Cache too old, will refresh');
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const rootCommands = new Map();
|
|
107
|
+
Object.entries(cache.commands).forEach(([name, node]) => {
|
|
108
|
+
rootCommands.set(name, node);
|
|
109
|
+
});
|
|
110
|
+
this.report(`Commands loaded from cache (${rootCommands.size} commands)`);
|
|
111
|
+
return rootCommands;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
this.logger.error(`Error loading cache: ${error}`);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get cache information
|
|
120
|
+
*/
|
|
121
|
+
getInfo() {
|
|
122
|
+
try {
|
|
123
|
+
if (!fs.existsSync(this.cacheFile)) {
|
|
124
|
+
return { exists: false, age: 'No cache' };
|
|
125
|
+
}
|
|
126
|
+
const cache = JSON.parse(fs.readFileSync(this.cacheFile, 'utf-8'));
|
|
127
|
+
if (cache.version !== this.cacheVersion || cache.serverIdentifier !== this.serverIdentifier) {
|
|
128
|
+
return { exists: false, age: 'Stale' };
|
|
129
|
+
}
|
|
130
|
+
const lastUpdated = new Date(cache.lastUpdated);
|
|
131
|
+
const ageMs = Date.now() - lastUpdated.getTime();
|
|
132
|
+
const maxAge = 7 * 24 * 60 * 60 * 1000;
|
|
133
|
+
if (ageMs > maxAge) {
|
|
134
|
+
return { exists: false, age: 'Expired' };
|
|
135
|
+
}
|
|
136
|
+
let age;
|
|
137
|
+
if (ageMs < 60000) {
|
|
138
|
+
age = 'Less than a minute';
|
|
139
|
+
}
|
|
140
|
+
else if (ageMs < 3600000) {
|
|
141
|
+
age = `${Math.floor(ageMs / 60000)} minutes`;
|
|
142
|
+
}
|
|
143
|
+
else if (ageMs < 86400000) {
|
|
144
|
+
age = `${Math.floor(ageMs / 3600000)} hours`;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
age = `${Math.floor(ageMs / 86400000)} days`;
|
|
148
|
+
}
|
|
149
|
+
return { exists: true, age, lastUpdated };
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return { exists: false, age: 'Error checking cache' };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Clear the cache
|
|
157
|
+
*/
|
|
158
|
+
clear() {
|
|
159
|
+
try {
|
|
160
|
+
if (fs.existsSync(this.cacheFile)) {
|
|
161
|
+
fs.unlinkSync(this.cacheFile);
|
|
162
|
+
this.report('Command cache cleared');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
this.logger.error(`Error clearing cache: ${error}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.CommandTreeCache = CommandTreeCache;
|
|
171
|
+
//# sourceMappingURL=commandTreeCache.js.map
|