citadel_cli 1.1.6 → 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 +527 -506
- package/dist/citadel.umd.js +8 -8
- 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 +1 -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,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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;
|
|
12
12
|
}
|
|
13
13
|
get status() {
|
|
@@ -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
|
|
79
|
-
|
|
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;
|
|
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);
|
|
@@ -96,15 +99,15 @@ class E {
|
|
|
96
99
|
this.level >= 1 && console.error(this.prefix, ...e);
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
|
-
|
|
100
|
-
const
|
|
102
|
+
b(C, "level", 0), b(C, "prefix", "");
|
|
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,9 +119,9 @@ 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 = {
|
|
123
126
|
type: "localStorage",
|
|
124
127
|
maxCommands: 100,
|
|
@@ -135,10 +138,10 @@ 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");
|
|
142
145
|
}
|
|
143
146
|
async getStoredCommands() {
|
|
144
147
|
try {
|
|
@@ -170,10 +173,10 @@ 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", []);
|
|
177
180
|
}
|
|
178
181
|
async getStoredCommands() {
|
|
179
182
|
return this.storedCommands.map((n) => ({
|
|
@@ -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");
|
|
200
|
+
}
|
|
201
|
+
static reset() {
|
|
202
|
+
P.instance = void 0;
|
|
197
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
|
-
|
|
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,27 +228,27 @@ 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 =
|
|
243
|
-
|
|
244
|
-
|
|
246
|
+
class Ie {
|
|
247
|
+
constructor(e, n, t = me) {
|
|
248
|
+
b(this, "_segments");
|
|
249
|
+
b(this, "_description");
|
|
245
250
|
// Used by `Help` command, etc.
|
|
246
|
-
|
|
251
|
+
b(this, "_handler");
|
|
247
252
|
this._segments = e, this._description = n, this._handler = t;
|
|
248
253
|
}
|
|
249
254
|
get segments() {
|
|
@@ -268,9 +273,9 @@ 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
|
}
|
|
275
280
|
get commands() {
|
|
276
281
|
return this._commands;
|
|
@@ -286,19 +291,19 @@ 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
|
}
|
|
304
309
|
/**
|
|
@@ -322,19 +327,19 @@ class Q {
|
|
|
322
327
|
const t = n.fullPath.join(" "), o = e.join(" ");
|
|
323
328
|
if (t === o)
|
|
324
329
|
return !0;
|
|
325
|
-
const
|
|
326
|
-
return
|
|
330
|
+
const i = n.segments.filter((c) => c.type === "word").map((c) => c.name);
|
|
331
|
+
return i.length === e.length && i.join(" ") === o;
|
|
327
332
|
});
|
|
328
333
|
}
|
|
329
334
|
commandExistsForPath(e) {
|
|
330
335
|
const n = this._commands.map(
|
|
331
336
|
(o) => o.segments.map(
|
|
332
|
-
(
|
|
337
|
+
(a) => a.type === "argument" ? "*" : a.name
|
|
333
338
|
).join(" ")
|
|
334
|
-
), t = e.map((o,
|
|
335
|
-
(
|
|
336
|
-
var
|
|
337
|
-
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";
|
|
338
343
|
}
|
|
339
344
|
) ? "*" : o).join(" ");
|
|
340
345
|
return n.includes(t);
|
|
@@ -345,8 +350,7 @@ class Q {
|
|
|
345
350
|
* @param path The path to get completions for.
|
|
346
351
|
* @returns An array of completion strings.
|
|
347
352
|
*/
|
|
348
|
-
|
|
349
|
-
getCompletions_s(e) {
|
|
353
|
+
getCompletionNames(e) {
|
|
350
354
|
return this.getCompletions(e).map((n) => n.name);
|
|
351
355
|
}
|
|
352
356
|
/**
|
|
@@ -356,29 +360,29 @@ class Q {
|
|
|
356
360
|
* @returns An array of completion strings.
|
|
357
361
|
*/
|
|
358
362
|
getCompletions(e) {
|
|
359
|
-
if (
|
|
360
|
-
const
|
|
361
|
-
return
|
|
362
|
-
(
|
|
363
|
+
if (C.debug("[getCompletions] path: ", e), !e.length) {
|
|
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))
|
|
363
367
|
);
|
|
364
368
|
}
|
|
365
369
|
const n = e.length;
|
|
366
|
-
return this._commands.filter((
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
370
|
+
return this._commands.filter((a) => {
|
|
371
|
+
const i = a.segments;
|
|
372
|
+
if (i.length <= n - 1)
|
|
369
373
|
return !1;
|
|
370
|
-
for (let
|
|
371
|
-
const
|
|
372
|
-
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)
|
|
373
377
|
return !1;
|
|
374
378
|
}
|
|
375
379
|
return !0;
|
|
376
|
-
}).filter((
|
|
377
|
-
const
|
|
378
|
-
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);
|
|
379
383
|
}).filter(
|
|
380
|
-
(
|
|
381
|
-
(
|
|
384
|
+
(a, i, c) => i === c.findIndex(
|
|
385
|
+
(s) => s.type === a.type && s.name === a.name
|
|
382
386
|
)
|
|
383
387
|
);
|
|
384
388
|
}
|
|
@@ -386,11 +390,11 @@ class Q {
|
|
|
386
390
|
return this.getCompletions(e).length > 0;
|
|
387
391
|
}
|
|
388
392
|
}
|
|
389
|
-
class
|
|
393
|
+
class he {
|
|
390
394
|
constructor() {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
395
|
+
b(this, "segments", []);
|
|
396
|
+
b(this, "nullSegment", new ue());
|
|
397
|
+
b(this, "observers", []);
|
|
394
398
|
}
|
|
395
399
|
subscribe(e) {
|
|
396
400
|
this.observers.push(e);
|
|
@@ -473,153 +477,167 @@ class de {
|
|
|
473
477
|
return [...this.segments];
|
|
474
478
|
}
|
|
475
479
|
}
|
|
476
|
-
const
|
|
477
|
-
config:
|
|
478
|
-
commands: new
|
|
479
|
-
segmentStack: new
|
|
480
|
-
},
|
|
481
|
-
const [t, o] =
|
|
482
|
-
...
|
|
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
|
+
..._,
|
|
483
487
|
...r,
|
|
484
488
|
// Ensure nested objects are properly merged
|
|
485
489
|
storage: {
|
|
486
|
-
...
|
|
490
|
+
..._.storage,
|
|
487
491
|
...r.storage
|
|
488
492
|
},
|
|
489
493
|
// Ensure explicit values from config take precedence
|
|
490
|
-
cursorType: r.cursorType ??
|
|
491
|
-
cursorColor: r.cursorColor ??
|
|
492
|
-
cursorSpeed: r.cursorSpeed ??
|
|
494
|
+
cursorType: r.cursorType ?? _.cursorType,
|
|
495
|
+
cursorColor: r.cursorColor ?? _.cursorColor,
|
|
496
|
+
cursorSpeed: r.cursorSpeed ?? _.cursorSpeed,
|
|
493
497
|
showCitadelKey: r.showCitadelKey || "."
|
|
494
498
|
};
|
|
495
499
|
A(() => {
|
|
496
500
|
q.getInstance().initializeStorage(
|
|
497
|
-
|
|
501
|
+
i.storage ?? _.storage
|
|
498
502
|
), o(q.getInstance().getStorage());
|
|
499
503
|
}, []), A(() => {
|
|
500
504
|
if (e) {
|
|
501
|
-
if (
|
|
505
|
+
if (i.includeHelpCommand) {
|
|
502
506
|
if (!e.commandExistsForPath(["help"])) {
|
|
503
|
-
const
|
|
507
|
+
const s = _e(e);
|
|
504
508
|
e.addCommand(
|
|
505
509
|
[{ type: "word", name: "help" }],
|
|
506
510
|
"Show available commands",
|
|
507
|
-
|
|
511
|
+
s
|
|
508
512
|
);
|
|
509
513
|
}
|
|
510
514
|
return;
|
|
511
515
|
}
|
|
512
516
|
e.removeCommand(["help"]);
|
|
513
517
|
}
|
|
514
|
-
}, [e,
|
|
515
|
-
const
|
|
516
|
-
config:
|
|
517
|
-
commands: e || new
|
|
518
|
+
}, [e, i.includeHelpCommand]);
|
|
519
|
+
const c = D(() => ({
|
|
520
|
+
config: i,
|
|
521
|
+
commands: e || new Z(),
|
|
518
522
|
storage: t,
|
|
519
|
-
segmentStack:
|
|
520
|
-
};
|
|
521
|
-
return /* @__PURE__ */ m(
|
|
522
|
-
},
|
|
523
|
-
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);
|
|
524
528
|
if (r === void 0)
|
|
525
529
|
throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
|
|
526
530
|
return r.config;
|
|
527
531
|
}, B = () => {
|
|
528
|
-
const r = Y(
|
|
532
|
+
const r = Y(L);
|
|
529
533
|
if (r === void 0)
|
|
530
534
|
throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
|
|
531
535
|
return r.commands;
|
|
532
|
-
},
|
|
533
|
-
const r = Y(
|
|
536
|
+
}, pe = () => {
|
|
537
|
+
const r = Y(L);
|
|
534
538
|
if (r === void 0)
|
|
535
539
|
throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
|
|
536
540
|
return r.storage;
|
|
537
|
-
},
|
|
538
|
-
const r = Y(
|
|
541
|
+
}, K = () => {
|
|
542
|
+
const r = Y(L);
|
|
539
543
|
if (r === void 0)
|
|
540
544
|
throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
|
|
541
545
|
return r.segmentStack;
|
|
542
|
-
}
|
|
543
|
-
class Re {
|
|
546
|
+
}, V = class V {
|
|
544
547
|
constructor(e, n) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
548
|
+
b(this, "id");
|
|
549
|
+
b(this, "timestamp");
|
|
550
|
+
b(this, "command");
|
|
551
|
+
b(this, "result");
|
|
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();
|
|
549
553
|
}
|
|
550
|
-
}
|
|
554
|
+
};
|
|
555
|
+
b(V, "idCounter", 0);
|
|
556
|
+
let J = V;
|
|
551
557
|
function He(r) {
|
|
552
558
|
return {
|
|
553
559
|
commandSegments: r,
|
|
554
560
|
timestamp: Date.now()
|
|
555
561
|
};
|
|
556
562
|
}
|
|
557
|
-
function
|
|
558
|
-
const r =
|
|
563
|
+
function ge() {
|
|
564
|
+
const r = pe(), [e, n] = R({
|
|
559
565
|
storedCommands: [],
|
|
560
566
|
position: null
|
|
561
|
-
}), t =
|
|
567
|
+
}), t = y(async (c) => {
|
|
562
568
|
if (r)
|
|
563
569
|
try {
|
|
564
|
-
const
|
|
565
|
-
await r.addStoredCommand(
|
|
566
|
-
...
|
|
567
|
-
storedCommands: [...
|
|
570
|
+
const s = He(c);
|
|
571
|
+
await r.addStoredCommand(s), n((l) => ({
|
|
572
|
+
...l,
|
|
573
|
+
storedCommands: [...l.storedCommands, s],
|
|
568
574
|
position: null
|
|
569
575
|
}));
|
|
570
|
-
} catch (
|
|
571
|
-
console.warn("Failed to save command to history:",
|
|
576
|
+
} catch (s) {
|
|
577
|
+
console.warn("Failed to save command to history:", s);
|
|
572
578
|
}
|
|
573
|
-
}, [r]), o =
|
|
579
|
+
}, [r]), o = y(async () => r ? await r.getStoredCommands() : [], [r]);
|
|
574
580
|
A(() => {
|
|
575
581
|
if (!r) return;
|
|
576
582
|
(async () => {
|
|
577
583
|
try {
|
|
578
|
-
const
|
|
579
|
-
return n((
|
|
580
|
-
...
|
|
581
|
-
storedCommands:
|
|
582
|
-
})),
|
|
583
|
-
} catch (
|
|
584
|
-
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);
|
|
585
591
|
}
|
|
586
592
|
})();
|
|
587
593
|
}, [r]);
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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) => ({
|
|
604
|
+
...p,
|
|
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
|
+
} : {
|
|
596
617
|
segments: [],
|
|
597
618
|
position: null
|
|
598
|
-
} : {
|
|
599
|
-
segments: c !== null ? e.storedCommands[c].commandSegments : null,
|
|
600
|
-
position: c
|
|
601
619
|
};
|
|
602
|
-
}, [e, o]),
|
|
620
|
+
}, [e.position, o]), i = y(async () => {
|
|
603
621
|
try {
|
|
604
622
|
if (!r) return;
|
|
605
623
|
await r.clear(), n({
|
|
606
624
|
storedCommands: [],
|
|
607
625
|
position: null
|
|
608
626
|
});
|
|
609
|
-
} catch (
|
|
610
|
-
console.warn("Failed to clear command history:",
|
|
627
|
+
} catch (c) {
|
|
628
|
+
console.warn("Failed to clear command history:", c);
|
|
611
629
|
}
|
|
612
630
|
}, [r]);
|
|
613
631
|
return {
|
|
614
632
|
history: e,
|
|
615
633
|
addStoredCommand: t,
|
|
616
634
|
getStoredCommands: o,
|
|
617
|
-
navigateHistory:
|
|
618
|
-
clear:
|
|
635
|
+
navigateHistory: a,
|
|
636
|
+
clear: i
|
|
619
637
|
};
|
|
620
638
|
}
|
|
621
|
-
const
|
|
622
|
-
const r =
|
|
639
|
+
const ee = () => {
|
|
640
|
+
const r = $(), e = B(), n = ge(), t = K(), o = pe(), [a, i] = R({
|
|
623
641
|
currentInput: "",
|
|
624
642
|
isEnteringArg: !1,
|
|
625
643
|
output: [],
|
|
@@ -631,8 +649,8 @@ const X = () => {
|
|
|
631
649
|
});
|
|
632
650
|
A(() => {
|
|
633
651
|
}, [o]), A(() => {
|
|
634
|
-
|
|
635
|
-
...
|
|
652
|
+
i((s) => ({
|
|
653
|
+
...s,
|
|
636
654
|
history: {
|
|
637
655
|
commands: n.history.storedCommands,
|
|
638
656
|
position: n.history.position,
|
|
@@ -640,105 +658,100 @@ const X = () => {
|
|
|
640
658
|
}
|
|
641
659
|
}));
|
|
642
660
|
}, [n.history, o]);
|
|
643
|
-
const
|
|
644
|
-
setCurrentInput:
|
|
645
|
-
|
|
661
|
+
const c = {
|
|
662
|
+
setCurrentInput: y((s) => {
|
|
663
|
+
C.debug("[CitadelActions] setCurrentInput: ", s), i((l) => ({ ...l, currentInput: s }));
|
|
646
664
|
}, []),
|
|
647
|
-
setIsEnteringArg:
|
|
648
|
-
|
|
665
|
+
setIsEnteringArg: y((s) => {
|
|
666
|
+
C.debug("[CitadelActions] setIsEnteringArg: ", s), i((l) => ({ ...l, isEnteringArg: s }));
|
|
649
667
|
}, []),
|
|
650
|
-
addOutput:
|
|
651
|
-
|
|
652
|
-
...
|
|
653
|
-
output: [...
|
|
668
|
+
addOutput: y((s) => {
|
|
669
|
+
C.debug("[CitadelActions]addOutput: ", s), i((l) => ({
|
|
670
|
+
...l,
|
|
671
|
+
output: [...l.output, s]
|
|
654
672
|
}));
|
|
655
673
|
}, []),
|
|
656
|
-
executeCommand:
|
|
657
|
-
const
|
|
658
|
-
if (!
|
|
659
|
-
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);
|
|
660
678
|
return;
|
|
661
679
|
}
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
...
|
|
665
|
-
output: [...
|
|
680
|
+
const h = new J(t);
|
|
681
|
+
i((p) => ({
|
|
682
|
+
...p,
|
|
683
|
+
output: [...p.output, h]
|
|
666
684
|
}));
|
|
667
685
|
try {
|
|
668
|
-
const
|
|
686
|
+
const p = new Promise((u, k) => {
|
|
669
687
|
setTimeout(() => {
|
|
670
|
-
|
|
688
|
+
k(new Error("Request timed out"));
|
|
671
689
|
}, r.commandTimeoutMs);
|
|
672
|
-
}),
|
|
673
|
-
|
|
674
|
-
|
|
690
|
+
}), S = t.arguments.map((u) => u.value || ""), v = await Promise.race([
|
|
691
|
+
l.handler(S),
|
|
692
|
+
p
|
|
675
693
|
]);
|
|
676
|
-
if (!(
|
|
694
|
+
if (!(v instanceof T))
|
|
677
695
|
throw new Error(
|
|
678
|
-
`The ${
|
|
696
|
+
`The ${s.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
679
697
|
For example:
|
|
680
698
|
return new JsonCommandResult({ text: "Hello World" });
|
|
681
|
-
Check the definition of the ${
|
|
699
|
+
Check the definition of the ${s.join(".")} command and update the return type for its handler.`
|
|
682
700
|
);
|
|
683
|
-
|
|
684
|
-
...
|
|
685
|
-
output:
|
|
686
|
-
(
|
|
701
|
+
v.markSuccess(), i((u) => ({
|
|
702
|
+
...u,
|
|
703
|
+
output: u.output.map(
|
|
704
|
+
(k) => k.id === h.id ? { ...k, result: v } : k
|
|
687
705
|
)
|
|
688
706
|
}));
|
|
689
|
-
} catch (
|
|
690
|
-
const
|
|
691
|
-
|
|
707
|
+
} catch (p) {
|
|
708
|
+
const S = new Ne(
|
|
709
|
+
p instanceof Error ? p.message : "Unknown error"
|
|
692
710
|
);
|
|
693
|
-
|
|
694
|
-
...
|
|
695
|
-
output:
|
|
696
|
-
(
|
|
711
|
+
S.markFailure(), i((v) => ({
|
|
712
|
+
...v,
|
|
713
|
+
output: v.output.map(
|
|
714
|
+
(u) => u.id === h.id ? { ...u, result: S } : u
|
|
697
715
|
)
|
|
698
716
|
}));
|
|
699
717
|
}
|
|
700
718
|
}, [e, r.commandTimeoutMs, t]),
|
|
701
|
-
clearHistory:
|
|
719
|
+
clearHistory: y(async () => {
|
|
702
720
|
try {
|
|
703
721
|
await n.clear();
|
|
704
|
-
} catch (
|
|
705
|
-
console.warn("Failed to clear history:",
|
|
722
|
+
} catch (s) {
|
|
723
|
+
console.warn("Failed to clear history:", s);
|
|
706
724
|
}
|
|
707
725
|
}, [n])
|
|
708
|
-
}, d = b(() => e.getCompletions_s(t.path()), [t, e]), c = b(() => e.getCompletions(t.path()), [t, e]);
|
|
709
|
-
return {
|
|
710
|
-
state: s,
|
|
711
|
-
actions: l,
|
|
712
|
-
getAvailableCommands_s: d,
|
|
713
|
-
getAvailableCommandSegments: c
|
|
714
726
|
};
|
|
715
|
-
|
|
727
|
+
return { state: a, actions: c };
|
|
728
|
+
}, Me = ({ onOpen: r, onClose: e, isVisible: n, showCitadelKey: t }) => {
|
|
716
729
|
A(() => {
|
|
717
|
-
const o = (
|
|
718
|
-
var
|
|
719
|
-
!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());
|
|
720
733
|
};
|
|
721
734
|
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
722
735
|
}, [r, e, n, t]);
|
|
723
|
-
}, 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 = {
|
|
724
737
|
panelContainer: De,
|
|
725
|
-
innerContainer:
|
|
738
|
+
innerContainer: Te,
|
|
726
739
|
inputSection: Ue,
|
|
727
|
-
resizeHandle:
|
|
728
|
-
citadel_slideUp:
|
|
729
|
-
citadel_slideDown:
|
|
730
|
-
inlineContainer:
|
|
740
|
+
resizeHandle: je,
|
|
741
|
+
citadel_slideUp: Fe,
|
|
742
|
+
citadel_slideDown: Oe,
|
|
743
|
+
inlineContainer: Le
|
|
731
744
|
}, $e = (r) => {
|
|
732
|
-
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]);
|
|
733
746
|
return A(() => {
|
|
734
747
|
if (t) {
|
|
735
|
-
const
|
|
748
|
+
const i = setTimeout(() => {
|
|
736
749
|
t();
|
|
737
750
|
}, 200);
|
|
738
|
-
return () => clearTimeout(
|
|
751
|
+
return () => clearTimeout(i);
|
|
739
752
|
}
|
|
740
753
|
}, [n, t]), {
|
|
741
|
-
style:
|
|
754
|
+
style: D(() => ({
|
|
742
755
|
opacity: e ? 1 : 0,
|
|
743
756
|
transform: e ? "translateY(0)" : n ? "translateY(100%)" : "translateY(-100%)",
|
|
744
757
|
transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
|
|
@@ -751,19 +764,19 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
751
764
|
"data-testid": "spinner",
|
|
752
765
|
className: "animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"
|
|
753
766
|
}
|
|
754
|
-
),
|
|
767
|
+
), We = ({
|
|
755
768
|
command: r,
|
|
756
769
|
timestamp: e,
|
|
757
770
|
status: n
|
|
758
|
-
}) => /* @__PURE__ */
|
|
759
|
-
/* @__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: [
|
|
760
773
|
"> ",
|
|
761
774
|
r.split(" ").map((t, o) => {
|
|
762
|
-
const
|
|
763
|
-
return /* @__PURE__ */
|
|
775
|
+
const a = t.startsWith("<") && t.endsWith(">");
|
|
776
|
+
return /* @__PURE__ */ N(
|
|
764
777
|
"span",
|
|
765
778
|
{
|
|
766
|
-
className:
|
|
779
|
+
className: a ? "text-green-400" : "text-gray-200",
|
|
767
780
|
children: [
|
|
768
781
|
o > 0 ? " " : "",
|
|
769
782
|
t
|
|
@@ -775,23 +788,23 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
775
788
|
] }),
|
|
776
789
|
/* @__PURE__ */ m("span", { className: "text-gray-400", children: "·" }),
|
|
777
790
|
/* @__PURE__ */ m("span", { className: "text-gray-500", children: e }),
|
|
778
|
-
n ===
|
|
779
|
-
n ===
|
|
791
|
+
n === F.Pending && /* @__PURE__ */ m(Ke, {}),
|
|
792
|
+
n === F.Success && /* @__PURE__ */ m(
|
|
780
793
|
"div",
|
|
781
794
|
{
|
|
782
795
|
"data-testid": "success-indicator",
|
|
783
796
|
className: "w-4 h-4 rounded-full bg-green-500"
|
|
784
797
|
}
|
|
785
798
|
),
|
|
786
|
-
(n ===
|
|
799
|
+
(n === F.Timeout || n === F.Failure) && /* @__PURE__ */ m(
|
|
787
800
|
"div",
|
|
788
801
|
{
|
|
789
802
|
"data-testid": "success-indicator",
|
|
790
803
|
className: "w-4 h-4 rounded-full bg-red-500"
|
|
791
804
|
}
|
|
792
805
|
)
|
|
793
|
-
] }),
|
|
794
|
-
const n =
|
|
806
|
+
] }), qe = ({ output: r, outputRef: e }) => {
|
|
807
|
+
const n = $(), t = y(() => {
|
|
795
808
|
if (e.current) {
|
|
796
809
|
const o = e.current;
|
|
797
810
|
requestAnimationFrame(() => {
|
|
@@ -801,9 +814,9 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
801
814
|
}, [e]);
|
|
802
815
|
return A(() => {
|
|
803
816
|
if (t(), e.current) {
|
|
804
|
-
const o = e.current.getElementsByTagName("img"),
|
|
805
|
-
if (
|
|
806
|
-
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);
|
|
807
820
|
}
|
|
808
821
|
}, [r, t, e]), /* @__PURE__ */ m(
|
|
809
822
|
"div",
|
|
@@ -811,9 +824,9 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
811
824
|
ref: e,
|
|
812
825
|
className: "h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",
|
|
813
826
|
"data-testid": "citadel-command-output",
|
|
814
|
-
children: r.map((o
|
|
827
|
+
children: r.map((o) => /* @__PURE__ */ N("div", { className: "mb-4 last:mb-0", children: [
|
|
815
828
|
/* @__PURE__ */ m(
|
|
816
|
-
|
|
829
|
+
We,
|
|
817
830
|
{
|
|
818
831
|
command: o.command.join(" "),
|
|
819
832
|
timestamp: new Date(o.timestamp).toLocaleTimeString(),
|
|
@@ -821,10 +834,10 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
821
834
|
}
|
|
822
835
|
),
|
|
823
836
|
/* @__PURE__ */ m("pre", { className: `text-gray-200 whitespace-pre font-mono ${n.outputFontSize}`, children: o.result.render() })
|
|
824
|
-
] },
|
|
837
|
+
] }, o.id))
|
|
825
838
|
}
|
|
826
839
|
);
|
|
827
|
-
},
|
|
840
|
+
}, Ve = {
|
|
828
841
|
blink: {
|
|
829
842
|
character: "▋",
|
|
830
843
|
speed: 530,
|
|
@@ -845,23 +858,23 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
845
858
|
speed: 120,
|
|
846
859
|
color: "#fff"
|
|
847
860
|
}
|
|
848
|
-
},
|
|
861
|
+
}, oe = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], se = ["|", "/", "-", "\\"], Ye = ({
|
|
849
862
|
style: r = { type: "blink" },
|
|
850
863
|
isValid: e = !0,
|
|
851
864
|
errorMessage: n
|
|
852
865
|
}) => {
|
|
853
|
-
const t =
|
|
854
|
-
...
|
|
866
|
+
const t = D(() => ({
|
|
867
|
+
...Ve[r.type],
|
|
855
868
|
...r
|
|
856
|
-
}), [r]), [o,
|
|
869
|
+
}), [r]), [o, a] = R(!0), [i, c] = R(0);
|
|
857
870
|
A(() => {
|
|
858
871
|
if (t.speed === 0) return;
|
|
859
|
-
const
|
|
860
|
-
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));
|
|
861
874
|
}, t.speed);
|
|
862
|
-
return () => clearInterval(
|
|
875
|
+
return () => clearInterval(h);
|
|
863
876
|
}, [t.type, t.speed]);
|
|
864
|
-
const
|
|
877
|
+
const s = D(() => ({
|
|
865
878
|
color: e ? t.color : "#ff4444",
|
|
866
879
|
transition: "color 0.15s ease-in-out"
|
|
867
880
|
}), [e, t.color]);
|
|
@@ -869,148 +882,144 @@ Check the definition of the ${u.join(".")} command and update the return type fo
|
|
|
869
882
|
"span",
|
|
870
883
|
{
|
|
871
884
|
className: `command-cursor ${e ? "" : "animate-shake"}`,
|
|
872
|
-
style:
|
|
885
|
+
style: s,
|
|
873
886
|
title: n,
|
|
874
|
-
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 : " "
|
|
875
888
|
}
|
|
876
889
|
) });
|
|
877
890
|
};
|
|
878
|
-
function
|
|
891
|
+
function Be(r, e) {
|
|
879
892
|
switch (e.type) {
|
|
880
893
|
case "set":
|
|
881
|
-
return
|
|
894
|
+
return C.debug(`[inputStateReducer] InputState changing from ${r} to ${e.state}`), e.state;
|
|
882
895
|
default:
|
|
883
896
|
return r;
|
|
884
897
|
}
|
|
885
898
|
}
|
|
886
|
-
const
|
|
887
|
-
const { state: r } =
|
|
888
|
-
|
|
889
|
-
},
|
|
890
|
-
const
|
|
891
|
-
return
|
|
892
|
-
}, [e, t]),
|
|
893
|
-
if (!
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
return Array.from(g.values()).filter(() => {
|
|
899
|
-
const w = l();
|
|
900
|
-
return w.type !== "word" ? !1 : w.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());
|
|
901
911
|
});
|
|
902
|
-
}, [
|
|
903
|
-
const
|
|
904
|
-
(
|
|
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())
|
|
905
915
|
);
|
|
906
|
-
return
|
|
907
|
-
}, [e, t]),
|
|
908
|
-
const
|
|
909
|
-
return
|
|
910
|
-
(
|
|
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())
|
|
911
921
|
);
|
|
912
|
-
}, [e, t]),
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
return !
|
|
916
|
-
}, [
|
|
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) => {
|
|
917
927
|
if (r.history.position === null) {
|
|
918
|
-
if (
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
921
|
-
if (
|
|
922
|
-
const
|
|
923
|
-
if (
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
return;
|
|
927
|
-
}
|
|
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;
|
|
928
936
|
} else
|
|
929
937
|
return;
|
|
930
|
-
else if (
|
|
931
|
-
const
|
|
932
|
-
|
|
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");
|
|
933
942
|
return;
|
|
934
943
|
} else
|
|
935
944
|
return;
|
|
936
945
|
}
|
|
937
|
-
if (o
|
|
938
|
-
const
|
|
939
|
-
if (
|
|
940
|
-
|
|
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");
|
|
941
950
|
return;
|
|
942
951
|
}
|
|
943
952
|
}
|
|
944
953
|
}
|
|
945
|
-
}, [
|
|
946
|
-
|
|
947
|
-
}, [t]), k =
|
|
948
|
-
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))
|
|
949
958
|
return !0;
|
|
950
|
-
const { currentInput:
|
|
951
|
-
switch (
|
|
959
|
+
const { currentInput: g, isEnteringArg: E } = f, I = ae(g);
|
|
960
|
+
switch (d.key) {
|
|
952
961
|
case "Backspace":
|
|
953
|
-
return
|
|
962
|
+
return g === "" && (d.preventDefault(), t.size() > 0 && t.pop(), i("idle")), !0;
|
|
954
963
|
case "Enter": {
|
|
955
|
-
if (
|
|
964
|
+
if (d.preventDefault(), I.isQuoted && !I.isComplete)
|
|
956
965
|
return !0;
|
|
957
|
-
if (o === "entering_argument" ||
|
|
958
|
-
const
|
|
959
|
-
|
|
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));
|
|
960
969
|
}
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
970
|
+
const z = t.path(), U = e.getCommand(z);
|
|
971
|
+
if (!U)
|
|
963
972
|
return !1;
|
|
964
|
-
const
|
|
965
|
-
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);
|
|
966
975
|
}
|
|
967
976
|
case "ArrowUp":
|
|
968
|
-
return
|
|
969
|
-
const
|
|
970
|
-
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;
|
|
971
980
|
})();
|
|
972
981
|
case "ArrowDown":
|
|
973
|
-
return
|
|
974
|
-
const
|
|
975
|
-
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;
|
|
976
985
|
})();
|
|
977
986
|
default: {
|
|
978
|
-
if (!
|
|
979
|
-
const
|
|
980
|
-
if (!
|
|
981
|
-
return
|
|
987
|
+
if (!E && d.key.length === 1) {
|
|
988
|
+
const z = g + d.key;
|
|
989
|
+
if (!p(z))
|
|
990
|
+
return d.preventDefault(), !1;
|
|
982
991
|
}
|
|
983
992
|
return !0;
|
|
984
993
|
}
|
|
985
994
|
}
|
|
986
995
|
}, [
|
|
987
996
|
o,
|
|
988
|
-
|
|
989
|
-
|
|
997
|
+
p,
|
|
998
|
+
c,
|
|
990
999
|
n,
|
|
991
|
-
|
|
1000
|
+
u,
|
|
992
1001
|
e,
|
|
993
1002
|
t
|
|
994
1003
|
]);
|
|
995
1004
|
return {
|
|
996
|
-
handleInputChange:
|
|
1005
|
+
handleInputChange: v,
|
|
997
1006
|
handleKeyDown: k,
|
|
998
1007
|
inputState: o,
|
|
999
|
-
setInputStateWithLogging:
|
|
1008
|
+
setInputStateWithLogging: i,
|
|
1000
1009
|
// Expose internal functions for testing
|
|
1001
|
-
findMatchingCommands:
|
|
1002
|
-
getAutocompleteSuggestion:
|
|
1003
|
-
getAvailableNodes:
|
|
1004
|
-
getNextExpectedSegment:
|
|
1005
|
-
isValidCommandInput:
|
|
1010
|
+
findMatchingCommands: l,
|
|
1011
|
+
getAutocompleteSuggestion: h,
|
|
1012
|
+
getAvailableNodes: s,
|
|
1013
|
+
getNextExpectedSegment: c,
|
|
1014
|
+
isValidCommandInput: p
|
|
1006
1015
|
};
|
|
1007
1016
|
};
|
|
1008
|
-
function
|
|
1017
|
+
function ae(r) {
|
|
1009
1018
|
const e = [];
|
|
1010
1019
|
let n = "", t = !1, o;
|
|
1011
|
-
for (let
|
|
1012
|
-
const
|
|
1013
|
-
(
|
|
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;
|
|
1014
1023
|
}
|
|
1015
1024
|
return {
|
|
1016
1025
|
words: e,
|
|
@@ -1020,8 +1029,8 @@ function te(r) {
|
|
|
1020
1029
|
isComplete: !t && !n
|
|
1021
1030
|
};
|
|
1022
1031
|
}
|
|
1023
|
-
const
|
|
1024
|
-
const r =
|
|
1032
|
+
const Je = () => {
|
|
1033
|
+
const r = K(), [e, n] = R(0);
|
|
1025
1034
|
return A(() => {
|
|
1026
1035
|
const t = {
|
|
1027
1036
|
update: () => {
|
|
@@ -1032,66 +1041,64 @@ const Ge = () => {
|
|
|
1032
1041
|
r.unsubscribe(t);
|
|
1033
1042
|
};
|
|
1034
1043
|
}, [r]), e;
|
|
1035
|
-
},
|
|
1044
|
+
}, Qe = ({
|
|
1036
1045
|
state: r,
|
|
1037
1046
|
actions: e
|
|
1038
1047
|
}) => {
|
|
1039
|
-
const n =
|
|
1040
|
-
handleKeyDown:
|
|
1041
|
-
handleInputChange:
|
|
1042
|
-
inputState:
|
|
1043
|
-
setInputStateWithLogging:
|
|
1044
|
-
getNextExpectedSegment:
|
|
1045
|
-
} =
|
|
1046
|
-
const
|
|
1047
|
-
await Promise.resolve(
|
|
1048
|
-
}, k = (
|
|
1049
|
-
|
|
1050
|
-
},
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1053
|
-
|
|
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);
|
|
1054
1063
|
};
|
|
1055
1064
|
A(() => {
|
|
1056
|
-
n.current && n.current.focus(),
|
|
1057
|
-
}, [
|
|
1058
|
-
if (
|
|
1059
|
-
const
|
|
1060
|
-
let
|
|
1061
|
-
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) {
|
|
1062
1071
|
case "word":
|
|
1063
|
-
|
|
1072
|
+
E = "entering_command", e.setIsEnteringArg(!1);
|
|
1064
1073
|
break;
|
|
1065
1074
|
case "argument":
|
|
1066
|
-
|
|
1075
|
+
E = "entering_argument", e.setIsEnteringArg(!0);
|
|
1067
1076
|
break;
|
|
1068
1077
|
}
|
|
1069
|
-
|
|
1070
|
-
}, [
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
/* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children:
|
|
1080
|
-
|
|
1081
|
-
] }, "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);
|
|
1082
1090
|
}
|
|
1083
|
-
return /* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children:
|
|
1085
|
-
|
|
1086
|
-
] }, "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);
|
|
1087
1095
|
});
|
|
1088
|
-
|
|
1089
|
-
}, [
|
|
1090
|
-
const [N, w] = 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("");
|
|
1091
1098
|
return A(() => {
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
}, [
|
|
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: [
|
|
1095
1102
|
/* @__PURE__ */ m("style", { children: `
|
|
1096
1103
|
@keyframes subtleGlow {
|
|
1097
1104
|
0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
|
|
@@ -1101,11 +1108,11 @@ const Ge = () => {
|
|
|
1101
1108
|
animation: subtleGlow 0.4s ease-in-out;
|
|
1102
1109
|
}
|
|
1103
1110
|
` }),
|
|
1104
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
|
|
1105
1112
|
/* @__PURE__ */ m("div", { className: "text-gray-400 font-mono", children: ">" }),
|
|
1106
|
-
/* @__PURE__ */
|
|
1107
|
-
|
|
1108
|
-
/* @__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: [
|
|
1109
1116
|
/* @__PURE__ */ m(
|
|
1110
1117
|
"input",
|
|
1111
1118
|
{
|
|
@@ -1114,13 +1121,13 @@ const Ge = () => {
|
|
|
1114
1121
|
role: "textbox",
|
|
1115
1122
|
value: r.currentInput,
|
|
1116
1123
|
onChange: k,
|
|
1117
|
-
onKeyDown:
|
|
1118
|
-
onPaste:
|
|
1124
|
+
onKeyDown: u,
|
|
1125
|
+
onPaste: d,
|
|
1119
1126
|
"data-testid": "citadel-command-input",
|
|
1120
|
-
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" : ""}`,
|
|
1121
1128
|
spellCheck: !1,
|
|
1122
1129
|
autoComplete: "off",
|
|
1123
|
-
placeholder:
|
|
1130
|
+
placeholder: w
|
|
1124
1131
|
}
|
|
1125
1132
|
),
|
|
1126
1133
|
/* @__PURE__ */ m(
|
|
@@ -1132,12 +1139,12 @@ const Ge = () => {
|
|
|
1132
1139
|
transition: "left 0.05s ease-out"
|
|
1133
1140
|
},
|
|
1134
1141
|
children: /* @__PURE__ */ m(
|
|
1135
|
-
|
|
1142
|
+
Ye,
|
|
1136
1143
|
{
|
|
1137
1144
|
style: {
|
|
1138
|
-
type:
|
|
1139
|
-
color:
|
|
1140
|
-
speed:
|
|
1145
|
+
type: S.cursorType ?? _.cursorType,
|
|
1146
|
+
color: S.cursorColor || _.cursorColor,
|
|
1147
|
+
speed: S.cursorSpeed || _.cursorSpeed
|
|
1141
1148
|
}
|
|
1142
1149
|
}
|
|
1143
1150
|
)
|
|
@@ -1147,116 +1154,120 @@ const Ge = () => {
|
|
|
1147
1154
|
] })
|
|
1148
1155
|
] })
|
|
1149
1156
|
] });
|
|
1150
|
-
},
|
|
1151
|
-
const r = B(), e =
|
|
1152
|
-
|
|
1153
|
-
const a =
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
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);
|
|
1176
|
+
}
|
|
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: [
|
|
1165
1182
|
"- ",
|
|
1166
|
-
|
|
1183
|
+
s.description
|
|
1167
1184
|
] })
|
|
1168
|
-
] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: a == null ? void 0 : a.map((
|
|
1169
|
-
const
|
|
1170
|
-
if (C === c) return h;
|
|
1171
|
-
let f = 0;
|
|
1172
|
-
for (; f < c.name.length && f < C.name.length && c.name[f].toLowerCase() === C.name[f].toLowerCase(); )
|
|
1173
|
-
f++;
|
|
1174
|
-
return Math.max(h, f + 1);
|
|
1175
|
-
}, 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;
|
|
1176
1187
|
return /* @__PURE__ */ m(
|
|
1177
1188
|
"div",
|
|
1178
1189
|
{
|
|
1179
1190
|
className: "px-2 py-1 rounded bg-gray-800 mr-2 last:mr-0",
|
|
1180
|
-
children: /* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */ m("strong", { className: "underline", children:
|
|
1182
|
-
|
|
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)
|
|
1183
1194
|
] })
|
|
1184
1195
|
},
|
|
1185
|
-
|
|
1196
|
+
l.name
|
|
1186
1197
|
);
|
|
1187
1198
|
}) }) }) });
|
|
1188
|
-
},
|
|
1199
|
+
}, fe = ({
|
|
1189
1200
|
state: r,
|
|
1190
1201
|
actions: e,
|
|
1191
1202
|
outputRef: n
|
|
1192
|
-
}) => /* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(
|
|
1194
|
-
/* @__PURE__ */
|
|
1195
|
-
/* @__PURE__ */ m(
|
|
1196
|
-
/* @__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, {})
|
|
1197
1208
|
] })
|
|
1198
|
-
] }),
|
|
1199
|
-
const [r, e] = R(!1), [n, t] = R(!1), o =
|
|
1200
|
-
|
|
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({
|
|
1201
1212
|
onOpen: () => e(!0),
|
|
1202
1213
|
onClose: () => t(!0),
|
|
1203
1214
|
isVisible: r,
|
|
1204
1215
|
showCitadelKey: o.showCitadelKey || "."
|
|
1205
1216
|
});
|
|
1206
|
-
const
|
|
1207
|
-
var
|
|
1208
|
-
if (!
|
|
1209
|
-
const
|
|
1210
|
-
Math.max(
|
|
1211
|
-
|
|
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
|
|
1212
1223
|
);
|
|
1213
|
-
|
|
1214
|
-
}, [o.maxHeight, o.minHeight]), k =
|
|
1215
|
-
|
|
1216
|
-
}, [
|
|
1217
|
-
|
|
1218
|
-
}, [
|
|
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]);
|
|
1219
1230
|
A(() => () => {
|
|
1220
|
-
document.removeEventListener("mousemove",
|
|
1221
|
-
}, [
|
|
1222
|
-
const
|
|
1231
|
+
document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", k);
|
|
1232
|
+
}, [u, k]);
|
|
1233
|
+
const f = y(() => {
|
|
1223
1234
|
n && (e(!1), t(!1));
|
|
1224
1235
|
}, [n]);
|
|
1225
1236
|
return $e({
|
|
1226
1237
|
isVisible: r,
|
|
1227
1238
|
isClosing: n,
|
|
1228
|
-
onAnimationComplete:
|
|
1229
|
-
}), r ? /* @__PURE__ */
|
|
1239
|
+
onAnimationComplete: f
|
|
1240
|
+
}), r ? /* @__PURE__ */ N(
|
|
1230
1241
|
"div",
|
|
1231
1242
|
{
|
|
1232
|
-
ref:
|
|
1243
|
+
ref: s,
|
|
1233
1244
|
className: `panelContainer ${r ? "citadel_slideUp" : ""} ${n ? "citadel_slideDown" : ""}`,
|
|
1234
1245
|
style: {
|
|
1235
|
-
...
|
|
1246
|
+
...a ? { height: a } : void 0,
|
|
1236
1247
|
maxHeight: o.maxHeight
|
|
1237
1248
|
},
|
|
1238
1249
|
children: [
|
|
1239
|
-
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown:
|
|
1250
|
+
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: d }),
|
|
1240
1251
|
/* @__PURE__ */ m(
|
|
1241
|
-
|
|
1252
|
+
fe,
|
|
1242
1253
|
{
|
|
1243
|
-
state:
|
|
1244
|
-
actions:
|
|
1245
|
-
outputRef:
|
|
1254
|
+
state: S,
|
|
1255
|
+
actions: v,
|
|
1256
|
+
outputRef: c
|
|
1246
1257
|
}
|
|
1247
1258
|
)
|
|
1248
1259
|
]
|
|
1249
1260
|
}
|
|
1250
1261
|
) : null;
|
|
1251
|
-
},
|
|
1252
|
-
const { state: r, actions: e } =
|
|
1262
|
+
}, en = () => {
|
|
1263
|
+
const { state: r, actions: e } = ee(), n = H(null);
|
|
1253
1264
|
return /* @__PURE__ */ m(
|
|
1254
1265
|
"div",
|
|
1255
1266
|
{
|
|
1256
1267
|
className: "inlineContainer",
|
|
1257
1268
|
"data-testid": "citadel-inline-container",
|
|
1258
1269
|
children: /* @__PURE__ */ m(
|
|
1259
|
-
|
|
1270
|
+
fe,
|
|
1260
1271
|
{
|
|
1261
1272
|
state: r,
|
|
1262
1273
|
actions: e,
|
|
@@ -1265,7 +1276,7 @@ const Ge = () => {
|
|
|
1265
1276
|
)
|
|
1266
1277
|
}
|
|
1267
1278
|
);
|
|
1268
|
-
},
|
|
1279
|
+
}, ie = `:host {
|
|
1269
1280
|
--citadel-bg: rgb(17, 24, 39);
|
|
1270
1281
|
--citadel-text: rgba(255, 255, 255, 0.87);
|
|
1271
1282
|
--citadel-border: rgb(55, 65, 81);
|
|
@@ -1369,7 +1380,7 @@ a:hover {
|
|
|
1369
1380
|
.text-left {
|
|
1370
1381
|
text-align: left;
|
|
1371
1382
|
}
|
|
1372
|
-
`,
|
|
1383
|
+
`, le = `/* Keep only component-specific styles here */
|
|
1373
1384
|
|
|
1374
1385
|
.panelContainer {
|
|
1375
1386
|
position: fixed;
|
|
@@ -1451,10 +1462,10 @@ a:hover {
|
|
|
1451
1462
|
overflow: hidden;
|
|
1452
1463
|
box-sizing: border-box;
|
|
1453
1464
|
}
|
|
1454
|
-
`,
|
|
1465
|
+
`, ce = `@tailwind base;
|
|
1455
1466
|
@tailwind components;
|
|
1456
1467
|
@tailwind utilities;
|
|
1457
|
-
`,
|
|
1468
|
+
`, nn = `*, ::before, ::after {
|
|
1458
1469
|
--tw-border-spacing-x: 0;
|
|
1459
1470
|
--tw-border-spacing-y: 0;
|
|
1460
1471
|
--tw-translate-x: 0;
|
|
@@ -2271,75 +2282,85 @@ video {
|
|
|
2271
2282
|
.last\\:mr-0:last-child {
|
|
2272
2283
|
margin-right: 0px;
|
|
2273
2284
|
}
|
|
2274
|
-
`,
|
|
2275
|
-
config: r =
|
|
2276
|
-
commandRegistry: e = new
|
|
2285
|
+
`, dn = ({
|
|
2286
|
+
config: r = _,
|
|
2287
|
+
commandRegistry: e = new Z(),
|
|
2277
2288
|
containerId: n = null
|
|
2278
2289
|
}) => {
|
|
2279
|
-
const t =
|
|
2290
|
+
const t = H(null), o = r.displayMode ?? _.displayMode ?? "panel";
|
|
2280
2291
|
return A(() => {
|
|
2281
|
-
|
|
2282
|
-
level: r.logLevel ||
|
|
2292
|
+
C.configure({
|
|
2293
|
+
level: r.logLevel || _.logLevel || Q.ERROR,
|
|
2283
2294
|
prefix: "[Citadel]"
|
|
2284
2295
|
});
|
|
2285
|
-
const
|
|
2286
|
-
if (
|
|
2287
|
-
|
|
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);
|
|
2288
2299
|
else {
|
|
2289
|
-
if (
|
|
2300
|
+
if (i) {
|
|
2290
2301
|
console.warn("[Citadel] No host available for inline mode; skipping mount.");
|
|
2291
2302
|
return;
|
|
2292
2303
|
}
|
|
2293
|
-
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);
|
|
2294
2305
|
}
|
|
2295
2306
|
return () => {
|
|
2296
|
-
var
|
|
2297
|
-
(
|
|
2307
|
+
var s;
|
|
2308
|
+
(s = a.parentElement) == null || s.removeChild(a);
|
|
2298
2309
|
};
|
|
2299
2310
|
}, [e, n, r, o]), o === "inline" && !n ? /* @__PURE__ */ m("div", { ref: t, style: { width: "100%", height: "100%" } }) : null;
|
|
2300
2311
|
};
|
|
2301
|
-
class
|
|
2312
|
+
class we extends HTMLElement {
|
|
2302
2313
|
constructor(n, t) {
|
|
2303
|
-
var
|
|
2314
|
+
var a;
|
|
2304
2315
|
super();
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2316
|
+
b(this, "shadow");
|
|
2317
|
+
b(this, "root", null);
|
|
2318
|
+
b(this, "commandRegistry");
|
|
2319
|
+
b(this, "config");
|
|
2309
2320
|
this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = n, this.config = t;
|
|
2310
|
-
const o = ((
|
|
2321
|
+
const o = ((a = this.config) == null ? void 0 : a.displayMode) ?? "panel";
|
|
2311
2322
|
this.setAttribute("data-display-mode", o);
|
|
2312
2323
|
}
|
|
2313
2324
|
connectedCallback() {
|
|
2314
2325
|
try {
|
|
2315
|
-
const t = [
|
|
2316
|
-
const
|
|
2317
|
-
return
|
|
2326
|
+
const t = [ie, le, ce, nn].map((o) => {
|
|
2327
|
+
const a = new CSSStyleSheet();
|
|
2328
|
+
return a.replaceSync(o), a;
|
|
2318
2329
|
});
|
|
2319
2330
|
this.shadow.adoptedStyleSheets = [...t];
|
|
2320
2331
|
} catch {
|
|
2321
|
-
const t = [
|
|
2332
|
+
const t = [ie, le, ce].join(`
|
|
2322
2333
|
`), o = document.createElement("style");
|
|
2323
2334
|
o.textContent = t, this.shadow.appendChild(o);
|
|
2324
2335
|
}
|
|
2325
2336
|
const n = document.createElement("div");
|
|
2326
|
-
n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root =
|
|
2327
|
-
/* @__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, {}) })
|
|
2328
2339
|
);
|
|
2329
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
|
+
}
|
|
2330
2351
|
}
|
|
2331
|
-
customElements.define("citadel-element",
|
|
2332
|
-
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, {});
|
|
2333
2354
|
export {
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
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
|
|
2345
2366
|
};
|