citadel_cli 1.1.5 → 1.1.7
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/README.md +1 -76
- package/dist/App.test.d.ts +1 -0
- package/dist/__test-utils__/factories.d.ts +0 -2
- package/dist/citadel.es.js +523 -484
- package/dist/citadel.umd.js +9 -9
- package/dist/components/Citadel/Citadel.d.ts +1 -0
- package/dist/components/Citadel/config/types.d.ts +1 -1
- package/dist/components/Citadel/hooks/useCitadelState.d.ts +0 -2
- package/dist/components/Citadel/hooks/useCommandHistory.d.ts +2 -2
- package/dist/components/Citadel/services/__tests__/HistoryService.test.d.ts +1 -0
- package/dist/components/Citadel/storage/StorageFactory.d.ts +1 -0
- package/dist/components/Citadel/storage/__tests__/StorageFactory.test.d.ts +1 -0
- package/dist/components/Citadel/types/__tests__/help-command.test.d.ts +1 -0
- package/dist/components/Citadel/types/__tests__/state.test.d.ts +1 -0
- package/dist/components/Citadel/types/command-registry.d.ts +8 -1
- package/dist/components/Citadel/types/state.d.ts +2 -0
- package/dist/examples/runtimeConfigCommands.d.ts +12 -0
- package/dist/examples/runtimeConfigDemo.d.ts +13 -0
- package/package.json +1 -1
package/dist/citadel.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var b = (r, e, n) =>
|
|
4
|
-
import { jsx as m, jsxs as
|
|
5
|
-
import
|
|
6
|
-
import { createRoot as
|
|
7
|
-
var
|
|
8
|
-
class
|
|
1
|
+
var ye = Object.defineProperty;
|
|
2
|
+
var xe = (r, e, n) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var b = (r, e, n) => xe(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { jsx as m, jsxs as N, Fragment as ve } from "react/jsx-runtime";
|
|
5
|
+
import O, { createContext as Ce, useState as R, useEffect as A, useMemo as D, useContext as Y, useCallback as y, useReducer as Se, useRef as H } from "react";
|
|
6
|
+
import { createRoot as ke } from "react-dom/client";
|
|
7
|
+
var F = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Success = "success", r.Failure = "failure", r.Timeout = "timeout", r))(F || {});
|
|
8
|
+
class T {
|
|
9
9
|
constructor(e = Date.now()) {
|
|
10
10
|
b(this, "_status", "pending");
|
|
11
11
|
this.timestamp = e;
|
|
@@ -23,7 +23,7 @@ class U {
|
|
|
23
23
|
this._status = "timeout";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class ln extends T {
|
|
27
27
|
constructor(e, n) {
|
|
28
28
|
super(n), this.data = e;
|
|
29
29
|
}
|
|
@@ -31,7 +31,7 @@ class an extends U {
|
|
|
31
31
|
return /* @__PURE__ */ m("pre", { className: "text-gray-200", children: JSON.stringify(this.data, null, 2) });
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
class
|
|
34
|
+
class G extends T {
|
|
35
35
|
constructor(e, n) {
|
|
36
36
|
super(n), this.text = e;
|
|
37
37
|
}
|
|
@@ -39,7 +39,7 @@ class ae extends U {
|
|
|
39
39
|
return /* @__PURE__ */ m("div", { className: "text-gray-200 whitespace-pre font-mono", children: this.text });
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
class
|
|
42
|
+
class Ne extends T {
|
|
43
43
|
constructor(e, n) {
|
|
44
44
|
super(n), this.error = e, this.markFailure();
|
|
45
45
|
}
|
|
@@ -47,12 +47,12 @@ class ve extends U {
|
|
|
47
47
|
return /* @__PURE__ */ m("div", { className: "mt-1 text-red-400", children: this.error });
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
class
|
|
50
|
+
class Ee extends T {
|
|
51
51
|
render() {
|
|
52
52
|
return /* @__PURE__ */ m("div", { className: "text-gray-400", children: "..." });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
class
|
|
55
|
+
class cn extends T {
|
|
56
56
|
constructor(e, n = "", t) {
|
|
57
57
|
super(t), this.imageUrl = e, this.altText = n;
|
|
58
58
|
}
|
|
@@ -67,24 +67,27 @@ class ln extends U {
|
|
|
67
67
|
) });
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const _e = (r) => async function() {
|
|
71
71
|
const e = r.commands.filter((n) => n.fullPath[0] !== "help").map((n) => `${n.segments.map((o) => o.type === "argument" ? `<${o.name}>` : o.name).join(" ")} - ${n.description}`).sort();
|
|
72
|
-
return e.
|
|
73
|
-
|
|
72
|
+
return e.length === 0 ? new G(
|
|
73
|
+
"No commands available yet. Add some commands to get started!"
|
|
74
|
+
) : (e.push("help - Show available commands"), new G(
|
|
75
|
+
`Available Commands:
|
|
74
76
|
` + e.join(`
|
|
75
|
-
`)
|
|
76
|
-
);
|
|
77
|
+
`)
|
|
78
|
+
));
|
|
77
79
|
};
|
|
78
|
-
var
|
|
80
|
+
var Q = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.ERROR = 1] = "ERROR", r[r.WARN = 2] = "WARN", r[r.INFO = 3] = "INFO", r[r.DEBUG = 4] = "DEBUG", r[r.TRACE = 5] = "TRACE", r))(Q || {});
|
|
81
|
+
const ne = !0;
|
|
79
82
|
class C {
|
|
80
83
|
static configure(e) {
|
|
81
84
|
this.level = e.level, this.prefix = e.prefix || "[Citadel]";
|
|
82
85
|
}
|
|
83
86
|
static trace(...e) {
|
|
84
|
-
this.level >= 5 &&
|
|
87
|
+
this.level >= 5 && !ne && console.trace(this.prefix, ...e);
|
|
85
88
|
}
|
|
86
89
|
static debug(...e) {
|
|
87
|
-
this.level >= 4 &&
|
|
90
|
+
this.level >= 4 && !ne && console.debug(this.prefix, ...e);
|
|
88
91
|
}
|
|
89
92
|
static info(...e) {
|
|
90
93
|
this.level >= 3 && console.info(this.prefix, ...e);
|
|
@@ -97,14 +100,14 @@ class C {
|
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
b(C, "level", 0), b(C, "prefix", "");
|
|
100
|
-
const
|
|
103
|
+
const _ = {
|
|
101
104
|
commandTimeoutMs: 1e4,
|
|
102
105
|
cursorColor: "var(--cursor-color, #fff)",
|
|
103
106
|
cursorSpeed: 530,
|
|
104
107
|
cursorType: "blink",
|
|
105
108
|
includeHelpCommand: !0,
|
|
106
109
|
initialHeight: "40vh",
|
|
107
|
-
logLevel:
|
|
110
|
+
logLevel: Q.ERROR,
|
|
108
111
|
maxHeight: "80vh",
|
|
109
112
|
minHeight: "200",
|
|
110
113
|
outputFontSize: "0.875rem",
|
|
@@ -116,7 +119,7 @@ const z = {
|
|
|
116
119
|
maxCommands: 100
|
|
117
120
|
}
|
|
118
121
|
};
|
|
119
|
-
class
|
|
122
|
+
class de {
|
|
120
123
|
constructor(e) {
|
|
121
124
|
b(this, "config");
|
|
122
125
|
this.config = {
|
|
@@ -135,7 +138,7 @@ class ie {
|
|
|
135
138
|
await this.saveCommands(n);
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
|
-
class
|
|
141
|
+
class Ae extends de {
|
|
139
142
|
constructor(n) {
|
|
140
143
|
super(n);
|
|
141
144
|
b(this, "storageKey", "citadel_command_history");
|
|
@@ -170,7 +173,7 @@ class ke extends ie {
|
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
|
-
class
|
|
176
|
+
class te extends de {
|
|
174
177
|
constructor(n) {
|
|
175
178
|
super(n);
|
|
176
179
|
b(this, "storedCommands", []);
|
|
@@ -191,20 +194,22 @@ class Ee extends ie {
|
|
|
191
194
|
}));
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
|
-
const
|
|
197
|
+
const P = class P {
|
|
195
198
|
constructor() {
|
|
196
199
|
b(this, "currentStorage");
|
|
197
200
|
}
|
|
201
|
+
static reset() {
|
|
202
|
+
P.instance = void 0;
|
|
203
|
+
}
|
|
198
204
|
static getInstance() {
|
|
199
|
-
return
|
|
205
|
+
return P.instance || (P.instance = new P()), P.instance;
|
|
200
206
|
}
|
|
201
207
|
initializeStorage(e) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
+
try {
|
|
209
|
+
e.type === "memory" ? this.currentStorage = new te(e) : this.currentStorage = new Ae(e);
|
|
210
|
+
} catch (n) {
|
|
211
|
+
console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new te(e);
|
|
212
|
+
}
|
|
208
213
|
}
|
|
209
214
|
getStorage() {
|
|
210
215
|
if (!this.currentStorage)
|
|
@@ -212,10 +217,10 @@ const D = class D {
|
|
|
212
217
|
return this.currentStorage;
|
|
213
218
|
}
|
|
214
219
|
};
|
|
215
|
-
b(
|
|
216
|
-
let q =
|
|
217
|
-
const
|
|
218
|
-
class
|
|
220
|
+
b(P, "instance");
|
|
221
|
+
let q = P;
|
|
222
|
+
const me = async () => new G("");
|
|
223
|
+
class X {
|
|
219
224
|
constructor(e, n, t) {
|
|
220
225
|
this.type = e, this.name = n, this.description = t;
|
|
221
226
|
}
|
|
@@ -223,23 +228,23 @@ class J {
|
|
|
223
228
|
return this.name;
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
|
-
class
|
|
231
|
+
class ue extends X {
|
|
227
232
|
constructor() {
|
|
228
233
|
super("null", ">null<", "Empty segment");
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
|
-
class
|
|
236
|
+
class ze extends X {
|
|
232
237
|
constructor(e, n) {
|
|
233
238
|
super("word", e, n);
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
|
-
class
|
|
241
|
+
class W extends X {
|
|
237
242
|
constructor(e, n, t, o) {
|
|
238
243
|
super("argument", e, n), this.value = t, this.valid = o;
|
|
239
244
|
}
|
|
240
245
|
}
|
|
241
|
-
class
|
|
242
|
-
constructor(e, n, t =
|
|
246
|
+
class Ie {
|
|
247
|
+
constructor(e, n, t = me) {
|
|
243
248
|
b(this, "_segments");
|
|
244
249
|
b(this, "_description");
|
|
245
250
|
// Used by `Help` command, etc.
|
|
@@ -268,7 +273,7 @@ class Ae {
|
|
|
268
273
|
return this.fullPath.join(" ") === e.fullPath.join(" ");
|
|
269
274
|
}
|
|
270
275
|
}
|
|
271
|
-
class
|
|
276
|
+
class Z {
|
|
272
277
|
constructor() {
|
|
273
278
|
b(this, "_commands", []);
|
|
274
279
|
}
|
|
@@ -286,21 +291,31 @@ class Q {
|
|
|
286
291
|
* @param handler Async handler executed when the command is submitted; defaults to `NoopHandler`.
|
|
287
292
|
* @throws {Error} If the segment list is empty or the path collides with an existing command.
|
|
288
293
|
*/
|
|
289
|
-
addCommand(e, n, t =
|
|
294
|
+
addCommand(e, n, t = me) {
|
|
290
295
|
if (e === void 0 || e.length === 0)
|
|
291
296
|
throw new Error("Command path cannot be empty");
|
|
292
|
-
const o = new
|
|
293
|
-
const
|
|
294
|
-
(
|
|
295
|
-
).join(" "),
|
|
296
|
-
(
|
|
297
|
+
const o = new Ie(e, n, t), a = this._commands.find((i) => {
|
|
298
|
+
const c = i.segments.map(
|
|
299
|
+
(l) => l.type === "argument" ? "*" : l.name
|
|
300
|
+
).join(" "), s = e.map(
|
|
301
|
+
(l) => l.type === "argument" ? "*" : l.name
|
|
297
302
|
).join(" ");
|
|
298
|
-
return
|
|
303
|
+
return c === s;
|
|
299
304
|
});
|
|
300
|
-
if (
|
|
301
|
-
throw new Error(`Duplicate commands: '${
|
|
305
|
+
if (a)
|
|
306
|
+
throw new Error(`Duplicate commands: '${a.fullPath_s}' and '${o.fullPath_s}'`);
|
|
302
307
|
this._commands.push(o);
|
|
303
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Removes a command that exactly matches the provided path.
|
|
311
|
+
*
|
|
312
|
+
* @param path The command path to remove.
|
|
313
|
+
* @returns True if a command was removed; otherwise false.
|
|
314
|
+
*/
|
|
315
|
+
removeCommand(e) {
|
|
316
|
+
const n = e.join(" "), t = this._commands.findIndex((o) => o.fullPath.join(" ") === n);
|
|
317
|
+
return t === -1 ? !1 : (this._commands.splice(t, 1), !0);
|
|
318
|
+
}
|
|
304
319
|
/**
|
|
305
320
|
* Retrieves a command from the registry for the given path.
|
|
306
321
|
*
|
|
@@ -312,19 +327,19 @@ class Q {
|
|
|
312
327
|
const t = n.fullPath.join(" "), o = e.join(" ");
|
|
313
328
|
if (t === o)
|
|
314
329
|
return !0;
|
|
315
|
-
const
|
|
316
|
-
return
|
|
330
|
+
const i = n.segments.filter((c) => c.type === "word").map((c) => c.name);
|
|
331
|
+
return i.length === e.length && i.join(" ") === o;
|
|
317
332
|
});
|
|
318
333
|
}
|
|
319
334
|
commandExistsForPath(e) {
|
|
320
335
|
const n = this._commands.map(
|
|
321
336
|
(o) => o.segments.map(
|
|
322
|
-
(
|
|
337
|
+
(a) => a.type === "argument" ? "*" : a.name
|
|
323
338
|
).join(" ")
|
|
324
|
-
), t = e.map((o,
|
|
325
|
-
(
|
|
326
|
-
var
|
|
327
|
-
return ((
|
|
339
|
+
), t = e.map((o, a) => this._commands.some(
|
|
340
|
+
(c) => {
|
|
341
|
+
var s;
|
|
342
|
+
return ((s = c.segments[a]) == null ? void 0 : s.type) === "argument";
|
|
328
343
|
}
|
|
329
344
|
) ? "*" : o).join(" ");
|
|
330
345
|
return n.includes(t);
|
|
@@ -335,8 +350,7 @@ class Q {
|
|
|
335
350
|
* @param path The path to get completions for.
|
|
336
351
|
* @returns An array of completion strings.
|
|
337
352
|
*/
|
|
338
|
-
|
|
339
|
-
getCompletions_s(e) {
|
|
353
|
+
getCompletionNames(e) {
|
|
340
354
|
return this.getCompletions(e).map((n) => n.name);
|
|
341
355
|
}
|
|
342
356
|
/**
|
|
@@ -347,28 +361,28 @@ class Q {
|
|
|
347
361
|
*/
|
|
348
362
|
getCompletions(e) {
|
|
349
363
|
if (C.debug("[getCompletions] path: ", e), !e.length) {
|
|
350
|
-
const
|
|
351
|
-
return
|
|
352
|
-
(
|
|
364
|
+
const a = this._commands.map((s) => s.segments[0]), i = (s, l) => s.type === l.type && s.name === l.name;
|
|
365
|
+
return a.filter(
|
|
366
|
+
(s, l, h) => l === h.findIndex((p) => i(p, s))
|
|
353
367
|
);
|
|
354
368
|
}
|
|
355
369
|
const n = e.length;
|
|
356
|
-
return this._commands.filter((
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
370
|
+
return this._commands.filter((a) => {
|
|
371
|
+
const i = a.segments;
|
|
372
|
+
if (i.length <= n - 1)
|
|
359
373
|
return !1;
|
|
360
|
-
for (let
|
|
361
|
-
const
|
|
362
|
-
if (!(
|
|
374
|
+
for (let c = 0; c < n; c++) {
|
|
375
|
+
const s = e[c], l = i[c];
|
|
376
|
+
if (!(s === "*" && l.type === "argument") && s !== l.name)
|
|
363
377
|
return !1;
|
|
364
378
|
}
|
|
365
379
|
return !0;
|
|
366
|
-
}).filter((
|
|
367
|
-
const
|
|
368
|
-
return new
|
|
380
|
+
}).filter((a) => a.segments.length > n).map((a) => {
|
|
381
|
+
const i = a.segments[n], c = i.type === "argument" ? W : ze;
|
|
382
|
+
return new c(i.name, i.description);
|
|
369
383
|
}).filter(
|
|
370
|
-
(
|
|
371
|
-
(
|
|
384
|
+
(a, i, c) => i === c.findIndex(
|
|
385
|
+
(s) => s.type === a.type && s.name === a.name
|
|
372
386
|
)
|
|
373
387
|
);
|
|
374
388
|
}
|
|
@@ -376,10 +390,10 @@ class Q {
|
|
|
376
390
|
return this.getCompletions(e).length > 0;
|
|
377
391
|
}
|
|
378
392
|
}
|
|
379
|
-
class
|
|
393
|
+
class he {
|
|
380
394
|
constructor() {
|
|
381
395
|
b(this, "segments", []);
|
|
382
|
-
b(this, "nullSegment", new
|
|
396
|
+
b(this, "nullSegment", new ue());
|
|
383
397
|
b(this, "observers", []);
|
|
384
398
|
}
|
|
385
399
|
subscribe(e) {
|
|
@@ -463,147 +477,167 @@ class de {
|
|
|
463
477
|
return [...this.segments];
|
|
464
478
|
}
|
|
465
479
|
}
|
|
466
|
-
const
|
|
467
|
-
config:
|
|
468
|
-
commands: new
|
|
469
|
-
segmentStack: new
|
|
470
|
-
},
|
|
471
|
-
const [t, o] =
|
|
472
|
-
...
|
|
480
|
+
const Re = {
|
|
481
|
+
config: _,
|
|
482
|
+
commands: new Z(),
|
|
483
|
+
segmentStack: new he()
|
|
484
|
+
}, L = Ce(Re), Pe = ({ config: r = _, commandRegistry: e, children: n }) => {
|
|
485
|
+
const [t, o] = O.useState(), [a] = R(() => new he()), i = {
|
|
486
|
+
..._,
|
|
473
487
|
...r,
|
|
474
488
|
// Ensure nested objects are properly merged
|
|
475
489
|
storage: {
|
|
476
|
-
...
|
|
490
|
+
..._.storage,
|
|
477
491
|
...r.storage
|
|
478
492
|
},
|
|
479
493
|
// Ensure explicit values from config take precedence
|
|
480
|
-
cursorType: r.cursorType ??
|
|
481
|
-
cursorColor: r.cursorColor ??
|
|
482
|
-
cursorSpeed: r.cursorSpeed ??
|
|
494
|
+
cursorType: r.cursorType ?? _.cursorType,
|
|
495
|
+
cursorColor: r.cursorColor ?? _.cursorColor,
|
|
496
|
+
cursorSpeed: r.cursorSpeed ?? _.cursorSpeed,
|
|
483
497
|
showCitadelKey: r.showCitadelKey || "."
|
|
484
498
|
};
|
|
485
499
|
A(() => {
|
|
486
500
|
q.getInstance().initializeStorage(
|
|
487
|
-
|
|
501
|
+
i.storage ?? _.storage
|
|
488
502
|
), o(q.getInstance().getStorage());
|
|
489
503
|
}, []), A(() => {
|
|
490
|
-
if (e
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
504
|
+
if (e) {
|
|
505
|
+
if (i.includeHelpCommand) {
|
|
506
|
+
if (!e.commandExistsForPath(["help"])) {
|
|
507
|
+
const s = _e(e);
|
|
508
|
+
e.addCommand(
|
|
509
|
+
[{ type: "word", name: "help" }],
|
|
510
|
+
"Show available commands",
|
|
511
|
+
s
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
e.removeCommand(["help"]);
|
|
497
517
|
}
|
|
498
|
-
}, [e,
|
|
499
|
-
const
|
|
500
|
-
config:
|
|
501
|
-
commands: e || new
|
|
518
|
+
}, [e, i.includeHelpCommand]);
|
|
519
|
+
const c = D(() => ({
|
|
520
|
+
config: i,
|
|
521
|
+
commands: e || new Z(),
|
|
502
522
|
storage: t,
|
|
503
|
-
segmentStack:
|
|
504
|
-
};
|
|
505
|
-
return /* @__PURE__ */ m(
|
|
506
|
-
},
|
|
507
|
-
const r = Y(
|
|
523
|
+
segmentStack: a
|
|
524
|
+
}), [i, e, t, a]);
|
|
525
|
+
return /* @__PURE__ */ m(L.Provider, { value: c, children: n });
|
|
526
|
+
}, $ = () => {
|
|
527
|
+
const r = Y(L);
|
|
508
528
|
if (r === void 0)
|
|
509
529
|
throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
|
|
510
530
|
return r.config;
|
|
511
531
|
}, B = () => {
|
|
512
|
-
const r = Y(
|
|
532
|
+
const r = Y(L);
|
|
513
533
|
if (r === void 0)
|
|
514
534
|
throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
|
|
515
535
|
return r.commands;
|
|
516
|
-
},
|
|
517
|
-
const r = Y(
|
|
536
|
+
}, pe = () => {
|
|
537
|
+
const r = Y(L);
|
|
518
538
|
if (r === void 0)
|
|
519
539
|
throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
|
|
520
540
|
return r.storage;
|
|
521
|
-
},
|
|
522
|
-
const r = Y(
|
|
541
|
+
}, K = () => {
|
|
542
|
+
const r = Y(L);
|
|
523
543
|
if (r === void 0)
|
|
524
544
|
throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
|
|
525
545
|
return r.segmentStack;
|
|
526
|
-
}
|
|
527
|
-
class Re {
|
|
546
|
+
}, V = class V {
|
|
528
547
|
constructor(e, n) {
|
|
548
|
+
b(this, "id");
|
|
529
549
|
b(this, "timestamp");
|
|
530
550
|
b(this, "command");
|
|
531
551
|
b(this, "result");
|
|
532
|
-
this.command = e.toArray().map((t) => t.type === "argument" ? t.value || "" : t.name), this.timestamp = Date.now(), this.result = n ?? new
|
|
552
|
+
this.id = `output-${Date.now()}-${V.idCounter++}`, this.command = e.toArray().map((t) => t.type === "argument" ? t.value || "" : t.name), this.timestamp = Date.now(), this.result = n ?? new Ee();
|
|
533
553
|
}
|
|
534
|
-
}
|
|
535
|
-
|
|
554
|
+
};
|
|
555
|
+
b(V, "idCounter", 0);
|
|
556
|
+
let J = V;
|
|
557
|
+
function He(r) {
|
|
536
558
|
return {
|
|
537
559
|
commandSegments: r,
|
|
538
560
|
timestamp: Date.now()
|
|
539
561
|
};
|
|
540
562
|
}
|
|
541
|
-
function
|
|
542
|
-
const r =
|
|
563
|
+
function ge() {
|
|
564
|
+
const r = pe(), [e, n] = R({
|
|
543
565
|
storedCommands: [],
|
|
544
566
|
position: null
|
|
545
|
-
}), t =
|
|
567
|
+
}), t = y(async (c) => {
|
|
546
568
|
if (r)
|
|
547
569
|
try {
|
|
548
|
-
const
|
|
549
|
-
await r.addStoredCommand(
|
|
550
|
-
...
|
|
551
|
-
storedCommands: [...
|
|
570
|
+
const s = He(c);
|
|
571
|
+
await r.addStoredCommand(s), n((l) => ({
|
|
572
|
+
...l,
|
|
573
|
+
storedCommands: [...l.storedCommands, s],
|
|
552
574
|
position: null
|
|
553
575
|
}));
|
|
554
|
-
} catch (
|
|
555
|
-
console.warn("Failed to save command to history:",
|
|
576
|
+
} catch (s) {
|
|
577
|
+
console.warn("Failed to save command to history:", s);
|
|
556
578
|
}
|
|
557
|
-
}, [r]), o =
|
|
579
|
+
}, [r]), o = y(async () => r ? await r.getStoredCommands() : [], [r]);
|
|
558
580
|
A(() => {
|
|
559
581
|
if (!r) return;
|
|
560
582
|
(async () => {
|
|
561
583
|
try {
|
|
562
|
-
const
|
|
563
|
-
return n((
|
|
564
|
-
...
|
|
565
|
-
storedCommands:
|
|
566
|
-
})),
|
|
567
|
-
} catch (
|
|
568
|
-
console.warn("Failed to load command history:",
|
|
584
|
+
const s = await r.getStoredCommands();
|
|
585
|
+
return n((l) => ({
|
|
586
|
+
...l,
|
|
587
|
+
storedCommands: s
|
|
588
|
+
})), s;
|
|
589
|
+
} catch (s) {
|
|
590
|
+
console.warn("Failed to load command history:", s);
|
|
569
591
|
}
|
|
570
592
|
})();
|
|
571
593
|
}, [r]);
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
594
|
+
const a = y(async (c) => {
|
|
595
|
+
const s = await o();
|
|
596
|
+
if (s.length === 0)
|
|
597
|
+
return n((p) => ({
|
|
598
|
+
...p,
|
|
599
|
+
storedCommands: [],
|
|
600
|
+
position: null
|
|
601
|
+
})), { segments: null, position: null };
|
|
602
|
+
let l = null;
|
|
603
|
+
if (c === "up" ? e.position === null ? l = s.length - 1 : e.position > 0 ? l = e.position - 1 : l = 0 : e.position === null || e.position >= s.length - 1 ? l = null : l = e.position + 1, n((p) => ({
|
|
577
604
|
...p,
|
|
578
|
-
|
|
579
|
-
|
|
605
|
+
storedCommands: s,
|
|
606
|
+
position: l
|
|
607
|
+
})), l === null)
|
|
608
|
+
return {
|
|
609
|
+
segments: [],
|
|
610
|
+
position: null
|
|
611
|
+
};
|
|
612
|
+
const h = s[l];
|
|
613
|
+
return h ? {
|
|
614
|
+
segments: h.commandSegments,
|
|
615
|
+
position: l
|
|
616
|
+
} : {
|
|
580
617
|
segments: [],
|
|
581
618
|
position: null
|
|
582
|
-
} : {
|
|
583
|
-
segments: c !== null ? e.storedCommands[c].commandSegments : null,
|
|
584
|
-
position: c
|
|
585
619
|
};
|
|
586
|
-
}, [e, o]),
|
|
620
|
+
}, [e.position, o]), i = y(async () => {
|
|
587
621
|
try {
|
|
588
622
|
if (!r) return;
|
|
589
623
|
await r.clear(), n({
|
|
590
624
|
storedCommands: [],
|
|
591
625
|
position: null
|
|
592
626
|
});
|
|
593
|
-
} catch (
|
|
594
|
-
console.warn("Failed to clear command history:",
|
|
627
|
+
} catch (c) {
|
|
628
|
+
console.warn("Failed to clear command history:", c);
|
|
595
629
|
}
|
|
596
630
|
}, [r]);
|
|
597
631
|
return {
|
|
598
632
|
history: e,
|
|
599
633
|
addStoredCommand: t,
|
|
600
634
|
getStoredCommands: o,
|
|
601
|
-
navigateHistory:
|
|
602
|
-
clear:
|
|
635
|
+
navigateHistory: a,
|
|
636
|
+
clear: i
|
|
603
637
|
};
|
|
604
638
|
}
|
|
605
|
-
const
|
|
606
|
-
const r =
|
|
639
|
+
const ee = () => {
|
|
640
|
+
const r = $(), e = B(), n = ge(), t = K(), o = pe(), [a, i] = R({
|
|
607
641
|
currentInput: "",
|
|
608
642
|
isEnteringArg: !1,
|
|
609
643
|
output: [],
|
|
@@ -615,8 +649,8 @@ const X = () => {
|
|
|
615
649
|
});
|
|
616
650
|
A(() => {
|
|
617
651
|
}, [o]), A(() => {
|
|
618
|
-
|
|
619
|
-
...
|
|
652
|
+
i((s) => ({
|
|
653
|
+
...s,
|
|
620
654
|
history: {
|
|
621
655
|
commands: n.history.storedCommands,
|
|
622
656
|
position: n.history.position,
|
|
@@ -624,105 +658,100 @@ const X = () => {
|
|
|
624
658
|
}
|
|
625
659
|
}));
|
|
626
660
|
}, [n.history, o]);
|
|
627
|
-
const
|
|
628
|
-
setCurrentInput:
|
|
629
|
-
C.debug("[CitadelActions] setCurrentInput: ",
|
|
661
|
+
const c = {
|
|
662
|
+
setCurrentInput: y((s) => {
|
|
663
|
+
C.debug("[CitadelActions] setCurrentInput: ", s), i((l) => ({ ...l, currentInput: s }));
|
|
630
664
|
}, []),
|
|
631
|
-
setIsEnteringArg:
|
|
632
|
-
C.debug("[CitadelActions] setIsEnteringArg: ",
|
|
665
|
+
setIsEnteringArg: y((s) => {
|
|
666
|
+
C.debug("[CitadelActions] setIsEnteringArg: ", s), i((l) => ({ ...l, isEnteringArg: s }));
|
|
633
667
|
}, []),
|
|
634
|
-
addOutput:
|
|
635
|
-
C.debug("[CitadelActions]addOutput: ",
|
|
636
|
-
...
|
|
637
|
-
output: [...
|
|
668
|
+
addOutput: y((s) => {
|
|
669
|
+
C.debug("[CitadelActions]addOutput: ", s), i((l) => ({
|
|
670
|
+
...l,
|
|
671
|
+
output: [...l.output, s]
|
|
638
672
|
}));
|
|
639
673
|
}, []),
|
|
640
|
-
executeCommand:
|
|
641
|
-
const
|
|
642
|
-
if (!
|
|
643
|
-
console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ",
|
|
674
|
+
executeCommand: y(async () => {
|
|
675
|
+
const s = t.path(), l = e.getCommand(s);
|
|
676
|
+
if (!l) {
|
|
677
|
+
console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", s);
|
|
644
678
|
return;
|
|
645
679
|
}
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
...
|
|
649
|
-
output: [...
|
|
680
|
+
const h = new J(t);
|
|
681
|
+
i((p) => ({
|
|
682
|
+
...p,
|
|
683
|
+
output: [...p.output, h]
|
|
650
684
|
}));
|
|
651
685
|
try {
|
|
652
|
-
const
|
|
686
|
+
const p = new Promise((u, k) => {
|
|
653
687
|
setTimeout(() => {
|
|
654
|
-
|
|
688
|
+
k(new Error("Request timed out"));
|
|
655
689
|
}, r.commandTimeoutMs);
|
|
656
|
-
}),
|
|
657
|
-
|
|
658
|
-
|
|
690
|
+
}), S = t.arguments.map((u) => u.value || ""), v = await Promise.race([
|
|
691
|
+
l.handler(S),
|
|
692
|
+
p
|
|
659
693
|
]);
|
|
660
|
-
if (!(
|
|
694
|
+
if (!(v instanceof T))
|
|
661
695
|
throw new Error(
|
|
662
|
-
`The ${
|
|
696
|
+
`The ${s.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
663
697
|
For example:
|
|
664
698
|
return new JsonCommandResult({ text: "Hello World" });
|
|
665
|
-
Check the definition of the ${
|
|
699
|
+
Check the definition of the ${s.join(".")} command and update the return type for its handler.`
|
|
666
700
|
);
|
|
667
|
-
|
|
668
|
-
...
|
|
669
|
-
output:
|
|
670
|
-
(
|
|
701
|
+
v.markSuccess(), i((u) => ({
|
|
702
|
+
...u,
|
|
703
|
+
output: u.output.map(
|
|
704
|
+
(k) => k.id === h.id ? { ...k, result: v } : k
|
|
671
705
|
)
|
|
672
706
|
}));
|
|
673
|
-
} catch (
|
|
674
|
-
const
|
|
675
|
-
|
|
707
|
+
} catch (p) {
|
|
708
|
+
const S = new Ne(
|
|
709
|
+
p instanceof Error ? p.message : "Unknown error"
|
|
676
710
|
);
|
|
677
|
-
|
|
678
|
-
...
|
|
679
|
-
output:
|
|
680
|
-
(
|
|
711
|
+
S.markFailure(), i((v) => ({
|
|
712
|
+
...v,
|
|
713
|
+
output: v.output.map(
|
|
714
|
+
(u) => u.id === h.id ? { ...u, result: S } : u
|
|
681
715
|
)
|
|
682
716
|
}));
|
|
683
717
|
}
|
|
684
718
|
}, [e, r.commandTimeoutMs, t]),
|
|
685
|
-
clearHistory:
|
|
719
|
+
clearHistory: y(async () => {
|
|
686
720
|
try {
|
|
687
721
|
await n.clear();
|
|
688
|
-
} catch (
|
|
689
|
-
console.warn("Failed to clear history:",
|
|
722
|
+
} catch (s) {
|
|
723
|
+
console.warn("Failed to clear history:", s);
|
|
690
724
|
}
|
|
691
725
|
}, [n])
|
|
692
|
-
}, d = w(() => e.getCompletions_s(t.path()), [t, e]), c = w(() => e.getCompletions(t.path()), [t, e]);
|
|
693
|
-
return {
|
|
694
|
-
state: s,
|
|
695
|
-
actions: l,
|
|
696
|
-
getAvailableCommands_s: d,
|
|
697
|
-
getAvailableCommandSegments: c
|
|
698
726
|
};
|
|
699
|
-
|
|
727
|
+
return { state: a, actions: c };
|
|
728
|
+
}, Me = ({ onOpen: r, onClose: e, isVisible: n, showCitadelKey: t }) => {
|
|
700
729
|
A(() => {
|
|
701
|
-
const o = (
|
|
702
|
-
var
|
|
703
|
-
!n &&
|
|
730
|
+
const o = (a) => {
|
|
731
|
+
var i, c;
|
|
732
|
+
!n && a.key === t && !["input", "textarea"].includes(((c = (i = a.target) == null ? void 0 : i.tagName) == null ? void 0 : c.toLowerCase()) || "") && (a.preventDefault(), r()), n && a.key === "Escape" && (a.preventDefault(), e());
|
|
704
733
|
};
|
|
705
734
|
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
706
735
|
}, [r, e, n, t]);
|
|
707
|
-
}, De = "_panelContainer_1pav9_3",
|
|
736
|
+
}, De = "_panelContainer_1pav9_3", Te = "_innerContainer_1pav9_19", Ue = "_inputSection_1pav9_29", je = "_resizeHandle_1pav9_36", Fe = "_citadel_slideUp_1pav9_65", Oe = "_citadel_slideDown_1pav9_69", Le = "_inlineContainer_1pav9_73", re = {
|
|
708
737
|
panelContainer: De,
|
|
709
|
-
innerContainer:
|
|
738
|
+
innerContainer: Te,
|
|
710
739
|
inputSection: Ue,
|
|
711
|
-
resizeHandle:
|
|
712
|
-
citadel_slideUp:
|
|
713
|
-
citadel_slideDown:
|
|
714
|
-
inlineContainer:
|
|
740
|
+
resizeHandle: je,
|
|
741
|
+
citadel_slideUp: Fe,
|
|
742
|
+
citadel_slideDown: Oe,
|
|
743
|
+
inlineContainer: Le
|
|
715
744
|
}, $e = (r) => {
|
|
716
|
-
const { isVisible: e, isClosing: n, onAnimationComplete: t } = r, o =
|
|
745
|
+
const { isVisible: e, isClosing: n, onAnimationComplete: t } = r, o = D(() => e ? n ? re.slideDown : re.slideUp : "", [e, n]);
|
|
717
746
|
return A(() => {
|
|
718
747
|
if (t) {
|
|
719
|
-
const
|
|
748
|
+
const i = setTimeout(() => {
|
|
720
749
|
t();
|
|
721
750
|
}, 200);
|
|
722
|
-
return () => clearTimeout(
|
|
751
|
+
return () => clearTimeout(i);
|
|
723
752
|
}
|
|
724
753
|
}, [n, t]), {
|
|
725
|
-
style:
|
|
754
|
+
style: D(() => ({
|
|
726
755
|
opacity: e ? 1 : 0,
|
|
727
756
|
transform: e ? "translateY(0)" : n ? "translateY(100%)" : "translateY(-100%)",
|
|
728
757
|
transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
|
|
@@ -735,19 +764,19 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
735
764
|
"data-testid": "spinner",
|
|
736
765
|
className: "animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"
|
|
737
766
|
}
|
|
738
|
-
),
|
|
767
|
+
), We = ({
|
|
739
768
|
command: r,
|
|
740
769
|
timestamp: e,
|
|
741
770
|
status: n
|
|
742
|
-
}) => /* @__PURE__ */
|
|
743
|
-
/* @__PURE__ */
|
|
771
|
+
}) => /* @__PURE__ */ N("div", { className: "flex items-center gap-2 font-mono text-sm", children: [
|
|
772
|
+
/* @__PURE__ */ N("span", { className: "text-gray-200", children: [
|
|
744
773
|
"> ",
|
|
745
774
|
r.split(" ").map((t, o) => {
|
|
746
|
-
const
|
|
747
|
-
return /* @__PURE__ */
|
|
775
|
+
const a = t.startsWith("<") && t.endsWith(">");
|
|
776
|
+
return /* @__PURE__ */ N(
|
|
748
777
|
"span",
|
|
749
778
|
{
|
|
750
|
-
className:
|
|
779
|
+
className: a ? "text-green-400" : "text-gray-200",
|
|
751
780
|
children: [
|
|
752
781
|
o > 0 ? " " : "",
|
|
753
782
|
t
|
|
@@ -759,23 +788,23 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
759
788
|
] }),
|
|
760
789
|
/* @__PURE__ */ m("span", { className: "text-gray-400", children: "·" }),
|
|
761
790
|
/* @__PURE__ */ m("span", { className: "text-gray-500", children: e }),
|
|
762
|
-
n ===
|
|
763
|
-
n ===
|
|
791
|
+
n === F.Pending && /* @__PURE__ */ m(Ke, {}),
|
|
792
|
+
n === F.Success && /* @__PURE__ */ m(
|
|
764
793
|
"div",
|
|
765
794
|
{
|
|
766
795
|
"data-testid": "success-indicator",
|
|
767
796
|
className: "w-4 h-4 rounded-full bg-green-500"
|
|
768
797
|
}
|
|
769
798
|
),
|
|
770
|
-
(n ===
|
|
799
|
+
(n === F.Timeout || n === F.Failure) && /* @__PURE__ */ m(
|
|
771
800
|
"div",
|
|
772
801
|
{
|
|
773
802
|
"data-testid": "success-indicator",
|
|
774
803
|
className: "w-4 h-4 rounded-full bg-red-500"
|
|
775
804
|
}
|
|
776
805
|
)
|
|
777
|
-
] }),
|
|
778
|
-
const n =
|
|
806
|
+
] }), qe = ({ output: r, outputRef: e }) => {
|
|
807
|
+
const n = $(), t = y(() => {
|
|
779
808
|
if (e.current) {
|
|
780
809
|
const o = e.current;
|
|
781
810
|
requestAnimationFrame(() => {
|
|
@@ -785,9 +814,9 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
785
814
|
}, [e]);
|
|
786
815
|
return A(() => {
|
|
787
816
|
if (t(), e.current) {
|
|
788
|
-
const o = e.current.getElementsByTagName("img"),
|
|
789
|
-
if (
|
|
790
|
-
return
|
|
817
|
+
const o = e.current.getElementsByTagName("img"), a = o[o.length - 1];
|
|
818
|
+
if (a && !a.complete)
|
|
819
|
+
return a.addEventListener("load", t), () => a.removeEventListener("load", t);
|
|
791
820
|
}
|
|
792
821
|
}, [r, t, e]), /* @__PURE__ */ m(
|
|
793
822
|
"div",
|
|
@@ -795,9 +824,9 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
795
824
|
ref: e,
|
|
796
825
|
className: "h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",
|
|
797
826
|
"data-testid": "citadel-command-output",
|
|
798
|
-
children: r.map((o
|
|
827
|
+
children: r.map((o) => /* @__PURE__ */ N("div", { className: "mb-4 last:mb-0", children: [
|
|
799
828
|
/* @__PURE__ */ m(
|
|
800
|
-
|
|
829
|
+
We,
|
|
801
830
|
{
|
|
802
831
|
command: o.command.join(" "),
|
|
803
832
|
timestamp: new Date(o.timestamp).toLocaleTimeString(),
|
|
@@ -805,10 +834,10 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
805
834
|
}
|
|
806
835
|
),
|
|
807
836
|
/* @__PURE__ */ m("pre", { className: `text-gray-200 whitespace-pre font-mono ${n.outputFontSize}`, children: o.result.render() })
|
|
808
|
-
] },
|
|
837
|
+
] }, o.id))
|
|
809
838
|
}
|
|
810
839
|
);
|
|
811
|
-
},
|
|
840
|
+
}, Ve = {
|
|
812
841
|
blink: {
|
|
813
842
|
character: "▋",
|
|
814
843
|
speed: 530,
|
|
@@ -829,23 +858,23 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
829
858
|
speed: 120,
|
|
830
859
|
color: "#fff"
|
|
831
860
|
}
|
|
832
|
-
},
|
|
861
|
+
}, oe = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], se = ["|", "/", "-", "\\"], Ye = ({
|
|
833
862
|
style: r = { type: "blink" },
|
|
834
863
|
isValid: e = !0,
|
|
835
864
|
errorMessage: n
|
|
836
865
|
}) => {
|
|
837
|
-
const t =
|
|
838
|
-
...
|
|
866
|
+
const t = D(() => ({
|
|
867
|
+
...Ve[r.type],
|
|
839
868
|
...r
|
|
840
|
-
}), [r]), [o,
|
|
869
|
+
}), [r]), [o, a] = R(!0), [i, c] = R(0);
|
|
841
870
|
A(() => {
|
|
842
871
|
if (t.speed === 0) return;
|
|
843
|
-
const
|
|
844
|
-
t.type === "blink" ?
|
|
872
|
+
const h = setInterval(() => {
|
|
873
|
+
t.type === "blink" ? a((p) => !p) : ["spin", "bbs"].includes(t.type) && c((p) => (p + 1) % (t.type === "bbs" ? se.length : oe.length));
|
|
845
874
|
}, t.speed);
|
|
846
|
-
return () => clearInterval(
|
|
875
|
+
return () => clearInterval(h);
|
|
847
876
|
}, [t.type, t.speed]);
|
|
848
|
-
const
|
|
877
|
+
const s = D(() => ({
|
|
849
878
|
color: e ? t.color : "#ff4444",
|
|
850
879
|
transition: "color 0.15s ease-in-out"
|
|
851
880
|
}), [e, t.color]);
|
|
@@ -853,13 +882,13 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
853
882
|
"span",
|
|
854
883
|
{
|
|
855
884
|
className: `command-cursor ${e ? "" : "animate-shake"}`,
|
|
856
|
-
style:
|
|
885
|
+
style: s,
|
|
857
886
|
title: n,
|
|
858
|
-
children: !e && n ? "✗" : ["spin", "bbs"].includes(t.type) ? (t.type === "bbs" ?
|
|
887
|
+
children: !e && n ? "✗" : ["spin", "bbs"].includes(t.type) ? (t.type === "bbs" ? se : oe)[i] : t.type === "solid" || o ? t.character : " "
|
|
859
888
|
}
|
|
860
889
|
) });
|
|
861
890
|
};
|
|
862
|
-
function
|
|
891
|
+
function Be(r, e) {
|
|
863
892
|
switch (e.type) {
|
|
864
893
|
case "set":
|
|
865
894
|
return C.debug(`[inputStateReducer] InputState changing from ${r} to ${e.state}`), e.state;
|
|
@@ -867,102 +896,98 @@ function Ye(r, e) {
|
|
|
867
896
|
return r;
|
|
868
897
|
}
|
|
869
898
|
}
|
|
870
|
-
const
|
|
871
|
-
const { state: r } =
|
|
872
|
-
|
|
873
|
-
},
|
|
874
|
-
const
|
|
875
|
-
return C.debug("[getNextExpectedSegment] ",
|
|
876
|
-
}, [e, t]),
|
|
877
|
-
if (!
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
return Array.from(g.values()).filter(() => {
|
|
883
|
-
const f = l();
|
|
884
|
-
return f.type !== "word" ? !1 : f.name.toLowerCase().startsWith(i.toLowerCase());
|
|
899
|
+
const Ge = () => {
|
|
900
|
+
const { state: r } = ee(), e = B(), n = ge(), t = K(), [o, a] = Se(Be, "idle"), i = (d) => {
|
|
901
|
+
a({ type: "set", state: d });
|
|
902
|
+
}, c = y(() => {
|
|
903
|
+
const f = e.getCompletions(t.path())[0] || t.nullSegment;
|
|
904
|
+
return C.debug("[getNextExpectedSegment] ", f), f;
|
|
905
|
+
}, [e, t]), s = y(() => e.getCompletionNames(t.path()).map((f) => e.getCommand([...t.path(), f])).filter((f) => f !== void 0), [e, t]), l = y((d, f) => {
|
|
906
|
+
if (!d) return f;
|
|
907
|
+
const w = t.path().length;
|
|
908
|
+
return f.filter((x) => {
|
|
909
|
+
const g = x.segments[w];
|
|
910
|
+
return !g || g.type !== "word" ? !1 : g.name.toLowerCase().startsWith(d.toLowerCase());
|
|
885
911
|
});
|
|
886
|
-
}, [
|
|
887
|
-
const
|
|
888
|
-
(
|
|
912
|
+
}, [t]), h = y((d) => {
|
|
913
|
+
const w = e.getCompletions(t.path()).filter((x) => x.type === "word").filter(
|
|
914
|
+
(x) => x.name.toLowerCase().startsWith(d.toLowerCase())
|
|
889
915
|
);
|
|
890
|
-
return
|
|
891
|
-
}, [e, t]), p =
|
|
892
|
-
const
|
|
893
|
-
return
|
|
894
|
-
(
|
|
916
|
+
return w.length === 1 ? w[0] : t.nullSegment;
|
|
917
|
+
}, [e, t]), p = y((d) => {
|
|
918
|
+
const f = t.path(), w = e.getCompletions(f);
|
|
919
|
+
return w.length === 0 && d ? !1 : w.some((g) => g.type === "argument") ? !0 : w.some(
|
|
920
|
+
(g) => g.type === "word" && g.name.toLowerCase().startsWith(d.toLowerCase())
|
|
895
921
|
);
|
|
896
|
-
}, [e, t]),
|
|
897
|
-
C.debug("[tryAutoComplete] input: ",
|
|
898
|
-
const
|
|
899
|
-
return !
|
|
900
|
-
}, [
|
|
922
|
+
}, [e, t]), S = y((d) => {
|
|
923
|
+
C.debug("[tryAutoComplete] input: ", d);
|
|
924
|
+
const f = h(d);
|
|
925
|
+
return !f || f.name === d ? new ue() : (C.debug("[tryAutoComplete] result: ", f), f);
|
|
926
|
+
}, [h]), v = y((d, f) => {
|
|
901
927
|
if (r.history.position === null) {
|
|
902
|
-
if (
|
|
903
|
-
const
|
|
904
|
-
if (
|
|
905
|
-
if (
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
928
|
+
if (f.setCurrentInput(d), C.debug("[useCommandParser][handleInputChange] newValue: ", d), o === "entering_argument") {
|
|
929
|
+
const w = ae(d);
|
|
930
|
+
if (w.isQuoted)
|
|
931
|
+
if (w.isComplete) {
|
|
932
|
+
const x = c();
|
|
933
|
+
if (!(x instanceof W)) return;
|
|
934
|
+
x.value = d.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", x), t.push(x), f.setCurrentInput(""), i("idle");
|
|
935
|
+
return;
|
|
912
936
|
} else
|
|
913
937
|
return;
|
|
914
|
-
else if (
|
|
915
|
-
const
|
|
916
|
-
|
|
938
|
+
else if (w.isComplete) {
|
|
939
|
+
const x = c();
|
|
940
|
+
if (!(x instanceof W)) return;
|
|
941
|
+
x.value = d.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", x), t.push(x), f.setCurrentInput(""), i("idle");
|
|
917
942
|
return;
|
|
918
943
|
} else
|
|
919
944
|
return;
|
|
920
945
|
}
|
|
921
|
-
if (o
|
|
922
|
-
const
|
|
923
|
-
if (
|
|
924
|
-
C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ",
|
|
946
|
+
if (o === "entering_command") {
|
|
947
|
+
const w = S(d);
|
|
948
|
+
if (w.type === "word") {
|
|
949
|
+
C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), t.push(w), f.setCurrentInput(""), i("idle");
|
|
925
950
|
return;
|
|
926
951
|
}
|
|
927
952
|
}
|
|
928
953
|
}
|
|
929
|
-
}, [
|
|
930
|
-
|
|
931
|
-
}, [t]),
|
|
932
|
-
if (!(
|
|
954
|
+
}, [S, r, c, o, t]), u = y((d) => {
|
|
955
|
+
d.setCurrentInput(""), d.setIsEnteringArg(!1), t.clear(), i("idle");
|
|
956
|
+
}, [t]), k = y((d, f, w) => {
|
|
957
|
+
if (!(d.key === "Backspace" || d.key === "Enter" || d.key === "ArrowUp" || d.key === "ArrowDown" || d.key === "ArrowLeft" || d.key === "ArrowRight" || d.key === "Escape" || d.key === "Delete" || d.key === "Home" || d.key === "End" || d.key.length === 1))
|
|
933
958
|
return !0;
|
|
934
|
-
const { currentInput:
|
|
935
|
-
switch (
|
|
959
|
+
const { currentInput: g, isEnteringArg: E } = f, I = ae(g);
|
|
960
|
+
switch (d.key) {
|
|
936
961
|
case "Backspace":
|
|
937
|
-
return
|
|
962
|
+
return g === "" && (d.preventDefault(), t.size() > 0 && t.pop(), i("idle")), !0;
|
|
938
963
|
case "Enter": {
|
|
939
|
-
if (
|
|
964
|
+
if (d.preventDefault(), I.isQuoted && !I.isComplete)
|
|
940
965
|
return !0;
|
|
941
|
-
if (o === "entering_argument" ||
|
|
942
|
-
const
|
|
943
|
-
|
|
966
|
+
if (o === "entering_argument" || E && g.trim()) {
|
|
967
|
+
const M = c();
|
|
968
|
+
M instanceof W && (M.value = g, C.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", M), t.push(M));
|
|
944
969
|
}
|
|
945
|
-
const
|
|
946
|
-
if (!
|
|
970
|
+
const z = t.path(), U = e.getCommand(z);
|
|
971
|
+
if (!U)
|
|
947
972
|
return !1;
|
|
948
|
-
const
|
|
949
|
-
return
|
|
973
|
+
const j = U.segments.filter((M) => M.type === "argument"), be = t.arguments;
|
|
974
|
+
return j.length > be.length ? !1 : (C.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", t), w.executeCommand(), n.addStoredCommand(t.toArray()), u(w), !0);
|
|
950
975
|
}
|
|
951
976
|
case "ArrowUp":
|
|
952
|
-
return
|
|
953
|
-
const
|
|
954
|
-
return
|
|
977
|
+
return d.preventDefault(), (async () => {
|
|
978
|
+
const z = await n.navigateHistory("up");
|
|
979
|
+
return z.segments && (t.clear(), t.pushAll(z.segments), w.setCurrentInput("")), !0;
|
|
955
980
|
})();
|
|
956
981
|
case "ArrowDown":
|
|
957
|
-
return
|
|
958
|
-
const
|
|
959
|
-
return
|
|
982
|
+
return d.preventDefault(), (async () => {
|
|
983
|
+
const z = await n.navigateHistory("down");
|
|
984
|
+
return z.segments && (t.clear(), t.pushAll(z.segments), w.setCurrentInput("")), !0;
|
|
960
985
|
})();
|
|
961
986
|
default: {
|
|
962
|
-
if (!
|
|
963
|
-
const
|
|
964
|
-
if (!p(
|
|
965
|
-
return
|
|
987
|
+
if (!E && d.key.length === 1) {
|
|
988
|
+
const z = g + d.key;
|
|
989
|
+
if (!p(z))
|
|
990
|
+
return d.preventDefault(), !1;
|
|
966
991
|
}
|
|
967
992
|
return !0;
|
|
968
993
|
}
|
|
@@ -970,31 +995,31 @@ const Be = () => {
|
|
|
970
995
|
}, [
|
|
971
996
|
o,
|
|
972
997
|
p,
|
|
973
|
-
|
|
998
|
+
c,
|
|
974
999
|
n,
|
|
975
|
-
|
|
1000
|
+
u,
|
|
976
1001
|
e,
|
|
977
1002
|
t
|
|
978
1003
|
]);
|
|
979
1004
|
return {
|
|
980
|
-
handleInputChange:
|
|
981
|
-
handleKeyDown:
|
|
1005
|
+
handleInputChange: v,
|
|
1006
|
+
handleKeyDown: k,
|
|
982
1007
|
inputState: o,
|
|
983
|
-
setInputStateWithLogging:
|
|
1008
|
+
setInputStateWithLogging: i,
|
|
984
1009
|
// Expose internal functions for testing
|
|
985
|
-
findMatchingCommands:
|
|
986
|
-
getAutocompleteSuggestion:
|
|
987
|
-
getAvailableNodes:
|
|
988
|
-
getNextExpectedSegment:
|
|
1010
|
+
findMatchingCommands: l,
|
|
1011
|
+
getAutocompleteSuggestion: h,
|
|
1012
|
+
getAvailableNodes: s,
|
|
1013
|
+
getNextExpectedSegment: c,
|
|
989
1014
|
isValidCommandInput: p
|
|
990
1015
|
};
|
|
991
1016
|
};
|
|
992
|
-
function
|
|
1017
|
+
function ae(r) {
|
|
993
1018
|
const e = [];
|
|
994
1019
|
let n = "", t = !1, o;
|
|
995
|
-
for (let
|
|
996
|
-
const
|
|
997
|
-
(
|
|
1020
|
+
for (let a = 0; a < r.length; a++) {
|
|
1021
|
+
const i = r[a];
|
|
1022
|
+
(i === '"' || i === "'") && (!t || i === o) ? t ? (e.push(n), n = "", t = !1, o = void 0) : (n && (e.push(n), n = ""), t = !0, o = i) : !t && i === " " ? n && (e.push(n), n = "") : n += i;
|
|
998
1023
|
}
|
|
999
1024
|
return {
|
|
1000
1025
|
words: e,
|
|
@@ -1004,8 +1029,8 @@ function te(r) {
|
|
|
1004
1029
|
isComplete: !t && !n
|
|
1005
1030
|
};
|
|
1006
1031
|
}
|
|
1007
|
-
const
|
|
1008
|
-
const r =
|
|
1032
|
+
const Je = () => {
|
|
1033
|
+
const r = K(), [e, n] = R(0);
|
|
1009
1034
|
return A(() => {
|
|
1010
1035
|
const t = {
|
|
1011
1036
|
update: () => {
|
|
@@ -1016,66 +1041,64 @@ const Ge = () => {
|
|
|
1016
1041
|
r.unsubscribe(t);
|
|
1017
1042
|
};
|
|
1018
1043
|
}, [r]), e;
|
|
1019
|
-
},
|
|
1044
|
+
}, Qe = ({
|
|
1020
1045
|
state: r,
|
|
1021
1046
|
actions: e
|
|
1022
1047
|
}) => {
|
|
1023
|
-
const n = H(null), t = B(), o =
|
|
1024
|
-
handleKeyDown:
|
|
1025
|
-
handleInputChange:
|
|
1026
|
-
inputState:
|
|
1027
|
-
setInputStateWithLogging:
|
|
1028
|
-
getNextExpectedSegment:
|
|
1029
|
-
} =
|
|
1030
|
-
const
|
|
1031
|
-
await Promise.resolve(
|
|
1032
|
-
},
|
|
1033
|
-
|
|
1034
|
-
},
|
|
1035
|
-
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1048
|
+
const n = H(null), t = B(), o = K(), {
|
|
1049
|
+
handleKeyDown: a,
|
|
1050
|
+
handleInputChange: i,
|
|
1051
|
+
inputState: c,
|
|
1052
|
+
setInputStateWithLogging: s,
|
|
1053
|
+
getNextExpectedSegment: l
|
|
1054
|
+
} = Ge(), [h, p] = R(!1), S = $(), v = Je(), u = async (g) => {
|
|
1055
|
+
const E = a(g, r, e);
|
|
1056
|
+
await Promise.resolve(E) === !1 && (p(!0), setTimeout(() => p(!1), 500));
|
|
1057
|
+
}, k = (g) => {
|
|
1058
|
+
i(g.target.value, e);
|
|
1059
|
+
}, d = (g) => {
|
|
1060
|
+
g.preventDefault();
|
|
1061
|
+
const E = g.clipboardData.getData("text");
|
|
1062
|
+
i(E, e);
|
|
1038
1063
|
};
|
|
1039
1064
|
A(() => {
|
|
1040
|
-
n.current && n.current.focus(),
|
|
1041
|
-
}, [
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
let
|
|
1045
|
-
switch (
|
|
1065
|
+
n.current && n.current.focus(), c !== "entering_command" && s("entering_command");
|
|
1066
|
+
}, [c, s]), A(() => {
|
|
1067
|
+
if (c !== "idle") return;
|
|
1068
|
+
const g = l();
|
|
1069
|
+
let E = "idle";
|
|
1070
|
+
switch (g.type) {
|
|
1046
1071
|
case "word":
|
|
1047
|
-
|
|
1072
|
+
E = "entering_command", e.setIsEnteringArg(!1);
|
|
1048
1073
|
break;
|
|
1049
1074
|
case "argument":
|
|
1050
|
-
|
|
1075
|
+
E = "entering_argument", e.setIsEnteringArg(!0);
|
|
1051
1076
|
break;
|
|
1052
1077
|
}
|
|
1053
|
-
|
|
1054
|
-
}, [
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
/* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children:
|
|
1064
|
-
|
|
1065
|
-
] }, "arg-" + M.name + M.value);
|
|
1078
|
+
s(E);
|
|
1079
|
+
}, [v, c, l, s, e]);
|
|
1080
|
+
const f = D(() => {
|
|
1081
|
+
const g = [], E = o.toArray().map((I, z) => {
|
|
1082
|
+
g.push(I.name);
|
|
1083
|
+
const U = t.hasNextSegment(g);
|
|
1084
|
+
if (I.type === "argument") {
|
|
1085
|
+
const j = I;
|
|
1086
|
+
return /* @__PURE__ */ N(O.Fragment, { children: [
|
|
1087
|
+
/* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: j.value }),
|
|
1088
|
+
z < o.size() && U && /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: " " })
|
|
1089
|
+
] }, "arg-" + j.name + j.value);
|
|
1066
1090
|
}
|
|
1067
|
-
return /* @__PURE__ */
|
|
1068
|
-
/* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children:
|
|
1069
|
-
|
|
1070
|
-
] }, "word-" +
|
|
1091
|
+
return /* @__PURE__ */ N(O.Fragment, { children: [
|
|
1092
|
+
/* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: I.name }),
|
|
1093
|
+
z < o.size() && U && /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: " " })
|
|
1094
|
+
] }, "word-" + I.name);
|
|
1071
1095
|
});
|
|
1072
|
-
|
|
1073
|
-
}, [
|
|
1074
|
-
const [S, f] = R("");
|
|
1096
|
+
return [/* @__PURE__ */ m("div", { className: "flex items-center gap-1", "data-testid": "user-input-area", children: E }, "{segmentStackVersion}")];
|
|
1097
|
+
}, [v, t, o]), [w, x] = R("");
|
|
1075
1098
|
return A(() => {
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
}, [
|
|
1099
|
+
const g = l();
|
|
1100
|
+
g.type === "argument" ? x(g.name) : x("");
|
|
1101
|
+
}, [v, l]), /* @__PURE__ */ N("div", { className: "flex flex-col w-full bg-gray-900 rounded-lg p-4", children: [
|
|
1079
1102
|
/* @__PURE__ */ m("style", { children: `
|
|
1080
1103
|
@keyframes subtleGlow {
|
|
1081
1104
|
0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
|
|
@@ -1085,11 +1108,11 @@ const Ge = () => {
|
|
|
1085
1108
|
animation: subtleGlow 0.4s ease-in-out;
|
|
1086
1109
|
}
|
|
1087
1110
|
` }),
|
|
1088
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
|
|
1089
1112
|
/* @__PURE__ */ m("div", { className: "text-gray-400 font-mono", children: ">" }),
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
|
|
1092
|
-
/* @__PURE__ */
|
|
1113
|
+
/* @__PURE__ */ N("div", { className: "flex-1 font-mono flex items-center", children: [
|
|
1114
|
+
f,
|
|
1115
|
+
/* @__PURE__ */ N("div", { className: "relative flex-1", children: [
|
|
1093
1116
|
/* @__PURE__ */ m(
|
|
1094
1117
|
"input",
|
|
1095
1118
|
{
|
|
@@ -1097,14 +1120,14 @@ const Ge = () => {
|
|
|
1097
1120
|
type: "text",
|
|
1098
1121
|
role: "textbox",
|
|
1099
1122
|
value: r.currentInput,
|
|
1100
|
-
onChange:
|
|
1101
|
-
onKeyDown:
|
|
1102
|
-
onPaste:
|
|
1123
|
+
onChange: k,
|
|
1124
|
+
onKeyDown: u,
|
|
1125
|
+
onPaste: d,
|
|
1103
1126
|
"data-testid": "citadel-command-input",
|
|
1104
|
-
className: `w-full bg-transparent outline-none text-gray-200 caret-transparent ${
|
|
1127
|
+
className: `w-full bg-transparent outline-none text-gray-200 caret-transparent ${h ? "invalid-input-animation" : ""}`,
|
|
1105
1128
|
spellCheck: !1,
|
|
1106
1129
|
autoComplete: "off",
|
|
1107
|
-
placeholder:
|
|
1130
|
+
placeholder: w
|
|
1108
1131
|
}
|
|
1109
1132
|
),
|
|
1110
1133
|
/* @__PURE__ */ m(
|
|
@@ -1116,12 +1139,12 @@ const Ge = () => {
|
|
|
1116
1139
|
transition: "left 0.05s ease-out"
|
|
1117
1140
|
},
|
|
1118
1141
|
children: /* @__PURE__ */ m(
|
|
1119
|
-
|
|
1142
|
+
Ye,
|
|
1120
1143
|
{
|
|
1121
1144
|
style: {
|
|
1122
|
-
type:
|
|
1123
|
-
color:
|
|
1124
|
-
speed:
|
|
1145
|
+
type: S.cursorType ?? _.cursorType,
|
|
1146
|
+
color: S.cursorColor || _.cursorColor,
|
|
1147
|
+
speed: S.cursorSpeed || _.cursorSpeed
|
|
1125
1148
|
}
|
|
1126
1149
|
}
|
|
1127
1150
|
)
|
|
@@ -1131,114 +1154,120 @@ const Ge = () => {
|
|
|
1131
1154
|
] })
|
|
1132
1155
|
] })
|
|
1133
1156
|
] });
|
|
1134
|
-
},
|
|
1135
|
-
const r = B(), e =
|
|
1136
|
-
C.debug("[AvailableCommands] nextCommandSegments: ",
|
|
1137
|
-
const a =
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1157
|
+
}, Xe = () => {
|
|
1158
|
+
const r = B(), e = K(), n = "mt-2 border-t border-gray-700 px-4 py-2", t = "text-gray-300", o = r.getCompletions(e.path());
|
|
1159
|
+
C.debug("[AvailableCommands] nextCommandSegments: ", o);
|
|
1160
|
+
const a = O.useMemo(() => {
|
|
1161
|
+
const l = [...o], h = (u) => u.name.toLowerCase() === "help", p = l.filter(h);
|
|
1162
|
+
return [...l.filter((u) => !h(u)).sort(
|
|
1163
|
+
(u, k) => u.name.localeCompare(k.name, void 0, { sensitivity: "base" })
|
|
1164
|
+
), ...p];
|
|
1165
|
+
}, [o]), i = O.useMemo(() => {
|
|
1166
|
+
const l = /* @__PURE__ */ new Map();
|
|
1167
|
+
for (const h of a) {
|
|
1168
|
+
const p = a.reduce((S, v) => {
|
|
1169
|
+
if (v === h) return S;
|
|
1170
|
+
let u = 0;
|
|
1171
|
+
for (; u < h.name.length && u < v.name.length && h.name[u].toLowerCase() === v.name[u].toLowerCase(); )
|
|
1172
|
+
u++;
|
|
1173
|
+
return Math.max(S, u + 1);
|
|
1174
|
+
}, 1);
|
|
1175
|
+
l.set(h.name, p);
|
|
1141
1176
|
}
|
|
1142
|
-
return
|
|
1143
|
-
}, [
|
|
1144
|
-
return /* @__PURE__ */ m("div", { className:
|
|
1145
|
-
/* @__PURE__ */ m("span", { className: "text-blue-400", children:
|
|
1146
|
-
|
|
1177
|
+
return l;
|
|
1178
|
+
}, [a]), c = o.some((l) => l.type === "argument"), s = o[0];
|
|
1179
|
+
return /* @__PURE__ */ m("div", { className: n, "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: t, children: c ? o.length > 0 ? /* @__PURE__ */ N(ve, { children: [
|
|
1180
|
+
/* @__PURE__ */ m("span", { className: "text-blue-400", children: s.name }),
|
|
1181
|
+
s.description && /* @__PURE__ */ N("span", { className: "text-gray-400 ml-2", children: [
|
|
1147
1182
|
"- ",
|
|
1148
|
-
|
|
1183
|
+
s.description
|
|
1149
1184
|
] })
|
|
1150
|
-
] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: a == null ? void 0 : a.map((
|
|
1151
|
-
const
|
|
1152
|
-
if (k === c) return p;
|
|
1153
|
-
let y = 0;
|
|
1154
|
-
for (; y < c.name.length && y < k.name.length && c.name[y].toLowerCase() === k.name[y].toLowerCase(); )
|
|
1155
|
-
y++;
|
|
1156
|
-
return Math.max(p, y + 1);
|
|
1157
|
-
}, 1);
|
|
1185
|
+
] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: a == null ? void 0 : a.map((l) => {
|
|
1186
|
+
const h = i.get(l.name) ?? 1;
|
|
1158
1187
|
return /* @__PURE__ */ m(
|
|
1159
1188
|
"div",
|
|
1160
1189
|
{
|
|
1161
1190
|
className: "px-2 py-1 rounded bg-gray-800 mr-2 last:mr-0",
|
|
1162
|
-
children: /* @__PURE__ */
|
|
1163
|
-
/* @__PURE__ */ m("strong", { className: "underline", children:
|
|
1164
|
-
|
|
1191
|
+
children: /* @__PURE__ */ N("span", { className: "font-mono text-white", children: [
|
|
1192
|
+
/* @__PURE__ */ m("strong", { className: "underline", children: l.name.slice(0, h) }),
|
|
1193
|
+
l.name.slice(h)
|
|
1165
1194
|
] })
|
|
1166
1195
|
},
|
|
1167
|
-
|
|
1196
|
+
l.name
|
|
1168
1197
|
);
|
|
1169
1198
|
}) }) }) });
|
|
1170
|
-
},
|
|
1199
|
+
}, fe = ({
|
|
1171
1200
|
state: r,
|
|
1172
1201
|
actions: e,
|
|
1173
1202
|
outputRef: n
|
|
1174
|
-
}) => /* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */ m(
|
|
1178
|
-
/* @__PURE__ */ m(
|
|
1203
|
+
}) => /* @__PURE__ */ N("div", { className: "innerContainer", children: [
|
|
1204
|
+
/* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(qe, { output: r.output, outputRef: n }) }),
|
|
1205
|
+
/* @__PURE__ */ N("div", { children: [
|
|
1206
|
+
/* @__PURE__ */ m(Qe, { state: r, actions: e }),
|
|
1207
|
+
/* @__PURE__ */ m(Xe, {})
|
|
1179
1208
|
] })
|
|
1180
|
-
] }),
|
|
1181
|
-
const [r, e] = R(!1), [n, t] = R(!1), o =
|
|
1182
|
-
|
|
1209
|
+
] }), Ze = () => {
|
|
1210
|
+
const [r, e] = R(!1), [n, t] = R(!1), o = $(), [a, i] = R(() => o.initialHeight || null), c = H(null), s = H(null), l = H(!1), h = H(0), p = H(0), { state: S, actions: v } = ee();
|
|
1211
|
+
Me({
|
|
1183
1212
|
onOpen: () => e(!0),
|
|
1184
1213
|
onClose: () => t(!0),
|
|
1185
1214
|
isVisible: r,
|
|
1186
1215
|
showCitadelKey: o.showCitadelKey || "."
|
|
1187
1216
|
});
|
|
1188
|
-
const
|
|
1189
|
-
var
|
|
1190
|
-
if (!
|
|
1191
|
-
const
|
|
1192
|
-
Math.max(p.current -
|
|
1193
|
-
|
|
1217
|
+
const u = y((w) => {
|
|
1218
|
+
var I;
|
|
1219
|
+
if (!l.current) return;
|
|
1220
|
+
const x = w.clientY - h.current, g = (I = o.maxHeight) != null && I.endsWith("vh") ? window.innerHeight * parseInt(o.maxHeight, 10) / 100 : parseInt(o.maxHeight || "80vh", 10), E = Math.min(
|
|
1221
|
+
Math.max(p.current - x, parseInt(o.minHeight || "200", 10)),
|
|
1222
|
+
g
|
|
1194
1223
|
);
|
|
1195
|
-
|
|
1196
|
-
}, [o.maxHeight, o.minHeight]),
|
|
1197
|
-
|
|
1198
|
-
}, [
|
|
1199
|
-
|
|
1200
|
-
}, [
|
|
1224
|
+
s.current && (s.current.style.height = `${E}px`, s.current.style.bottom = "0", i(`${E}px`));
|
|
1225
|
+
}, [o.maxHeight, o.minHeight]), k = y(() => {
|
|
1226
|
+
l.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", k);
|
|
1227
|
+
}, [u]), d = y((w) => {
|
|
1228
|
+
s.current && (l.current = !0, h.current = w.clientY, p.current = s.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mousemove", u), document.addEventListener("mouseup", k));
|
|
1229
|
+
}, [u, k]);
|
|
1201
1230
|
A(() => () => {
|
|
1202
|
-
document.removeEventListener("mousemove",
|
|
1203
|
-
}, [
|
|
1204
|
-
const
|
|
1231
|
+
document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", k);
|
|
1232
|
+
}, [u, k]);
|
|
1233
|
+
const f = y(() => {
|
|
1205
1234
|
n && (e(!1), t(!1));
|
|
1206
1235
|
}, [n]);
|
|
1207
1236
|
return $e({
|
|
1208
1237
|
isVisible: r,
|
|
1209
1238
|
isClosing: n,
|
|
1210
|
-
onAnimationComplete:
|
|
1211
|
-
}), r ? /* @__PURE__ */
|
|
1239
|
+
onAnimationComplete: f
|
|
1240
|
+
}), r ? /* @__PURE__ */ N(
|
|
1212
1241
|
"div",
|
|
1213
1242
|
{
|
|
1214
|
-
ref:
|
|
1243
|
+
ref: s,
|
|
1215
1244
|
className: `panelContainer ${r ? "citadel_slideUp" : ""} ${n ? "citadel_slideDown" : ""}`,
|
|
1216
1245
|
style: {
|
|
1217
|
-
...
|
|
1246
|
+
...a ? { height: a } : void 0,
|
|
1218
1247
|
maxHeight: o.maxHeight
|
|
1219
1248
|
},
|
|
1220
1249
|
children: [
|
|
1221
|
-
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown:
|
|
1250
|
+
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: d }),
|
|
1222
1251
|
/* @__PURE__ */ m(
|
|
1223
|
-
|
|
1252
|
+
fe,
|
|
1224
1253
|
{
|
|
1225
|
-
state:
|
|
1226
|
-
actions:
|
|
1227
|
-
outputRef:
|
|
1254
|
+
state: S,
|
|
1255
|
+
actions: v,
|
|
1256
|
+
outputRef: c
|
|
1228
1257
|
}
|
|
1229
1258
|
)
|
|
1230
1259
|
]
|
|
1231
1260
|
}
|
|
1232
1261
|
) : null;
|
|
1233
|
-
},
|
|
1234
|
-
const { state: r, actions: e } =
|
|
1262
|
+
}, en = () => {
|
|
1263
|
+
const { state: r, actions: e } = ee(), n = H(null);
|
|
1235
1264
|
return /* @__PURE__ */ m(
|
|
1236
1265
|
"div",
|
|
1237
1266
|
{
|
|
1238
1267
|
className: "inlineContainer",
|
|
1239
1268
|
"data-testid": "citadel-inline-container",
|
|
1240
1269
|
children: /* @__PURE__ */ m(
|
|
1241
|
-
|
|
1270
|
+
fe,
|
|
1242
1271
|
{
|
|
1243
1272
|
state: r,
|
|
1244
1273
|
actions: e,
|
|
@@ -1247,7 +1276,7 @@ const Ge = () => {
|
|
|
1247
1276
|
)
|
|
1248
1277
|
}
|
|
1249
1278
|
);
|
|
1250
|
-
},
|
|
1279
|
+
}, ie = `:host {
|
|
1251
1280
|
--citadel-bg: rgb(17, 24, 39);
|
|
1252
1281
|
--citadel-text: rgba(255, 255, 255, 0.87);
|
|
1253
1282
|
--citadel-border: rgb(55, 65, 81);
|
|
@@ -1351,7 +1380,7 @@ a:hover {
|
|
|
1351
1380
|
.text-left {
|
|
1352
1381
|
text-align: left;
|
|
1353
1382
|
}
|
|
1354
|
-
`,
|
|
1383
|
+
`, le = `/* Keep only component-specific styles here */
|
|
1355
1384
|
|
|
1356
1385
|
.panelContainer {
|
|
1357
1386
|
position: fixed;
|
|
@@ -1433,10 +1462,10 @@ a:hover {
|
|
|
1433
1462
|
overflow: hidden;
|
|
1434
1463
|
box-sizing: border-box;
|
|
1435
1464
|
}
|
|
1436
|
-
`,
|
|
1465
|
+
`, ce = `@tailwind base;
|
|
1437
1466
|
@tailwind components;
|
|
1438
1467
|
@tailwind utilities;
|
|
1439
|
-
`,
|
|
1468
|
+
`, nn = `*, ::before, ::after {
|
|
1440
1469
|
--tw-border-spacing-x: 0;
|
|
1441
1470
|
--tw-border-spacing-y: 0;
|
|
1442
1471
|
--tw-translate-x: 0;
|
|
@@ -2253,75 +2282,85 @@ video {
|
|
|
2253
2282
|
.last\\:mr-0:last-child {
|
|
2254
2283
|
margin-right: 0px;
|
|
2255
2284
|
}
|
|
2256
|
-
`,
|
|
2257
|
-
config: r =
|
|
2258
|
-
commandRegistry: e = new
|
|
2285
|
+
`, dn = ({
|
|
2286
|
+
config: r = _,
|
|
2287
|
+
commandRegistry: e = new Z(),
|
|
2259
2288
|
containerId: n = null
|
|
2260
2289
|
}) => {
|
|
2261
|
-
const t = H(null), o = r.displayMode ??
|
|
2290
|
+
const t = H(null), o = r.displayMode ?? _.displayMode ?? "panel";
|
|
2262
2291
|
return A(() => {
|
|
2263
2292
|
C.configure({
|
|
2264
|
-
level: r.logLevel ||
|
|
2293
|
+
level: r.logLevel || _.logLevel || Q.ERROR,
|
|
2265
2294
|
prefix: "[Citadel]"
|
|
2266
2295
|
});
|
|
2267
|
-
const
|
|
2268
|
-
if (
|
|
2269
|
-
|
|
2296
|
+
const a = new we(e, r), i = o === "inline" && !n, c = i ? t.current : n ? document.getElementById(n) : document.body;
|
|
2297
|
+
if (c)
|
|
2298
|
+
c.appendChild(a);
|
|
2270
2299
|
else {
|
|
2271
|
-
if (
|
|
2300
|
+
if (i) {
|
|
2272
2301
|
console.warn("[Citadel] No host available for inline mode; skipping mount.");
|
|
2273
2302
|
return;
|
|
2274
2303
|
}
|
|
2275
|
-
console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(
|
|
2304
|
+
console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(a);
|
|
2276
2305
|
}
|
|
2277
2306
|
return () => {
|
|
2278
|
-
var
|
|
2279
|
-
(
|
|
2307
|
+
var s;
|
|
2308
|
+
(s = a.parentElement) == null || s.removeChild(a);
|
|
2280
2309
|
};
|
|
2281
2310
|
}, [e, n, r, o]), o === "inline" && !n ? /* @__PURE__ */ m("div", { ref: t, style: { width: "100%", height: "100%" } }) : null;
|
|
2282
2311
|
};
|
|
2283
|
-
class
|
|
2312
|
+
class we extends HTMLElement {
|
|
2284
2313
|
constructor(n, t) {
|
|
2285
|
-
var
|
|
2314
|
+
var a;
|
|
2286
2315
|
super();
|
|
2287
2316
|
b(this, "shadow");
|
|
2288
2317
|
b(this, "root", null);
|
|
2289
2318
|
b(this, "commandRegistry");
|
|
2290
2319
|
b(this, "config");
|
|
2291
2320
|
this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = n, this.config = t;
|
|
2292
|
-
const o = ((
|
|
2321
|
+
const o = ((a = this.config) == null ? void 0 : a.displayMode) ?? "panel";
|
|
2293
2322
|
this.setAttribute("data-display-mode", o);
|
|
2294
2323
|
}
|
|
2295
2324
|
connectedCallback() {
|
|
2296
2325
|
try {
|
|
2297
|
-
const t = [
|
|
2298
|
-
const
|
|
2299
|
-
return
|
|
2326
|
+
const t = [ie, le, ce, nn].map((o) => {
|
|
2327
|
+
const a = new CSSStyleSheet();
|
|
2328
|
+
return a.replaceSync(o), a;
|
|
2300
2329
|
});
|
|
2301
2330
|
this.shadow.adoptedStyleSheets = [...t];
|
|
2302
2331
|
} catch {
|
|
2303
|
-
const t = [
|
|
2332
|
+
const t = [ie, le, ce].join(`
|
|
2304
2333
|
`), o = document.createElement("style");
|
|
2305
2334
|
o.textContent = t, this.shadow.appendChild(o);
|
|
2306
2335
|
}
|
|
2307
2336
|
const n = document.createElement("div");
|
|
2308
|
-
n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root =
|
|
2309
|
-
/* @__PURE__ */ m(
|
|
2337
|
+
n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root = ke(n), this.root.render(
|
|
2338
|
+
/* @__PURE__ */ m(Pe, { config: this.config || _, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(tn, {}) })
|
|
2310
2339
|
);
|
|
2311
2340
|
}
|
|
2341
|
+
disconnectedCallback() {
|
|
2342
|
+
const n = this.root;
|
|
2343
|
+
if (this.root = null, !n) {
|
|
2344
|
+
this.shadow.replaceChildren();
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
queueMicrotask(() => {
|
|
2348
|
+
n.unmount(), this.shadow.replaceChildren();
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2312
2351
|
}
|
|
2313
|
-
customElements.define("citadel-element",
|
|
2314
|
-
const
|
|
2352
|
+
typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element", we);
|
|
2353
|
+
const tn = () => ($().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(en, {}) : /* @__PURE__ */ m(Ze, {});
|
|
2315
2354
|
export {
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2355
|
+
dn as Citadel,
|
|
2356
|
+
Z as CommandRegistry,
|
|
2357
|
+
T as CommandResult,
|
|
2358
|
+
F as CommandStatus,
|
|
2359
|
+
Ve as DEFAULT_CURSOR_CONFIGS,
|
|
2360
|
+
Ne as ErrorCommandResult,
|
|
2361
|
+
cn as ImageCommandResult,
|
|
2362
|
+
ln as JsonCommandResult,
|
|
2363
|
+
J as OutputItem,
|
|
2364
|
+
Ee as PendingCommandResult,
|
|
2365
|
+
G as TextCommandResult
|
|
2327
2366
|
};
|