citadel_cli 1.4.0 → 1.4.1
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 +55 -12
- package/dist/citadel.css +472 -0
- package/dist/citadel.es.js +664 -627
- package/dist/citadel.umd.cjs +479 -0
- package/dist/citadel.umd.js +21 -8
- package/dist/components/Citadel/config/defaults.d.ts +4 -0
- package/dist/components/Citadel/config/types.d.ts +10 -0
- package/dist/components/Citadel/hooks/useGlobalShortcut.d.ts +2 -1
- package/dist/components/Citadel/hooks/useSlideAnimation.d.ts +1 -5
- package/dist/components/Citadel/types/command-dsl.d.ts +2 -1
- package/dist/components/Citadel/types/command-results.d.ts +7 -0
- package/package.json +3 -2
package/dist/citadel.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Pe = (
|
|
3
|
-
var
|
|
4
|
-
import { jsx as m, jsxs as
|
|
5
|
-
import
|
|
1
|
+
var Ie = Object.defineProperty;
|
|
2
|
+
var Pe = (t, e, n) => e in t ? Ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var y = (t, e, n) => Pe(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { jsx as m, jsxs as A, Fragment as He } from "react/jsx-runtime";
|
|
5
|
+
import $, { createContext as Re, useState as _, useMemo as P, useEffect as I, useContext as Z, useCallback as f, useReducer as _e, useRef as T, useLayoutEffect as Me } from "react";
|
|
6
6
|
import { createRoot as Te } from "react-dom/client";
|
|
7
|
-
var
|
|
8
|
-
class
|
|
7
|
+
var V = /* @__PURE__ */ ((t) => (t.Pending = "pending", t.Success = "success", t.Failure = "failure", t.Timeout = "timeout", t))(V || {});
|
|
8
|
+
class K {
|
|
9
9
|
constructor(e = Date.now()) {
|
|
10
|
-
|
|
10
|
+
y(this, "_status", "pending");
|
|
11
11
|
this.timestamp = e;
|
|
12
12
|
}
|
|
13
13
|
get status() {
|
|
@@ -23,38 +23,46 @@ class W {
|
|
|
23
23
|
this._status = "timeout";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class ze extends
|
|
27
|
-
constructor(e,
|
|
28
|
-
super(
|
|
26
|
+
class ze extends K {
|
|
27
|
+
constructor(e, n) {
|
|
28
|
+
super(n), this.data = e;
|
|
29
29
|
}
|
|
30
30
|
render() {
|
|
31
31
|
return /* @__PURE__ */ m("pre", { className: "citadel-result-json", children: JSON.stringify(this.data, null, 2) });
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
class
|
|
35
|
-
constructor(e,
|
|
36
|
-
super(
|
|
34
|
+
class G extends K {
|
|
35
|
+
constructor(e, n) {
|
|
36
|
+
super(n), this.text = e;
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
39
|
return /* @__PURE__ */ m("div", { className: "citadel-result-text", children: this.text });
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
class
|
|
43
|
-
constructor(e,
|
|
44
|
-
super(
|
|
42
|
+
class De extends K {
|
|
43
|
+
constructor(e, n = "true", s = "false", r) {
|
|
44
|
+
super(r), this.value = e, this.trueText = n, this.falseText = s;
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
return /* @__PURE__ */ m("div", { className: "citadel-result-text citadel-result-boolean", children: this.value ? this.trueText : this.falseText });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class we extends K {
|
|
51
|
+
constructor(e, n) {
|
|
52
|
+
super(n), this.error = e, this.markFailure();
|
|
45
53
|
}
|
|
46
54
|
render() {
|
|
47
55
|
return /* @__PURE__ */ m("div", { className: "citadel-result-error", children: this.error });
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
|
-
class
|
|
58
|
+
class Oe extends K {
|
|
51
59
|
render() {
|
|
52
60
|
return /* @__PURE__ */ m("div", { className: "citadel-result-pending", children: "..." });
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
|
-
class Fe extends
|
|
56
|
-
constructor(e,
|
|
57
|
-
super(s), this.imageUrl = e, this.altText =
|
|
63
|
+
class Fe extends K {
|
|
64
|
+
constructor(e, n = "", s) {
|
|
65
|
+
super(s), this.imageUrl = e, this.altText = n;
|
|
58
66
|
}
|
|
59
67
|
render() {
|
|
60
68
|
return /* @__PURE__ */ m("div", { className: "citadel-result-image-wrap", children: /* @__PURE__ */ m(
|
|
@@ -67,28 +75,28 @@ class Fe extends W {
|
|
|
67
75
|
) });
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
|
-
const Le = (
|
|
71
|
-
const
|
|
72
|
-
const
|
|
78
|
+
const Le = (t) => async function() {
|
|
79
|
+
const n = t.commands.filter((s) => s.fullPath[0] !== "help").map((s) => {
|
|
80
|
+
const o = `${s.segments.map((c) => c.type === "argument" ? `<${c.name}>` : c.name).join(" ")} - ${s.description}`, a = s.segments.filter((c) => c.type === "argument" && c.description).map((c) => ` <${c.name}>: ${c.description}`);
|
|
73
81
|
return {
|
|
74
|
-
commandLine:
|
|
75
|
-
argumentLines:
|
|
82
|
+
commandLine: o,
|
|
83
|
+
argumentLines: a
|
|
76
84
|
};
|
|
77
85
|
}).sort((s, r) => s.commandLine.localeCompare(r.commandLine)).flatMap((s) => [
|
|
78
86
|
s.commandLine,
|
|
79
87
|
...s.argumentLines
|
|
80
88
|
]);
|
|
81
|
-
return
|
|
89
|
+
return n.length === 0 ? new G(
|
|
82
90
|
"No commands available yet. Add some commands to get started!"
|
|
83
|
-
) : (
|
|
91
|
+
) : (n.push("help - Show available commands"), new G(
|
|
84
92
|
`Available Commands:
|
|
85
|
-
` +
|
|
93
|
+
` + n.join(`
|
|
86
94
|
`)
|
|
87
95
|
));
|
|
88
96
|
};
|
|
89
|
-
var ie = /* @__PURE__ */ ((
|
|
97
|
+
var ie = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.ERROR = 1] = "ERROR", t[t.WARN = 2] = "WARN", t[t.INFO = 3] = "INFO", t[t.DEBUG = 4] = "DEBUG", t[t.TRACE = 5] = "TRACE", t))(ie || {});
|
|
90
98
|
const ue = !0;
|
|
91
|
-
class
|
|
99
|
+
class b {
|
|
92
100
|
static configure(e) {
|
|
93
101
|
this.level = e.level, this.prefix = e.prefix || "[Citadel]";
|
|
94
102
|
}
|
|
@@ -108,8 +116,8 @@ class k {
|
|
|
108
116
|
this.level >= 1 && console.error(this.prefix, ...e);
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
119
|
+
y(b, "level", 0), y(b, "prefix", "");
|
|
120
|
+
const x = {
|
|
113
121
|
commandTimeoutMs: 1e4,
|
|
114
122
|
cursorColor: "var(--cursor-color, #fff)",
|
|
115
123
|
cursorSpeed: 530,
|
|
@@ -123,16 +131,18 @@ const N = {
|
|
|
123
131
|
minHeight: "200",
|
|
124
132
|
outputFontSize: "0.875rem",
|
|
125
133
|
resetStateOnHide: !1,
|
|
134
|
+
closeOnEscape: !0,
|
|
126
135
|
showCitadelKey: ".",
|
|
136
|
+
showOnLoad: !1,
|
|
127
137
|
displayMode: "panel",
|
|
128
138
|
storage: {
|
|
129
139
|
type: "localStorage",
|
|
130
140
|
maxCommands: 100
|
|
131
141
|
}
|
|
132
|
-
}, Ce = async () => new
|
|
142
|
+
}, Ce = async () => new G("");
|
|
133
143
|
class ce {
|
|
134
|
-
constructor(e,
|
|
135
|
-
this.type = e, this.name =
|
|
144
|
+
constructor(e, n, s) {
|
|
145
|
+
this.type = e, this.name = n, this.description = s;
|
|
136
146
|
}
|
|
137
147
|
toString() {
|
|
138
148
|
return this.name;
|
|
@@ -144,21 +154,21 @@ class le extends ce {
|
|
|
144
154
|
}
|
|
145
155
|
}
|
|
146
156
|
class ve extends ce {
|
|
147
|
-
constructor(e,
|
|
148
|
-
super("word", e,
|
|
157
|
+
constructor(e, n) {
|
|
158
|
+
super("word", e, n);
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
|
-
class
|
|
152
|
-
constructor(e,
|
|
153
|
-
super("argument", e,
|
|
161
|
+
class q extends ce {
|
|
162
|
+
constructor(e, n, s, r) {
|
|
163
|
+
super("argument", e, n), this.value = s, this.valid = r;
|
|
154
164
|
}
|
|
155
165
|
}
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
return new ve(
|
|
159
|
-
if (
|
|
160
|
-
const e =
|
|
161
|
-
return new
|
|
166
|
+
const je = (t) => {
|
|
167
|
+
if (t.type === "word")
|
|
168
|
+
return new ve(t.name, t.description);
|
|
169
|
+
if (t.type === "argument") {
|
|
170
|
+
const e = t;
|
|
171
|
+
return new q(
|
|
162
172
|
e.name,
|
|
163
173
|
e.description,
|
|
164
174
|
e.value,
|
|
@@ -166,14 +176,14 @@ const $e = (n) => {
|
|
|
166
176
|
);
|
|
167
177
|
}
|
|
168
178
|
return new le();
|
|
169
|
-
},
|
|
170
|
-
class
|
|
171
|
-
constructor(e,
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
}, z = (t) => t.map((e) => je(e));
|
|
180
|
+
class Ue {
|
|
181
|
+
constructor(e, n, s = Ce) {
|
|
182
|
+
y(this, "_segments");
|
|
183
|
+
y(this, "_description");
|
|
174
184
|
// Used by `Help` command, etc.
|
|
175
|
-
|
|
176
|
-
this._segments = e, this._description =
|
|
185
|
+
y(this, "_handler");
|
|
186
|
+
this._segments = e, this._description = n, this._handler = s;
|
|
177
187
|
}
|
|
178
188
|
get segments() {
|
|
179
189
|
return this._segments;
|
|
@@ -197,9 +207,9 @@ class je {
|
|
|
197
207
|
return this.fullPath.join(" ") === e.fullPath.join(" ");
|
|
198
208
|
}
|
|
199
209
|
}
|
|
200
|
-
class
|
|
210
|
+
class ee {
|
|
201
211
|
constructor() {
|
|
202
|
-
|
|
212
|
+
y(this, "_commands", []);
|
|
203
213
|
}
|
|
204
214
|
get commands() {
|
|
205
215
|
return this._commands;
|
|
@@ -215,19 +225,19 @@ class X {
|
|
|
215
225
|
* @param handler Async handler executed when the command is submitted; defaults to `NoopHandler`.
|
|
216
226
|
* @throws {Error} If the segment list is empty or the path collides with an existing command.
|
|
217
227
|
*/
|
|
218
|
-
addCommand(e,
|
|
228
|
+
addCommand(e, n, s = Ce) {
|
|
219
229
|
if (e === void 0 || e.length === 0)
|
|
220
230
|
throw new Error("Command path cannot be empty");
|
|
221
|
-
const r = new
|
|
222
|
-
const c =
|
|
231
|
+
const r = new Ue(e, n, s), o = this._commands.find((a) => {
|
|
232
|
+
const c = a.segments.map(
|
|
223
233
|
(d) => d.type === "argument" ? "*" : d.name
|
|
224
234
|
).join(" "), i = e.map(
|
|
225
235
|
(d) => d.type === "argument" ? "*" : d.name
|
|
226
236
|
).join(" ");
|
|
227
237
|
return c === i;
|
|
228
238
|
});
|
|
229
|
-
if (
|
|
230
|
-
throw new Error(`Duplicate commands: '${
|
|
239
|
+
if (o)
|
|
240
|
+
throw new Error(`Duplicate commands: '${o.fullPath_s}' and '${r.fullPath_s}'`);
|
|
231
241
|
this._commands.push(r);
|
|
232
242
|
}
|
|
233
243
|
/**
|
|
@@ -237,7 +247,7 @@ class X {
|
|
|
237
247
|
* @returns True if a command was removed; otherwise false.
|
|
238
248
|
*/
|
|
239
249
|
removeCommand(e) {
|
|
240
|
-
const
|
|
250
|
+
const n = e.join(" "), s = this._commands.findIndex((r) => r.fullPath.join(" ") === n);
|
|
241
251
|
return s === -1 ? !1 : (this._commands.splice(s, 1), !0);
|
|
242
252
|
}
|
|
243
253
|
/**
|
|
@@ -247,26 +257,26 @@ class X {
|
|
|
247
257
|
* @returns The command node or undefined if not found.
|
|
248
258
|
*/
|
|
249
259
|
getCommand(e) {
|
|
250
|
-
return this._commands.find((
|
|
251
|
-
const s =
|
|
260
|
+
return this._commands.find((n) => {
|
|
261
|
+
const s = n.fullPath.join(" "), r = e.join(" ");
|
|
252
262
|
if (s === r)
|
|
253
263
|
return !0;
|
|
254
|
-
const
|
|
255
|
-
return
|
|
264
|
+
const a = n.segments.filter((c) => c.type === "word").map((c) => c.name);
|
|
265
|
+
return a.length === e.length && a.join(" ") === r;
|
|
256
266
|
});
|
|
257
267
|
}
|
|
258
268
|
commandExistsForPath(e) {
|
|
259
|
-
const
|
|
269
|
+
const n = this._commands.map(
|
|
260
270
|
(r) => r.segments.map(
|
|
261
|
-
(
|
|
271
|
+
(o) => o.type === "argument" ? "*" : o.name
|
|
262
272
|
).join(" ")
|
|
263
|
-
), s = e.map((r,
|
|
273
|
+
), s = e.map((r, o) => this._commands.some(
|
|
264
274
|
(c) => {
|
|
265
275
|
var i;
|
|
266
|
-
return ((i = c.segments[
|
|
276
|
+
return ((i = c.segments[o]) == null ? void 0 : i.type) === "argument";
|
|
267
277
|
}
|
|
268
278
|
) ? "*" : r).join(" ");
|
|
269
|
-
return
|
|
279
|
+
return n.includes(s);
|
|
270
280
|
}
|
|
271
281
|
/**
|
|
272
282
|
* Gets possible matches for a given path.
|
|
@@ -275,24 +285,24 @@ class X {
|
|
|
275
285
|
* @returns An array of completion strings.
|
|
276
286
|
*/
|
|
277
287
|
getCompletionNames(e) {
|
|
278
|
-
return this.getCompletions(e).map((
|
|
288
|
+
return this.getCompletions(e).map((n) => n.name);
|
|
279
289
|
}
|
|
280
290
|
/**
|
|
281
291
|
* Returns completion segments whose names start with the given prefix.
|
|
282
292
|
* Matching is case-insensitive.
|
|
283
293
|
*/
|
|
284
|
-
getMatchingCompletions(e,
|
|
285
|
-
const s =
|
|
294
|
+
getMatchingCompletions(e, n) {
|
|
295
|
+
const s = n.trim().toLowerCase(), r = this.getCompletions(e);
|
|
286
296
|
return s ? r.filter(
|
|
287
|
-
(
|
|
297
|
+
(o) => o.name.toLowerCase().startsWith(s)
|
|
288
298
|
) : r;
|
|
289
299
|
}
|
|
290
300
|
/**
|
|
291
301
|
* Returns a single completion when prefix matching is unambiguous.
|
|
292
302
|
* Returns undefined for ambiguous or no-match prefixes.
|
|
293
303
|
*/
|
|
294
|
-
getUniqueCompletion(e,
|
|
295
|
-
const s = this.getMatchingCompletions(e,
|
|
304
|
+
getUniqueCompletion(e, n) {
|
|
305
|
+
const s = this.getMatchingCompletions(e, n);
|
|
296
306
|
if (s.length === 1)
|
|
297
307
|
return s[0];
|
|
298
308
|
}
|
|
@@ -303,29 +313,29 @@ class X {
|
|
|
303
313
|
* @returns An array of completion strings.
|
|
304
314
|
*/
|
|
305
315
|
getCompletions(e) {
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
return
|
|
309
|
-
(i, d, g) => d === g.findIndex((u) =>
|
|
316
|
+
if (b.debug("[getCompletions] path: ", e), !e.length) {
|
|
317
|
+
const o = this._commands.map((i) => i.segments[0]), a = (i, d) => i.type === d.type && i.name === d.name;
|
|
318
|
+
return o.filter(
|
|
319
|
+
(i, d, g) => d === g.findIndex((u) => a(u, i))
|
|
310
320
|
);
|
|
311
321
|
}
|
|
312
|
-
const
|
|
313
|
-
return this._commands.filter((
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
322
|
+
const n = e.length;
|
|
323
|
+
return this._commands.filter((o) => {
|
|
324
|
+
const a = o.segments;
|
|
325
|
+
if (a.length <= n - 1)
|
|
316
326
|
return !1;
|
|
317
|
-
for (let c = 0; c <
|
|
318
|
-
const i = e[c], d =
|
|
327
|
+
for (let c = 0; c < n; c++) {
|
|
328
|
+
const i = e[c], d = a[c];
|
|
319
329
|
if (!(i === "*" && d.type === "argument") && i !== d.name)
|
|
320
330
|
return !1;
|
|
321
331
|
}
|
|
322
332
|
return !0;
|
|
323
|
-
}).filter((
|
|
324
|
-
const
|
|
325
|
-
return new c(
|
|
333
|
+
}).filter((o) => o.segments.length > n).map((o) => {
|
|
334
|
+
const a = o.segments[n], c = a.type === "argument" ? q : ve;
|
|
335
|
+
return new c(a.name, a.description);
|
|
326
336
|
}).filter(
|
|
327
|
-
(
|
|
328
|
-
(i) => i.type ===
|
|
337
|
+
(o, a, c) => a === c.findIndex(
|
|
338
|
+
(i) => i.type === o.type && i.name === o.name
|
|
329
339
|
)
|
|
330
340
|
);
|
|
331
341
|
}
|
|
@@ -335,7 +345,7 @@ class X {
|
|
|
335
345
|
}
|
|
336
346
|
class Se {
|
|
337
347
|
constructor(e) {
|
|
338
|
-
|
|
348
|
+
y(this, "config");
|
|
339
349
|
this.config = {
|
|
340
350
|
type: "localStorage",
|
|
341
351
|
maxCommands: 100,
|
|
@@ -346,43 +356,43 @@ class Se {
|
|
|
346
356
|
* Add a command to history, enforcing storage limits
|
|
347
357
|
*/
|
|
348
358
|
async addStoredCommand(e) {
|
|
349
|
-
const
|
|
350
|
-
for (
|
|
351
|
-
|
|
352
|
-
await this.saveCommands(
|
|
359
|
+
const n = await this.getStoredCommands();
|
|
360
|
+
for (n.push(e); n.length > this.config.maxCommands; )
|
|
361
|
+
n.shift();
|
|
362
|
+
await this.saveCommands(n);
|
|
353
363
|
}
|
|
354
364
|
}
|
|
355
|
-
class
|
|
356
|
-
constructor(
|
|
357
|
-
super(
|
|
358
|
-
|
|
365
|
+
class $e extends Se {
|
|
366
|
+
constructor(n) {
|
|
367
|
+
super(n);
|
|
368
|
+
y(this, "storageKey", "citadel_command_history");
|
|
359
369
|
}
|
|
360
370
|
async getStoredCommands() {
|
|
361
371
|
try {
|
|
362
|
-
const
|
|
363
|
-
return
|
|
364
|
-
commandSegments: Array.isArray(r.commandSegments) ?
|
|
372
|
+
const n = window.localStorage.getItem(this.storageKey);
|
|
373
|
+
return n ? JSON.parse(n).map((r) => ({
|
|
374
|
+
commandSegments: Array.isArray(r.commandSegments) ? z(r.commandSegments) : [],
|
|
365
375
|
timestamp: r.timestamp
|
|
366
376
|
})) : [];
|
|
367
|
-
} catch (
|
|
368
|
-
return console.warn("Failed to load commands from localStorage:",
|
|
377
|
+
} catch (n) {
|
|
378
|
+
return console.warn("Failed to load commands from localStorage:", n), [];
|
|
369
379
|
}
|
|
370
380
|
}
|
|
371
381
|
async clear() {
|
|
372
382
|
try {
|
|
373
383
|
window.localStorage.removeItem(this.storageKey);
|
|
374
|
-
} catch (
|
|
375
|
-
console.warn("Failed to clear localStorage:",
|
|
384
|
+
} catch (n) {
|
|
385
|
+
console.warn("Failed to clear localStorage:", n);
|
|
376
386
|
}
|
|
377
387
|
}
|
|
378
|
-
async saveCommands(
|
|
388
|
+
async saveCommands(n) {
|
|
379
389
|
try {
|
|
380
|
-
const s =
|
|
381
|
-
commandSegments: Array.isArray(r.commandSegments) ?
|
|
382
|
-
type:
|
|
383
|
-
name:
|
|
384
|
-
description:
|
|
385
|
-
...
|
|
390
|
+
const s = n.map((r) => ({
|
|
391
|
+
commandSegments: Array.isArray(r.commandSegments) ? z(r.commandSegments).map((o) => ({
|
|
392
|
+
type: o.type,
|
|
393
|
+
name: o.name,
|
|
394
|
+
description: o.description,
|
|
395
|
+
...o instanceof q ? { value: o.value } : {}
|
|
386
396
|
})) : [],
|
|
387
397
|
timestamp: r.timestamp
|
|
388
398
|
}));
|
|
@@ -393,41 +403,41 @@ class Ue extends Se {
|
|
|
393
403
|
}
|
|
394
404
|
}
|
|
395
405
|
class pe extends Se {
|
|
396
|
-
constructor(
|
|
397
|
-
super(
|
|
398
|
-
|
|
406
|
+
constructor(n) {
|
|
407
|
+
super(n);
|
|
408
|
+
y(this, "storedCommands", []);
|
|
399
409
|
}
|
|
400
410
|
async getStoredCommands() {
|
|
401
|
-
return this.storedCommands.map((
|
|
402
|
-
commandSegments: Array.isArray(
|
|
403
|
-
timestamp:
|
|
411
|
+
return this.storedCommands.map((n) => ({
|
|
412
|
+
commandSegments: Array.isArray(n.commandSegments) ? z(n.commandSegments) : [],
|
|
413
|
+
timestamp: n.timestamp
|
|
404
414
|
}));
|
|
405
415
|
}
|
|
406
416
|
async clear() {
|
|
407
417
|
this.storedCommands = [];
|
|
408
418
|
}
|
|
409
|
-
async saveCommands(
|
|
410
|
-
this.storedCommands =
|
|
411
|
-
commandSegments: Array.isArray(s.commandSegments) ?
|
|
419
|
+
async saveCommands(n) {
|
|
420
|
+
this.storedCommands = n.map((s) => ({
|
|
421
|
+
commandSegments: Array.isArray(s.commandSegments) ? z(s.commandSegments) : [],
|
|
412
422
|
timestamp: s.timestamp
|
|
413
423
|
}));
|
|
414
424
|
}
|
|
415
425
|
}
|
|
416
|
-
const
|
|
426
|
+
const j = class j {
|
|
417
427
|
constructor() {
|
|
418
|
-
|
|
428
|
+
y(this, "currentStorage");
|
|
419
429
|
}
|
|
420
430
|
static reset() {
|
|
421
|
-
|
|
431
|
+
j.instance = void 0;
|
|
422
432
|
}
|
|
423
433
|
static getInstance() {
|
|
424
|
-
return
|
|
434
|
+
return j.instance || (j.instance = new j()), j.instance;
|
|
425
435
|
}
|
|
426
436
|
initializeStorage(e) {
|
|
427
437
|
try {
|
|
428
|
-
e.type === "memory" ? this.currentStorage = new pe(e) : this.currentStorage = new
|
|
429
|
-
} catch (
|
|
430
|
-
console.warn("Failed to create storage, falling back to memory storage:",
|
|
438
|
+
e.type === "memory" ? this.currentStorage = new pe(e) : this.currentStorage = new $e(e);
|
|
439
|
+
} catch (n) {
|
|
440
|
+
console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new pe(e);
|
|
431
441
|
}
|
|
432
442
|
}
|
|
433
443
|
getStorage() {
|
|
@@ -436,19 +446,19 @@ const $ = class $ {
|
|
|
436
446
|
return this.currentStorage;
|
|
437
447
|
}
|
|
438
448
|
};
|
|
439
|
-
|
|
440
|
-
let
|
|
449
|
+
y(j, "instance");
|
|
450
|
+
let Q = j;
|
|
441
451
|
class xe {
|
|
442
452
|
constructor() {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
y(this, "segments", []);
|
|
454
|
+
y(this, "nullSegment", new le());
|
|
455
|
+
y(this, "observers", []);
|
|
446
456
|
}
|
|
447
457
|
subscribe(e) {
|
|
448
458
|
this.observers.push(e);
|
|
449
459
|
}
|
|
450
460
|
unsubscribe(e) {
|
|
451
|
-
this.observers = this.observers.filter((
|
|
461
|
+
this.observers = this.observers.filter((n) => n !== e);
|
|
452
462
|
}
|
|
453
463
|
notifyObservers() {
|
|
454
464
|
this.observers.forEach((e) => e.update());
|
|
@@ -469,7 +479,7 @@ class xe {
|
|
|
469
479
|
* Pushes an array of segments onto the stack
|
|
470
480
|
*/
|
|
471
481
|
pushAll(e) {
|
|
472
|
-
e.forEach((
|
|
482
|
+
e.forEach((n) => this.push(n));
|
|
473
483
|
}
|
|
474
484
|
/**
|
|
475
485
|
* Removes and returns the top segment from the stack
|
|
@@ -525,32 +535,34 @@ class xe {
|
|
|
525
535
|
return [...this.segments];
|
|
526
536
|
}
|
|
527
537
|
}
|
|
528
|
-
const
|
|
529
|
-
config:
|
|
530
|
-
commands: new
|
|
538
|
+
const Ke = {
|
|
539
|
+
config: x,
|
|
540
|
+
commands: new ee(),
|
|
531
541
|
segmentStack: new xe()
|
|
532
|
-
},
|
|
533
|
-
const [s, r] =
|
|
534
|
-
...
|
|
535
|
-
...
|
|
542
|
+
}, Y = Re(Ke), We = ({ config: t = x, commandRegistry: e, children: n }) => {
|
|
543
|
+
const [s, r] = $.useState(), [o] = _(() => new xe()), a = P(() => ({
|
|
544
|
+
...x,
|
|
545
|
+
...t,
|
|
536
546
|
// Ensure nested objects are properly merged
|
|
537
547
|
storage: {
|
|
538
|
-
...
|
|
539
|
-
...
|
|
548
|
+
...x.storage,
|
|
549
|
+
...t.storage
|
|
540
550
|
},
|
|
541
551
|
// Ensure explicit values from config take precedence
|
|
542
|
-
cursorType:
|
|
543
|
-
cursorColor:
|
|
544
|
-
cursorSpeed:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
+
cursorType: t.cursorType ?? x.cursorType,
|
|
553
|
+
cursorColor: t.cursorColor ?? x.cursorColor,
|
|
554
|
+
cursorSpeed: t.cursorSpeed ?? x.cursorSpeed,
|
|
555
|
+
closeOnEscape: t.closeOnEscape ?? x.closeOnEscape,
|
|
556
|
+
showCitadelKey: t.showCitadelKey ?? x.showCitadelKey,
|
|
557
|
+
showOnLoad: t.showOnLoad ?? x.showOnLoad
|
|
558
|
+
}), [t]);
|
|
559
|
+
I(() => {
|
|
560
|
+
Q.getInstance().initializeStorage(
|
|
561
|
+
a.storage ?? x.storage
|
|
562
|
+
), r(Q.getInstance().getStorage());
|
|
563
|
+
}, [a.storage]), I(() => {
|
|
552
564
|
if (e) {
|
|
553
|
-
if (
|
|
565
|
+
if (a.includeHelpCommand) {
|
|
554
566
|
if (!e.commandExistsForPath(["help"])) {
|
|
555
567
|
const i = Le(e);
|
|
556
568
|
e.addCommand(
|
|
@@ -563,83 +575,83 @@ const Oe = {
|
|
|
563
575
|
}
|
|
564
576
|
e.removeCommand(["help"]);
|
|
565
577
|
}
|
|
566
|
-
}, [e,
|
|
567
|
-
const c =
|
|
568
|
-
config:
|
|
569
|
-
commands: e || new
|
|
578
|
+
}, [e, a.includeHelpCommand]);
|
|
579
|
+
const c = P(() => ({
|
|
580
|
+
config: a,
|
|
581
|
+
commands: e || new ee(),
|
|
570
582
|
storage: s,
|
|
571
|
-
segmentStack:
|
|
572
|
-
}), [
|
|
573
|
-
return /* @__PURE__ */ m(
|
|
574
|
-
},
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
583
|
+
segmentStack: o
|
|
584
|
+
}), [a, e, s, o]);
|
|
585
|
+
return /* @__PURE__ */ m(Y.Provider, { value: c, children: n });
|
|
586
|
+
}, U = () => {
|
|
587
|
+
const t = Z(Y);
|
|
588
|
+
if (t === void 0)
|
|
577
589
|
throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
|
|
578
|
-
return
|
|
579
|
-
},
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
590
|
+
return t.config;
|
|
591
|
+
}, te = () => {
|
|
592
|
+
const t = Z(Y);
|
|
593
|
+
if (t === void 0)
|
|
582
594
|
throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
|
|
583
|
-
return
|
|
595
|
+
return t.commands;
|
|
584
596
|
}, be = () => {
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
597
|
+
const t = Z(Y);
|
|
598
|
+
if (t === void 0)
|
|
587
599
|
throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
|
|
588
|
-
return
|
|
589
|
-
},
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
600
|
+
return t.storage;
|
|
601
|
+
}, J = () => {
|
|
602
|
+
const t = Z(Y);
|
|
603
|
+
if (t === void 0)
|
|
592
604
|
throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
|
|
593
|
-
return
|
|
594
|
-
},
|
|
595
|
-
constructor(e,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
this.id = `output-${Date.now()}-${
|
|
605
|
+
return t.segmentStack;
|
|
606
|
+
}, X = class X {
|
|
607
|
+
constructor(e, n) {
|
|
608
|
+
y(this, "id");
|
|
609
|
+
y(this, "timestamp");
|
|
610
|
+
y(this, "command");
|
|
611
|
+
y(this, "result");
|
|
612
|
+
this.id = `output-${Date.now()}-${X.idCounter++}`, this.command = e.toArray().map((s) => s.type === "argument" ? s.value || "" : s.name), this.timestamp = Date.now(), this.result = n ?? new Oe();
|
|
601
613
|
}
|
|
602
614
|
};
|
|
603
|
-
|
|
604
|
-
let oe =
|
|
605
|
-
function
|
|
615
|
+
y(X, "idCounter", 0);
|
|
616
|
+
let oe = X;
|
|
617
|
+
function qe(t) {
|
|
606
618
|
return {
|
|
607
|
-
commandSegments:
|
|
619
|
+
commandSegments: z(t),
|
|
608
620
|
timestamp: Date.now()
|
|
609
621
|
};
|
|
610
622
|
}
|
|
611
623
|
function ke() {
|
|
612
|
-
const
|
|
624
|
+
const t = be(), [e, n] = _({
|
|
613
625
|
storedCommands: [],
|
|
614
626
|
position: null
|
|
615
|
-
}), s =
|
|
616
|
-
if (
|
|
627
|
+
}), s = f(async (c) => {
|
|
628
|
+
if (t)
|
|
617
629
|
try {
|
|
618
|
-
const i =
|
|
619
|
-
await
|
|
630
|
+
const i = qe(c);
|
|
631
|
+
await t.addStoredCommand(i), n((d) => ({
|
|
620
632
|
...d,
|
|
621
633
|
storedCommands: [...d.storedCommands, {
|
|
622
634
|
...i,
|
|
623
|
-
commandSegments:
|
|
635
|
+
commandSegments: z(i.commandSegments)
|
|
624
636
|
}],
|
|
625
637
|
position: null
|
|
626
638
|
}));
|
|
627
639
|
} catch (i) {
|
|
628
640
|
console.warn("Failed to save command to history:", i);
|
|
629
641
|
}
|
|
630
|
-
}, [
|
|
642
|
+
}, [t]), r = f(async () => t ? (await t.getStoredCommands()).map((i) => ({
|
|
631
643
|
...i,
|
|
632
|
-
commandSegments:
|
|
633
|
-
})) : [], [
|
|
634
|
-
|
|
635
|
-
if (!
|
|
644
|
+
commandSegments: z(i.commandSegments)
|
|
645
|
+
})) : [], [t]);
|
|
646
|
+
I(() => {
|
|
647
|
+
if (!t) return;
|
|
636
648
|
(async () => {
|
|
637
649
|
try {
|
|
638
|
-
const d = (await
|
|
650
|
+
const d = (await t.getStoredCommands()).map((g) => ({
|
|
639
651
|
...g,
|
|
640
|
-
commandSegments:
|
|
652
|
+
commandSegments: z(g.commandSegments)
|
|
641
653
|
}));
|
|
642
|
-
return
|
|
654
|
+
return n((g) => ({
|
|
643
655
|
...g,
|
|
644
656
|
storedCommands: d
|
|
645
657
|
})), d;
|
|
@@ -647,21 +659,21 @@ function ke() {
|
|
|
647
659
|
console.warn("Failed to load command history:", i);
|
|
648
660
|
}
|
|
649
661
|
})();
|
|
650
|
-
}, [
|
|
651
|
-
const
|
|
662
|
+
}, [t]);
|
|
663
|
+
const o = f(async (c) => {
|
|
652
664
|
const i = await r();
|
|
653
665
|
if (i.length === 0)
|
|
654
|
-
return
|
|
666
|
+
return n((u) => ({
|
|
655
667
|
...u,
|
|
656
668
|
storedCommands: [],
|
|
657
669
|
position: null
|
|
658
670
|
})), { segments: null, position: null };
|
|
659
671
|
let d = null;
|
|
660
|
-
if (c === "up" ? e.position === null ? d = i.length - 1 : e.position > 0 ? d = e.position - 1 : d = 0 : e.position === null || e.position >= i.length - 1 ? d = null : d = e.position + 1,
|
|
672
|
+
if (c === "up" ? e.position === null ? d = i.length - 1 : e.position > 0 ? d = e.position - 1 : d = 0 : e.position === null || e.position >= i.length - 1 ? d = null : d = e.position + 1, n((u) => ({
|
|
661
673
|
...u,
|
|
662
674
|
storedCommands: i.map((h) => ({
|
|
663
675
|
...h,
|
|
664
|
-
commandSegments:
|
|
676
|
+
commandSegments: z(h.commandSegments)
|
|
665
677
|
})),
|
|
666
678
|
position: d
|
|
667
679
|
})), d === null)
|
|
@@ -671,33 +683,33 @@ function ke() {
|
|
|
671
683
|
};
|
|
672
684
|
const g = i[d];
|
|
673
685
|
return g ? {
|
|
674
|
-
segments:
|
|
686
|
+
segments: z(g.commandSegments),
|
|
675
687
|
position: d
|
|
676
688
|
} : {
|
|
677
689
|
segments: [],
|
|
678
690
|
position: null
|
|
679
691
|
};
|
|
680
|
-
}, [e.position, r]),
|
|
692
|
+
}, [e.position, r]), a = f(async () => {
|
|
681
693
|
try {
|
|
682
|
-
if (!
|
|
683
|
-
await
|
|
694
|
+
if (!t) return;
|
|
695
|
+
await t.clear(), n({
|
|
684
696
|
storedCommands: [],
|
|
685
697
|
position: null
|
|
686
698
|
});
|
|
687
699
|
} catch (c) {
|
|
688
700
|
console.warn("Failed to clear command history:", c);
|
|
689
701
|
}
|
|
690
|
-
}, [
|
|
702
|
+
}, [t]);
|
|
691
703
|
return {
|
|
692
704
|
history: e,
|
|
693
705
|
addStoredCommand: s,
|
|
694
706
|
getStoredCommands: r,
|
|
695
|
-
navigateHistory:
|
|
696
|
-
clear:
|
|
707
|
+
navigateHistory: o,
|
|
708
|
+
clear: a
|
|
697
709
|
};
|
|
698
710
|
}
|
|
699
711
|
const de = () => {
|
|
700
|
-
const
|
|
712
|
+
const t = U(), e = te(), n = ke(), s = J(), r = be(), [o, a] = _({
|
|
701
713
|
currentInput: "",
|
|
702
714
|
isEnteringArg: !1,
|
|
703
715
|
output: [],
|
|
@@ -707,156 +719,160 @@ const de = () => {
|
|
|
707
719
|
storage: r
|
|
708
720
|
}
|
|
709
721
|
});
|
|
710
|
-
|
|
711
|
-
}, [r]),
|
|
712
|
-
|
|
722
|
+
I(() => {
|
|
723
|
+
}, [r]), I(() => {
|
|
724
|
+
a((i) => ({
|
|
713
725
|
...i,
|
|
714
726
|
history: {
|
|
715
|
-
commands:
|
|
716
|
-
position:
|
|
727
|
+
commands: n.history.storedCommands,
|
|
728
|
+
position: n.history.position,
|
|
717
729
|
storage: r
|
|
718
730
|
}
|
|
719
731
|
}));
|
|
720
|
-
}, [
|
|
732
|
+
}, [n.history, r]);
|
|
721
733
|
const c = {
|
|
722
|
-
setCurrentInput:
|
|
723
|
-
|
|
734
|
+
setCurrentInput: f((i) => {
|
|
735
|
+
b.debug("[CitadelActions] setCurrentInput: ", i), a((d) => ({ ...d, currentInput: i }));
|
|
724
736
|
}, []),
|
|
725
|
-
setIsEnteringArg:
|
|
726
|
-
|
|
737
|
+
setIsEnteringArg: f((i) => {
|
|
738
|
+
b.debug("[CitadelActions] setIsEnteringArg: ", i), a((d) => ({ ...d, isEnteringArg: i }));
|
|
727
739
|
}, []),
|
|
728
|
-
addOutput:
|
|
729
|
-
|
|
740
|
+
addOutput: f((i) => {
|
|
741
|
+
b.debug("[CitadelActions]addOutput: ", i), a((d) => ({
|
|
730
742
|
...d,
|
|
731
743
|
output: [...d.output, i]
|
|
732
744
|
}));
|
|
733
745
|
}, []),
|
|
734
|
-
executeCommand:
|
|
746
|
+
executeCommand: f(async () => {
|
|
735
747
|
const i = s.path(), d = e.getCommand(i);
|
|
736
748
|
if (!d) {
|
|
737
749
|
console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", i);
|
|
738
750
|
return;
|
|
739
751
|
}
|
|
740
752
|
const g = new oe(s);
|
|
741
|
-
|
|
753
|
+
a((u) => ({
|
|
742
754
|
...u,
|
|
743
755
|
output: [...u.output, g]
|
|
744
756
|
}));
|
|
745
757
|
try {
|
|
746
|
-
const u = new Promise((
|
|
758
|
+
const u = new Promise((C, k) => {
|
|
747
759
|
setTimeout(() => {
|
|
748
|
-
|
|
749
|
-
},
|
|
750
|
-
}), h = s.arguments.map((
|
|
760
|
+
k(new Error("Request timed out"));
|
|
761
|
+
}, t.commandTimeoutMs);
|
|
762
|
+
}), h = s.arguments.map((C) => C.value || ""), S = await Promise.race([
|
|
751
763
|
d.handler(h),
|
|
752
764
|
u
|
|
753
765
|
]);
|
|
754
|
-
if (!(
|
|
766
|
+
if (!(S instanceof K))
|
|
755
767
|
throw new Error(
|
|
756
768
|
`The ${i.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
757
769
|
For example:
|
|
758
770
|
return new JsonCommandResult({ text: "Hello World" });
|
|
759
771
|
Check the definition of the ${i.join(".")} command and update the return type for its handler.`
|
|
760
772
|
);
|
|
761
|
-
|
|
762
|
-
...
|
|
763
|
-
output:
|
|
764
|
-
(
|
|
773
|
+
S.markSuccess(), a((C) => ({
|
|
774
|
+
...C,
|
|
775
|
+
output: C.output.map(
|
|
776
|
+
(k) => k.id === g.id ? { ...k, result: S } : k
|
|
765
777
|
)
|
|
766
778
|
}));
|
|
767
779
|
} catch (u) {
|
|
768
780
|
const h = new we(
|
|
769
781
|
u instanceof Error ? u.message : "Unknown error"
|
|
770
782
|
);
|
|
771
|
-
h.markFailure(),
|
|
772
|
-
...
|
|
773
|
-
output:
|
|
774
|
-
(
|
|
783
|
+
h.markFailure(), a((S) => ({
|
|
784
|
+
...S,
|
|
785
|
+
output: S.output.map(
|
|
786
|
+
(C) => C.id === g.id ? { ...C, result: h } : C
|
|
775
787
|
)
|
|
776
788
|
}));
|
|
777
789
|
}
|
|
778
|
-
}, [e,
|
|
779
|
-
clearHistory:
|
|
790
|
+
}, [e, t.commandTimeoutMs, s]),
|
|
791
|
+
clearHistory: f(async () => {
|
|
780
792
|
try {
|
|
781
|
-
await
|
|
793
|
+
await n.clear();
|
|
782
794
|
} catch (i) {
|
|
783
795
|
console.warn("Failed to clear history:", i);
|
|
784
796
|
}
|
|
785
|
-
}, [
|
|
797
|
+
}, [n])
|
|
786
798
|
};
|
|
787
|
-
return { state:
|
|
788
|
-
},
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
799
|
+
return { state: o, actions: c };
|
|
800
|
+
}, Be = ({
|
|
801
|
+
onOpen: t,
|
|
802
|
+
onClose: e,
|
|
803
|
+
isVisible: n,
|
|
804
|
+
showCitadelKey: s,
|
|
805
|
+
closeOnEscape: r
|
|
806
|
+
}) => {
|
|
807
|
+
I(() => {
|
|
808
|
+
const o = (a) => {
|
|
809
|
+
var c, i;
|
|
810
|
+
!n && a.key === s && !["input", "textarea"].includes(((i = (c = a.target) == null ? void 0 : c.tagName) == null ? void 0 : i.toLowerCase()) || "") && (a.preventDefault(), t()), r && n && a.key === "Escape" && (a.preventDefault(), e());
|
|
793
811
|
};
|
|
794
|
-
return document.addEventListener("keydown",
|
|
795
|
-
}, [
|
|
796
|
-
},
|
|
797
|
-
const { isVisible: e, isClosing:
|
|
798
|
-
return
|
|
799
|
-
if (s)
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
return () => clearTimeout(o);
|
|
812
|
+
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
813
|
+
}, [t, e, n, s, r]);
|
|
814
|
+
}, Ve = 200, Ye = (t) => {
|
|
815
|
+
const { isVisible: e, isClosing: n, onAnimationComplete: s } = t, r = P(() => e ? n ? "citadel_slideDown" : "citadel_slideUp" : "", [e, n]);
|
|
816
|
+
return I(() => {
|
|
817
|
+
if (!n || !s) return;
|
|
818
|
+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
819
|
+
s();
|
|
820
|
+
return;
|
|
804
821
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
}), [e, t]),
|
|
822
|
+
const a = setTimeout(() => {
|
|
823
|
+
s();
|
|
824
|
+
}, Ve);
|
|
825
|
+
return () => clearTimeout(a);
|
|
826
|
+
}, [n, s]), {
|
|
811
827
|
animationClass: r
|
|
812
828
|
};
|
|
813
|
-
},
|
|
829
|
+
}, Je = () => /* @__PURE__ */ m(
|
|
814
830
|
"div",
|
|
815
831
|
{
|
|
816
832
|
"data-testid": "spinner",
|
|
817
833
|
className: "citadel-spinner"
|
|
818
834
|
}
|
|
819
|
-
), Ee = (
|
|
820
|
-
const e =
|
|
835
|
+
), Ee = (t) => {
|
|
836
|
+
const e = t == null ? void 0 : t.trim();
|
|
821
837
|
return e || void 0;
|
|
822
|
-
},
|
|
823
|
-
const e = Ee(
|
|
838
|
+
}, Ge = (t) => {
|
|
839
|
+
const e = Ee(t);
|
|
824
840
|
return e ? { style: { fontSize: e } } : {};
|
|
825
|
-
},
|
|
826
|
-
const
|
|
827
|
-
...
|
|
841
|
+
}, ne = (t, e) => {
|
|
842
|
+
const n = Ee(t), r = {
|
|
843
|
+
...Ge(e).style
|
|
828
844
|
};
|
|
829
|
-
return
|
|
845
|
+
return n && (r.fontFamily = n), {
|
|
830
846
|
style: Object.keys(r).length > 0 ? r : void 0
|
|
831
847
|
};
|
|
832
|
-
},
|
|
833
|
-
command:
|
|
848
|
+
}, Qe = ({
|
|
849
|
+
command: t,
|
|
834
850
|
timestamp: e,
|
|
835
|
-
status:
|
|
851
|
+
status: n,
|
|
836
852
|
fontFamily: s,
|
|
837
853
|
fontSize: r
|
|
838
854
|
}) => {
|
|
839
|
-
const
|
|
840
|
-
() =>
|
|
855
|
+
const o = P(
|
|
856
|
+
() => ne(s, r ?? "0.875rem"),
|
|
841
857
|
[s, r]
|
|
842
858
|
);
|
|
843
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ A(
|
|
844
860
|
"div",
|
|
845
861
|
{
|
|
846
862
|
className: "citadel-output-line",
|
|
847
|
-
style:
|
|
863
|
+
style: o.style,
|
|
848
864
|
children: [
|
|
849
|
-
/* @__PURE__ */
|
|
865
|
+
/* @__PURE__ */ A("span", { className: "citadel-output-command", children: [
|
|
850
866
|
"> ",
|
|
851
|
-
|
|
852
|
-
const i =
|
|
853
|
-
return /* @__PURE__ */
|
|
867
|
+
t.split(" ").map((a, c) => {
|
|
868
|
+
const i = a.startsWith("<") && a.endsWith(">");
|
|
869
|
+
return /* @__PURE__ */ A(
|
|
854
870
|
"span",
|
|
855
871
|
{
|
|
856
872
|
className: i ? "citadel-output-command-arg" : "citadel-output-command-word",
|
|
857
873
|
children: [
|
|
858
874
|
c > 0 ? " " : "",
|
|
859
|
-
|
|
875
|
+
a
|
|
860
876
|
]
|
|
861
877
|
},
|
|
862
878
|
c
|
|
@@ -865,15 +881,15 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
865
881
|
] }),
|
|
866
882
|
/* @__PURE__ */ m("span", { className: "citadel-output-separator", children: "·" }),
|
|
867
883
|
/* @__PURE__ */ m("span", { className: "citadel-output-timestamp", children: e }),
|
|
868
|
-
|
|
869
|
-
|
|
884
|
+
n === V.Pending && /* @__PURE__ */ m(Je, {}),
|
|
885
|
+
n === V.Success && /* @__PURE__ */ m(
|
|
870
886
|
"div",
|
|
871
887
|
{
|
|
872
888
|
"data-testid": "success-indicator",
|
|
873
889
|
className: "citadel-status-dot citadel-status-dot-success"
|
|
874
890
|
}
|
|
875
891
|
),
|
|
876
|
-
(
|
|
892
|
+
(n === V.Timeout || n === V.Failure) && /* @__PURE__ */ m(
|
|
877
893
|
"div",
|
|
878
894
|
{
|
|
879
895
|
"data-testid": "success-indicator",
|
|
@@ -883,39 +899,39 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
883
899
|
]
|
|
884
900
|
}
|
|
885
901
|
);
|
|
886
|
-
},
|
|
887
|
-
const
|
|
888
|
-
() =>
|
|
889
|
-
[
|
|
890
|
-
), r =
|
|
902
|
+
}, Xe = ({ output: t, outputRef: e }) => {
|
|
903
|
+
const n = U(), s = P(
|
|
904
|
+
() => ne(n.fontFamily, n.outputFontSize ?? n.fontSize),
|
|
905
|
+
[n.fontFamily, n.fontSize, n.outputFontSize]
|
|
906
|
+
), r = f(() => {
|
|
891
907
|
if (e.current) {
|
|
892
|
-
const
|
|
908
|
+
const o = e.current;
|
|
893
909
|
requestAnimationFrame(() => {
|
|
894
|
-
|
|
910
|
+
o.scrollTop = o.scrollHeight;
|
|
895
911
|
});
|
|
896
912
|
}
|
|
897
913
|
}, [e]);
|
|
898
|
-
return
|
|
914
|
+
return I(() => {
|
|
899
915
|
if (r(), e.current) {
|
|
900
|
-
const
|
|
901
|
-
if (
|
|
902
|
-
return
|
|
916
|
+
const o = e.current.getElementsByTagName("img"), a = o[o.length - 1];
|
|
917
|
+
if (a && !a.complete)
|
|
918
|
+
return a.addEventListener("load", r), () => a.removeEventListener("load", r);
|
|
903
919
|
}
|
|
904
|
-
}, [
|
|
920
|
+
}, [t, r, e]), /* @__PURE__ */ m(
|
|
905
921
|
"div",
|
|
906
922
|
{
|
|
907
923
|
ref: e,
|
|
908
924
|
className: "citadel-output",
|
|
909
925
|
"data-testid": "citadel-command-output",
|
|
910
|
-
children:
|
|
926
|
+
children: t.map((o) => /* @__PURE__ */ A("div", { className: "citadel-output-item", children: [
|
|
911
927
|
/* @__PURE__ */ m(
|
|
912
|
-
|
|
928
|
+
Qe,
|
|
913
929
|
{
|
|
914
|
-
command:
|
|
915
|
-
timestamp: new Date(
|
|
916
|
-
status:
|
|
917
|
-
fontFamily:
|
|
918
|
-
fontSize:
|
|
930
|
+
command: o.command.join(" "),
|
|
931
|
+
timestamp: new Date(o.timestamp).toLocaleTimeString(),
|
|
932
|
+
status: o.result.status,
|
|
933
|
+
fontFamily: n.fontFamily,
|
|
934
|
+
fontSize: n.fontSize
|
|
919
935
|
}
|
|
920
936
|
),
|
|
921
937
|
/* @__PURE__ */ m(
|
|
@@ -923,13 +939,13 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
923
939
|
{
|
|
924
940
|
className: "citadel-output-content",
|
|
925
941
|
style: s.style,
|
|
926
|
-
children:
|
|
942
|
+
children: o.result.render()
|
|
927
943
|
}
|
|
928
944
|
)
|
|
929
|
-
] },
|
|
945
|
+
] }, o.id))
|
|
930
946
|
}
|
|
931
947
|
);
|
|
932
|
-
},
|
|
948
|
+
}, Ze = {
|
|
933
949
|
blink: {
|
|
934
950
|
character: "▋",
|
|
935
951
|
speed: 530,
|
|
@@ -950,23 +966,23 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
950
966
|
speed: 120,
|
|
951
967
|
color: "#fff"
|
|
952
968
|
}
|
|
953
|
-
}, he = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], ge = ["|", "/", "-", "\\"],
|
|
954
|
-
style:
|
|
969
|
+
}, he = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], ge = ["|", "/", "-", "\\"], et = ({
|
|
970
|
+
style: t = { type: "blink" },
|
|
955
971
|
isValid: e = !0,
|
|
956
|
-
errorMessage:
|
|
972
|
+
errorMessage: n
|
|
957
973
|
}) => {
|
|
958
|
-
const s =
|
|
959
|
-
...
|
|
960
|
-
...
|
|
961
|
-
}), [
|
|
962
|
-
|
|
974
|
+
const s = P(() => ({
|
|
975
|
+
...Ze[t.type],
|
|
976
|
+
...t
|
|
977
|
+
}), [t]), [r, o] = _(!0), [a, c] = _(0);
|
|
978
|
+
I(() => {
|
|
963
979
|
if (s.speed === 0) return;
|
|
964
980
|
const g = setInterval(() => {
|
|
965
|
-
s.type === "blink" ?
|
|
981
|
+
s.type === "blink" ? o((u) => !u) : ["spin", "bbs"].includes(s.type) && c((u) => (u + 1) % (s.type === "bbs" ? ge.length : he.length));
|
|
966
982
|
}, s.speed);
|
|
967
983
|
return () => clearInterval(g);
|
|
968
984
|
}, [s.type, s.speed]);
|
|
969
|
-
const i =
|
|
985
|
+
const i = P(() => ({
|
|
970
986
|
color: e ? s.color : "#ff4444",
|
|
971
987
|
transition: "color 0.15s ease-in-out"
|
|
972
988
|
}), [e, s.color]);
|
|
@@ -975,113 +991,113 @@ Check the definition of the ${i.join(".")} command and update the return type fo
|
|
|
975
991
|
{
|
|
976
992
|
className: `command-cursor ${e ? "" : "animate-shake"}`,
|
|
977
993
|
style: i,
|
|
978
|
-
title:
|
|
979
|
-
children: !e &&
|
|
994
|
+
title: n,
|
|
995
|
+
children: !e && n ? "✗" : ["spin", "bbs"].includes(s.type) ? (s.type === "bbs" ? ge : he)[a] : s.type === "solid" || r ? s.character : " "
|
|
980
996
|
}
|
|
981
997
|
) });
|
|
982
998
|
};
|
|
983
|
-
function
|
|
999
|
+
function tt(t, e) {
|
|
984
1000
|
switch (e.type) {
|
|
985
1001
|
case "set":
|
|
986
|
-
return
|
|
1002
|
+
return b.debug(`[inputStateReducer] InputState changing from ${t} to ${e.state}`), e.state;
|
|
987
1003
|
default:
|
|
988
|
-
return
|
|
1004
|
+
return t;
|
|
989
1005
|
}
|
|
990
1006
|
}
|
|
991
|
-
const
|
|
992
|
-
const { state:
|
|
993
|
-
|
|
994
|
-
}, c =
|
|
1007
|
+
const nt = () => {
|
|
1008
|
+
const { state: t } = de(), e = te(), n = ke(), s = J(), [r, o] = _e(tt, "idle"), a = (l) => {
|
|
1009
|
+
o({ type: "set", state: l });
|
|
1010
|
+
}, c = f(() => {
|
|
995
1011
|
const p = e.getCompletions(s.path())[0] || s.nullSegment;
|
|
996
|
-
return
|
|
997
|
-
}, [e, s]), i =
|
|
1012
|
+
return b.debug("[getNextExpectedSegment] ", p), p;
|
|
1013
|
+
}, [e, s]), i = f(() => e.getCompletionNames(s.path()).map((p) => e.getCommand([...s.path(), p])).filter((p) => p !== void 0), [e, s]), d = f((l, p) => {
|
|
998
1014
|
if (!l) return p;
|
|
999
|
-
const
|
|
1000
|
-
return p.filter((
|
|
1001
|
-
const
|
|
1002
|
-
return !
|
|
1015
|
+
const w = s.path().length;
|
|
1016
|
+
return p.filter((D) => {
|
|
1017
|
+
const v = D.segments[w];
|
|
1018
|
+
return !v || v.type !== "word" ? !1 : v.name.toLowerCase().startsWith(l.toLowerCase());
|
|
1003
1019
|
});
|
|
1004
|
-
}, [s]), g =
|
|
1020
|
+
}, [s]), g = f((l) => {
|
|
1005
1021
|
const p = e.getUniqueCompletion(s.path(), l);
|
|
1006
1022
|
return p && p.type === "word" ? p : s.nullSegment;
|
|
1007
|
-
}, [e, s]), u =
|
|
1008
|
-
const p = s.path(),
|
|
1009
|
-
return
|
|
1010
|
-
}, [e, s]), h =
|
|
1011
|
-
|
|
1023
|
+
}, [e, s]), u = f((l) => {
|
|
1024
|
+
const p = s.path(), w = e.getCompletions(p);
|
|
1025
|
+
return w.length === 0 && l ? !1 : w.some((v) => v.type === "argument") ? !0 : e.getMatchingCompletions(p, l).some((v) => v.type === "word");
|
|
1026
|
+
}, [e, s]), h = f((l) => {
|
|
1027
|
+
b.debug("[tryAutoComplete] input: ", l);
|
|
1012
1028
|
const p = g(l);
|
|
1013
|
-
return !p || p.type === "null" ? new le() : (
|
|
1014
|
-
}, [g]),
|
|
1015
|
-
if (
|
|
1029
|
+
return !p || p.type === "null" ? new le() : (b.debug("[tryAutoComplete] result: ", p), p);
|
|
1030
|
+
}, [g]), S = f((l, p) => {
|
|
1031
|
+
if (t.history.position !== null)
|
|
1016
1032
|
return;
|
|
1017
|
-
p.setCurrentInput(l),
|
|
1018
|
-
const
|
|
1019
|
-
if (
|
|
1033
|
+
p.setCurrentInput(l), b.debug("[useCommandParser][handleInputChange] newValue: ", l);
|
|
1034
|
+
const w = c();
|
|
1035
|
+
if (w.type === "argument" || r === "entering_argument") {
|
|
1020
1036
|
const H = fe(l);
|
|
1021
1037
|
if (H.isQuoted)
|
|
1022
1038
|
if (H.isComplete) {
|
|
1023
|
-
if (!(
|
|
1024
|
-
|
|
1039
|
+
if (!(w instanceof q)) return;
|
|
1040
|
+
w.value = l.trim() || "", b.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), s.push(w), p.setCurrentInput(""), a("idle");
|
|
1025
1041
|
return;
|
|
1026
1042
|
} else
|
|
1027
1043
|
return;
|
|
1028
1044
|
else if (H.isComplete) {
|
|
1029
|
-
if (!(
|
|
1030
|
-
|
|
1045
|
+
if (!(w instanceof q)) return;
|
|
1046
|
+
w.value = l.trim() || "", b.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), s.push(w), p.setCurrentInput(""), a("idle");
|
|
1031
1047
|
return;
|
|
1032
1048
|
} else
|
|
1033
1049
|
return;
|
|
1034
1050
|
}
|
|
1035
1051
|
if (l.endsWith(" ")) {
|
|
1036
|
-
const H = l.trim().toLowerCase(),
|
|
1037
|
-
(
|
|
1052
|
+
const H = l.trim().toLowerCase(), M = e.getCompletions(s.path()).filter(
|
|
1053
|
+
(E) => E.type === "word" && E.name.toLowerCase() === H
|
|
1038
1054
|
);
|
|
1039
|
-
if (
|
|
1040
|
-
s.push(
|
|
1055
|
+
if (M.length === 1) {
|
|
1056
|
+
s.push(M[0]), p.setCurrentInput(""), a("idle");
|
|
1041
1057
|
return;
|
|
1042
1058
|
}
|
|
1043
1059
|
}
|
|
1044
|
-
const
|
|
1045
|
-
if (
|
|
1046
|
-
|
|
1060
|
+
const v = h(l);
|
|
1061
|
+
if (v.type === "word") {
|
|
1062
|
+
b.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", v), s.push(v), p.setCurrentInput(""), a("idle");
|
|
1047
1063
|
return;
|
|
1048
1064
|
}
|
|
1049
|
-
}, [h,
|
|
1050
|
-
l.setCurrentInput(""), l.setIsEnteringArg(!1), s.clear(),
|
|
1051
|
-
}, [s]),
|
|
1065
|
+
}, [h, t, c, r, s, e]), C = f((l) => {
|
|
1066
|
+
l.setCurrentInput(""), l.setIsEnteringArg(!1), s.clear(), a("idle");
|
|
1067
|
+
}, [s]), k = f((l, p, w) => {
|
|
1052
1068
|
if (!(l.key === "Backspace" || l.key === "Enter" || l.key === "ArrowUp" || l.key === "ArrowDown" || l.key === "ArrowLeft" || l.key === "ArrowRight" || l.key === "Escape" || l.key === "Delete" || l.key === "Home" || l.key === "End" || l.key.length === 1))
|
|
1053
1069
|
return !0;
|
|
1054
|
-
const { currentInput:
|
|
1070
|
+
const { currentInput: v, isEnteringArg: H } = p, M = fe(v);
|
|
1055
1071
|
switch (l.key) {
|
|
1056
1072
|
case "Backspace":
|
|
1057
|
-
return
|
|
1073
|
+
return v === "" && (l.preventDefault(), s.size() > 0 && s.pop(), a("idle")), !0;
|
|
1058
1074
|
case "Enter": {
|
|
1059
|
-
if (l.preventDefault(),
|
|
1075
|
+
if (l.preventDefault(), M.isQuoted && !M.isComplete)
|
|
1060
1076
|
return !0;
|
|
1061
|
-
if (r === "entering_argument" || H &&
|
|
1077
|
+
if (r === "entering_argument" || H && v.trim()) {
|
|
1062
1078
|
const F = c();
|
|
1063
|
-
F instanceof
|
|
1079
|
+
F instanceof q && (F.value = v, b.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", F), s.push(F));
|
|
1064
1080
|
}
|
|
1065
|
-
const
|
|
1066
|
-
if (!
|
|
1081
|
+
const E = s.path(), B = e.getCommand(E);
|
|
1082
|
+
if (!B)
|
|
1067
1083
|
return !1;
|
|
1068
|
-
const
|
|
1069
|
-
return
|
|
1084
|
+
const O = B.segments.filter((F) => F.type === "argument"), W = s.arguments;
|
|
1085
|
+
return O.length > W.length ? !1 : (b.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", s), w.executeCommand(), n.addStoredCommand(s.toArray()), C(w), !0);
|
|
1070
1086
|
}
|
|
1071
1087
|
case "ArrowUp":
|
|
1072
1088
|
return l.preventDefault(), (async () => {
|
|
1073
|
-
const
|
|
1074
|
-
return
|
|
1089
|
+
const E = await n.navigateHistory("up");
|
|
1090
|
+
return E.segments && (s.clear(), s.pushAll(E.segments), w.setCurrentInput("")), !0;
|
|
1075
1091
|
})();
|
|
1076
1092
|
case "ArrowDown":
|
|
1077
1093
|
return l.preventDefault(), (async () => {
|
|
1078
|
-
const
|
|
1079
|
-
return
|
|
1094
|
+
const E = await n.navigateHistory("down");
|
|
1095
|
+
return E.segments && (s.clear(), s.pushAll(E.segments), w.setCurrentInput("")), !0;
|
|
1080
1096
|
})();
|
|
1081
1097
|
default: {
|
|
1082
1098
|
if (!H && l.key.length === 1) {
|
|
1083
|
-
const
|
|
1084
|
-
if (!u(
|
|
1099
|
+
const E = v + l.key;
|
|
1100
|
+
if (!u(E))
|
|
1085
1101
|
return l.preventDefault(), !1;
|
|
1086
1102
|
}
|
|
1087
1103
|
return !0;
|
|
@@ -1091,16 +1107,16 @@ const et = () => {
|
|
|
1091
1107
|
r,
|
|
1092
1108
|
u,
|
|
1093
1109
|
c,
|
|
1094
|
-
|
|
1095
|
-
|
|
1110
|
+
n,
|
|
1111
|
+
C,
|
|
1096
1112
|
e,
|
|
1097
1113
|
s
|
|
1098
1114
|
]);
|
|
1099
1115
|
return {
|
|
1100
|
-
handleInputChange:
|
|
1101
|
-
handleKeyDown:
|
|
1116
|
+
handleInputChange: S,
|
|
1117
|
+
handleKeyDown: k,
|
|
1102
1118
|
inputState: r,
|
|
1103
|
-
setInputStateWithLogging:
|
|
1119
|
+
setInputStateWithLogging: a,
|
|
1104
1120
|
// Expose internal functions for testing
|
|
1105
1121
|
findMatchingCommands: d,
|
|
1106
1122
|
getAutocompleteSuggestion: g,
|
|
@@ -1109,63 +1125,63 @@ const et = () => {
|
|
|
1109
1125
|
isValidCommandInput: u
|
|
1110
1126
|
};
|
|
1111
1127
|
};
|
|
1112
|
-
function fe(
|
|
1128
|
+
function fe(t) {
|
|
1113
1129
|
const e = [];
|
|
1114
|
-
let
|
|
1115
|
-
for (let
|
|
1116
|
-
const
|
|
1117
|
-
(
|
|
1130
|
+
let n = "", s = !1, r;
|
|
1131
|
+
for (let o = 0; o < t.length; o++) {
|
|
1132
|
+
const a = t[o];
|
|
1133
|
+
(a === '"' || a === "'") && (!s || a === r) ? s ? (e.push(n), n = "", s = !1, r = void 0) : (n && (e.push(n), n = ""), s = !0, r = a) : !s && a === " " ? n && (e.push(n), n = "") : n += a;
|
|
1118
1134
|
}
|
|
1119
1135
|
return {
|
|
1120
1136
|
words: e,
|
|
1121
|
-
currentWord:
|
|
1137
|
+
currentWord: n,
|
|
1122
1138
|
isQuoted: s,
|
|
1123
1139
|
quoteChar: r,
|
|
1124
|
-
isComplete: !s && !
|
|
1140
|
+
isComplete: !s && !n
|
|
1125
1141
|
};
|
|
1126
1142
|
}
|
|
1127
|
-
const
|
|
1128
|
-
const
|
|
1129
|
-
return
|
|
1143
|
+
const st = () => {
|
|
1144
|
+
const t = J(), [e, n] = _(0);
|
|
1145
|
+
return I(() => {
|
|
1130
1146
|
const s = {
|
|
1131
1147
|
update: () => {
|
|
1132
|
-
|
|
1148
|
+
n((r) => r + 1);
|
|
1133
1149
|
}
|
|
1134
1150
|
};
|
|
1135
|
-
return
|
|
1136
|
-
|
|
1151
|
+
return t.subscribe(s), () => {
|
|
1152
|
+
t.unsubscribe(s);
|
|
1137
1153
|
};
|
|
1138
|
-
}, [
|
|
1139
|
-
},
|
|
1140
|
-
state:
|
|
1154
|
+
}, [t]), e;
|
|
1155
|
+
}, rt = ({
|
|
1156
|
+
state: t,
|
|
1141
1157
|
actions: e
|
|
1142
1158
|
}) => {
|
|
1143
|
-
const
|
|
1144
|
-
handleKeyDown:
|
|
1145
|
-
handleInputChange:
|
|
1159
|
+
const n = T(null), s = te(), r = J(), {
|
|
1160
|
+
handleKeyDown: o,
|
|
1161
|
+
handleInputChange: a,
|
|
1146
1162
|
inputState: c,
|
|
1147
1163
|
setInputStateWithLogging: i,
|
|
1148
1164
|
getNextExpectedSegment: d
|
|
1149
|
-
} =
|
|
1150
|
-
() =>
|
|
1165
|
+
} = nt(), [g, u] = _(!1), h = U(), S = st(), C = T(null), [k, l] = _(0), p = P(
|
|
1166
|
+
() => ne(h.fontFamily, h.fontSize),
|
|
1151
1167
|
[h.fontFamily, h.fontSize]
|
|
1152
|
-
),
|
|
1153
|
-
const R =
|
|
1168
|
+
), w = f(async (N) => {
|
|
1169
|
+
const R = o(N, t, e);
|
|
1154
1170
|
await Promise.resolve(R) === !1 && (u(!0), setTimeout(() => u(!1), 500));
|
|
1155
|
-
}, [e,
|
|
1156
|
-
|
|
1157
|
-
}, [e,
|
|
1158
|
-
|
|
1159
|
-
const R =
|
|
1160
|
-
|
|
1161
|
-
}, [e,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
}, [c, i]),
|
|
1171
|
+
}, [e, o, t]), D = f((N) => {
|
|
1172
|
+
a(N.target.value, e);
|
|
1173
|
+
}, [e, a]), v = f((N) => {
|
|
1174
|
+
N.preventDefault();
|
|
1175
|
+
const R = N.clipboardData.getData("text");
|
|
1176
|
+
a(R, e);
|
|
1177
|
+
}, [e, a]);
|
|
1178
|
+
I(() => {
|
|
1179
|
+
n.current && n.current.focus(), c !== "entering_command" && i("entering_command");
|
|
1180
|
+
}, [c, i]), I(() => {
|
|
1165
1181
|
if (c !== "idle") return;
|
|
1166
|
-
const
|
|
1182
|
+
const N = d();
|
|
1167
1183
|
let R = "idle";
|
|
1168
|
-
switch (
|
|
1184
|
+
switch (N.type) {
|
|
1169
1185
|
case "word":
|
|
1170
1186
|
R = "entering_command", e.setIsEnteringArg(!1);
|
|
1171
1187
|
break;
|
|
@@ -1174,93 +1190,93 @@ const tt = () => {
|
|
|
1174
1190
|
break;
|
|
1175
1191
|
}
|
|
1176
1192
|
i(R);
|
|
1177
|
-
}, [
|
|
1178
|
-
const H =
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
const me = s.hasNextSegment(
|
|
1193
|
+
}, [S, c, d, i, e]);
|
|
1194
|
+
const H = P(() => {
|
|
1195
|
+
const N = [], R = r.toArray().map((L, se) => {
|
|
1196
|
+
N.push(L.name);
|
|
1197
|
+
const me = s.hasNextSegment(N);
|
|
1182
1198
|
if (L.type === "argument") {
|
|
1183
1199
|
const re = L;
|
|
1184
|
-
return /* @__PURE__ */
|
|
1200
|
+
return /* @__PURE__ */ A($.Fragment, { children: [
|
|
1185
1201
|
/* @__PURE__ */ m("span", { className: "citadel-input-segment-arg", children: re.value }),
|
|
1186
1202
|
se < r.size() && me && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space", children: " " })
|
|
1187
1203
|
] }, "arg-" + re.name + re.value);
|
|
1188
1204
|
}
|
|
1189
|
-
return /* @__PURE__ */
|
|
1205
|
+
return /* @__PURE__ */ A($.Fragment, { children: [
|
|
1190
1206
|
/* @__PURE__ */ m("span", { className: "citadel-input-segment-word", children: L.name }),
|
|
1191
1207
|
se < r.size() && me && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space citadel-input-segment-space-command", children: " " })
|
|
1192
1208
|
] }, "word-" + L.name);
|
|
1193
1209
|
});
|
|
1194
|
-
return [/* @__PURE__ */ m("div", { className: "citadel-input-segments", "data-testid": "user-input-area", children: R },
|
|
1195
|
-
}, [
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
}, [
|
|
1200
|
-
const
|
|
1210
|
+
return [/* @__PURE__ */ m("div", { className: "citadel-input-segments", "data-testid": "user-input-area", children: R }, S)];
|
|
1211
|
+
}, [S, s, r]), [M, E] = _("");
|
|
1212
|
+
I(() => {
|
|
1213
|
+
const N = d();
|
|
1214
|
+
N.type === "argument" ? E(N.name) : E("");
|
|
1215
|
+
}, [S, d]);
|
|
1216
|
+
const O = !t.isEnteringArg ? "is-command-mode" : "is-argument-mode", W = P(
|
|
1201
1217
|
() => ({
|
|
1202
|
-
left: `${
|
|
1218
|
+
left: `${k}px`,
|
|
1203
1219
|
transition: "left 0.05s ease-out"
|
|
1204
1220
|
}),
|
|
1205
|
-
[
|
|
1206
|
-
), F =
|
|
1221
|
+
[k]
|
|
1222
|
+
), F = P(
|
|
1207
1223
|
() => ({
|
|
1208
|
-
type: h.cursorType ??
|
|
1209
|
-
color: h.cursorColor ||
|
|
1210
|
-
speed: h.cursorSpeed ||
|
|
1224
|
+
type: h.cursorType ?? x.cursorType,
|
|
1225
|
+
color: h.cursorColor || x.cursorColor,
|
|
1226
|
+
speed: h.cursorSpeed || x.cursorSpeed
|
|
1211
1227
|
}),
|
|
1212
1228
|
[h.cursorColor, h.cursorSpeed, h.cursorType]
|
|
1213
1229
|
);
|
|
1214
1230
|
return Me(() => {
|
|
1215
|
-
const
|
|
1216
|
-
if (!
|
|
1231
|
+
const N = C.current, R = n.current;
|
|
1232
|
+
if (!N || !R) {
|
|
1217
1233
|
l(0);
|
|
1218
1234
|
return;
|
|
1219
1235
|
}
|
|
1220
|
-
const L =
|
|
1236
|
+
const L = N.getBoundingClientRect().width;
|
|
1221
1237
|
l(Math.max(0, L - R.scrollLeft));
|
|
1222
|
-
}, [
|
|
1238
|
+
}, [t.currentInput, O, p.style]), /* @__PURE__ */ m("div", { className: "citadel-input-shell", children: /* @__PURE__ */ A(
|
|
1223
1239
|
"div",
|
|
1224
1240
|
{
|
|
1225
1241
|
className: "citadel-input-line",
|
|
1226
1242
|
style: p.style,
|
|
1227
1243
|
children: [
|
|
1228
1244
|
/* @__PURE__ */ m("div", { className: "citadel-input-prompt", children: ">" }),
|
|
1229
|
-
/* @__PURE__ */
|
|
1245
|
+
/* @__PURE__ */ A("div", { className: "citadel-input-row", children: [
|
|
1230
1246
|
H,
|
|
1231
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ A("div", { className: "citadel-input-control", children: [
|
|
1232
1248
|
/* @__PURE__ */ m(
|
|
1233
1249
|
"span",
|
|
1234
1250
|
{
|
|
1235
|
-
ref:
|
|
1236
|
-
className: `citadel-input-measure ${
|
|
1251
|
+
ref: C,
|
|
1252
|
+
className: `citadel-input-measure ${O}`.trim(),
|
|
1237
1253
|
"aria-hidden": "true",
|
|
1238
|
-
children:
|
|
1254
|
+
children: t.currentInput
|
|
1239
1255
|
}
|
|
1240
1256
|
),
|
|
1241
1257
|
/* @__PURE__ */ m(
|
|
1242
1258
|
"input",
|
|
1243
1259
|
{
|
|
1244
|
-
ref:
|
|
1260
|
+
ref: n,
|
|
1245
1261
|
type: "text",
|
|
1246
1262
|
role: "textbox",
|
|
1247
|
-
value:
|
|
1248
|
-
onChange:
|
|
1249
|
-
onKeyDown:
|
|
1250
|
-
onPaste:
|
|
1263
|
+
value: t.currentInput,
|
|
1264
|
+
onChange: D,
|
|
1265
|
+
onKeyDown: w,
|
|
1266
|
+
onPaste: v,
|
|
1251
1267
|
"data-testid": "citadel-command-input",
|
|
1252
|
-
className: `citadel-input-field ${
|
|
1268
|
+
className: `citadel-input-field ${O} ${g ? "invalid-input-animation" : ""}`.trim(),
|
|
1253
1269
|
spellCheck: !1,
|
|
1254
1270
|
autoComplete: "off",
|
|
1255
|
-
placeholder:
|
|
1271
|
+
placeholder: M
|
|
1256
1272
|
}
|
|
1257
1273
|
),
|
|
1258
1274
|
/* @__PURE__ */ m(
|
|
1259
1275
|
"div",
|
|
1260
1276
|
{
|
|
1261
1277
|
className: "citadel-input-cursor",
|
|
1262
|
-
style:
|
|
1263
|
-
children: /* @__PURE__ */ m(
|
|
1278
|
+
style: W,
|
|
1279
|
+
children: /* @__PURE__ */ m(et, { style: F })
|
|
1264
1280
|
}
|
|
1265
1281
|
)
|
|
1266
1282
|
] })
|
|
@@ -1268,37 +1284,37 @@ const tt = () => {
|
|
|
1268
1284
|
]
|
|
1269
1285
|
}
|
|
1270
1286
|
) });
|
|
1271
|
-
},
|
|
1272
|
-
const e =
|
|
1273
|
-
() =>
|
|
1274
|
-
[
|
|
1275
|
-
),
|
|
1287
|
+
}, at = ({ currentInput: t = "" }) => {
|
|
1288
|
+
const e = te(), n = U(), s = J(), r = $.useMemo(
|
|
1289
|
+
() => ne(n.fontFamily, n.fontSize),
|
|
1290
|
+
[n.fontFamily, n.fontSize]
|
|
1291
|
+
), o = t.trim().toLowerCase(), a = e.getMatchingCompletions(
|
|
1276
1292
|
s.path(),
|
|
1277
|
-
|
|
1293
|
+
o
|
|
1278
1294
|
);
|
|
1279
|
-
|
|
1280
|
-
const c =
|
|
1281
|
-
const u = [...
|
|
1295
|
+
b.debug("[AvailableCommands] nextCommandSegments: ", a);
|
|
1296
|
+
const c = $.useMemo(() => {
|
|
1297
|
+
const u = [...a], h = (l) => l.name.toLowerCase() === "help", S = u.filter(h);
|
|
1282
1298
|
return [...u.filter((l) => !h(l)).sort(
|
|
1283
1299
|
(l, p) => l.name.localeCompare(p.name, void 0, { sensitivity: "base" })
|
|
1284
|
-
), ...
|
|
1285
|
-
}, [
|
|
1300
|
+
), ...S];
|
|
1301
|
+
}, [a]), i = $.useMemo(() => {
|
|
1286
1302
|
const u = /* @__PURE__ */ new Map();
|
|
1287
1303
|
for (const h of c) {
|
|
1288
|
-
const
|
|
1289
|
-
if (
|
|
1304
|
+
const S = c.reduce((C, k) => {
|
|
1305
|
+
if (k === h) return C;
|
|
1290
1306
|
let l = 0;
|
|
1291
|
-
for (; l < h.name.length && l <
|
|
1307
|
+
for (; l < h.name.length && l < k.name.length && h.name[l].toLowerCase() === k.name[l].toLowerCase(); )
|
|
1292
1308
|
l++;
|
|
1293
|
-
return Math.max(
|
|
1309
|
+
return Math.max(C, l + 1);
|
|
1294
1310
|
}, 1);
|
|
1295
|
-
u.set(h.name,
|
|
1311
|
+
u.set(h.name, S);
|
|
1296
1312
|
}
|
|
1297
1313
|
return u;
|
|
1298
|
-
}, [c]), d =
|
|
1299
|
-
return /* @__PURE__ */ m("div", { className: "citadel-available-commands", "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: "citadel-available-commands-content", style: r.style, children: d ?
|
|
1314
|
+
}, [c]), d = a.some((u) => u.type === "argument"), g = a[0];
|
|
1315
|
+
return /* @__PURE__ */ m("div", { className: "citadel-available-commands", "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: "citadel-available-commands-content", style: r.style, children: d ? a.length > 0 ? /* @__PURE__ */ A(He, { children: [
|
|
1300
1316
|
/* @__PURE__ */ m("span", { className: "citadel-available-next-arg", children: g.name }),
|
|
1301
|
-
g.description && /* @__PURE__ */
|
|
1317
|
+
g.description && /* @__PURE__ */ A("span", { className: "citadel-available-next-desc", children: [
|
|
1302
1318
|
"- ",
|
|
1303
1319
|
g.description
|
|
1304
1320
|
] })
|
|
@@ -1309,7 +1325,7 @@ const tt = () => {
|
|
|
1309
1325
|
{
|
|
1310
1326
|
"data-testid": "available-command-chip",
|
|
1311
1327
|
className: "citadel-available-chip",
|
|
1312
|
-
children: /* @__PURE__ */
|
|
1328
|
+
children: /* @__PURE__ */ A("span", { className: "citadel-available-chip-text", children: [
|
|
1313
1329
|
/* @__PURE__ */ m("strong", { className: "citadel-available-chip-prefix", children: u.name.slice(0, h) }),
|
|
1314
1330
|
u.name.slice(h)
|
|
1315
1331
|
] })
|
|
@@ -1318,100 +1334,103 @@ const tt = () => {
|
|
|
1318
1334
|
);
|
|
1319
1335
|
}) }) }) });
|
|
1320
1336
|
}, Ne = ({
|
|
1321
|
-
state:
|
|
1337
|
+
state: t,
|
|
1322
1338
|
actions: e,
|
|
1323
|
-
outputRef:
|
|
1339
|
+
outputRef: n
|
|
1324
1340
|
}) => {
|
|
1325
|
-
const r =
|
|
1341
|
+
const r = U().displayMode === "inline", o = $.useMemo(
|
|
1326
1342
|
() => r ? { overflow: "hidden" } : void 0,
|
|
1327
1343
|
[r]
|
|
1328
1344
|
);
|
|
1329
|
-
return /* @__PURE__ */
|
|
1345
|
+
return /* @__PURE__ */ A("div", { className: "innerContainer citadel-tty", children: [
|
|
1330
1346
|
/* @__PURE__ */ m(
|
|
1331
1347
|
"div",
|
|
1332
1348
|
{
|
|
1333
1349
|
className: "citadel-tty-output-pane",
|
|
1334
1350
|
"data-testid": "citadel-output-pane",
|
|
1335
|
-
style:
|
|
1336
|
-
children: /* @__PURE__ */ m(
|
|
1351
|
+
style: o,
|
|
1352
|
+
children: /* @__PURE__ */ m(Xe, { output: t.output, outputRef: n })
|
|
1337
1353
|
}
|
|
1338
1354
|
),
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
/* @__PURE__ */ m(
|
|
1341
|
-
/* @__PURE__ */ m(
|
|
1355
|
+
/* @__PURE__ */ A("div", { className: "citadel-tty-input-region", children: [
|
|
1356
|
+
/* @__PURE__ */ m(rt, { state: t, actions: e }),
|
|
1357
|
+
/* @__PURE__ */ m(at, { currentInput: t.isEnteringArg ? "" : t.currentInput })
|
|
1342
1358
|
] })
|
|
1343
1359
|
] });
|
|
1344
|
-
},
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1360
|
+
}, ot = () => {
|
|
1361
|
+
const t = U(), [e, n] = _(() => t.showOnLoad ?? !1), [s, r] = _(!1), [o, a] = _(() => t.initialHeight || null), c = T(null), i = T(null), d = T(!1), g = T(0), u = T(0), { state: h, actions: S } = de(), C = f(() => {
|
|
1362
|
+
r(!1), n(!0);
|
|
1363
|
+
}, []), k = f(() => {
|
|
1364
|
+
r(!0);
|
|
1365
|
+
}, []);
|
|
1366
|
+
Be({
|
|
1367
|
+
onOpen: C,
|
|
1368
|
+
onClose: k,
|
|
1369
|
+
isVisible: e && !s,
|
|
1370
|
+
showCitadelKey: t.showCitadelKey || ".",
|
|
1371
|
+
closeOnEscape: t.closeOnEscape ?? !0
|
|
1351
1372
|
});
|
|
1352
|
-
const
|
|
1353
|
-
var
|
|
1373
|
+
const l = f((M) => {
|
|
1374
|
+
var W;
|
|
1354
1375
|
if (!d.current) return;
|
|
1355
|
-
const
|
|
1356
|
-
Math.max(u.current -
|
|
1357
|
-
|
|
1376
|
+
const E = M.clientY - g.current, B = (W = t.maxHeight) != null && W.endsWith("vh") ? window.innerHeight * parseInt(t.maxHeight, 10) / 100 : parseInt(t.maxHeight || "80vh", 10), O = Math.min(
|
|
1377
|
+
Math.max(u.current - E, parseInt(t.minHeight || "200", 10)),
|
|
1378
|
+
B
|
|
1358
1379
|
);
|
|
1359
|
-
i.current && (i.current.style.height = `${
|
|
1360
|
-
}, [
|
|
1361
|
-
d.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove",
|
|
1362
|
-
}, [
|
|
1363
|
-
i.current && (d.current = !0, g.current = M.clientY, u.current = i.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",
|
|
1364
|
-
}, [
|
|
1365
|
-
|
|
1366
|
-
document.removeEventListener("mousemove",
|
|
1367
|
-
}, [
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
}, [
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
});
|
|
1376
|
-
const C = A(
|
|
1380
|
+
i.current && (i.current.style.height = `${O}px`, i.current.style.bottom = "0", a(`${O}px`));
|
|
1381
|
+
}, [t.maxHeight, t.minHeight]), p = f(() => {
|
|
1382
|
+
d.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", p);
|
|
1383
|
+
}, [l]), w = f((M) => {
|
|
1384
|
+
i.current && (d.current = !0, g.current = M.clientY, u.current = i.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", l), document.addEventListener("mouseup", p));
|
|
1385
|
+
}, [l, p]);
|
|
1386
|
+
I(() => () => {
|
|
1387
|
+
document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", p);
|
|
1388
|
+
}, [l, p]);
|
|
1389
|
+
const D = f(() => {
|
|
1390
|
+
s && (n(!1), r(!1));
|
|
1391
|
+
}, [s]), { animationClass: v } = Ye({
|
|
1392
|
+
isVisible: e,
|
|
1393
|
+
isClosing: s,
|
|
1394
|
+
onAnimationComplete: D
|
|
1395
|
+
}), H = P(
|
|
1377
1396
|
() => ({
|
|
1378
|
-
...
|
|
1379
|
-
maxHeight:
|
|
1397
|
+
...o ? { height: o } : {},
|
|
1398
|
+
maxHeight: t.maxHeight
|
|
1380
1399
|
}),
|
|
1381
|
-
[
|
|
1400
|
+
[t.maxHeight, o]
|
|
1382
1401
|
);
|
|
1383
|
-
return
|
|
1402
|
+
return e ? /* @__PURE__ */ A(
|
|
1384
1403
|
"div",
|
|
1385
1404
|
{
|
|
1386
1405
|
ref: i,
|
|
1387
|
-
className: `panelContainer ${
|
|
1388
|
-
style:
|
|
1406
|
+
className: `panelContainer ${v}`.trim(),
|
|
1407
|
+
style: H,
|
|
1389
1408
|
children: [
|
|
1390
|
-
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown:
|
|
1409
|
+
/* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: w }),
|
|
1391
1410
|
/* @__PURE__ */ m(
|
|
1392
1411
|
Ne,
|
|
1393
1412
|
{
|
|
1394
1413
|
state: h,
|
|
1395
|
-
actions:
|
|
1414
|
+
actions: S,
|
|
1396
1415
|
outputRef: c
|
|
1397
1416
|
}
|
|
1398
1417
|
)
|
|
1399
1418
|
]
|
|
1400
1419
|
}
|
|
1401
1420
|
) : null;
|
|
1402
|
-
}, ae = (
|
|
1403
|
-
if (!
|
|
1404
|
-
const e =
|
|
1421
|
+
}, ae = (t) => {
|
|
1422
|
+
if (!t) return;
|
|
1423
|
+
const e = t.trim();
|
|
1405
1424
|
if (e)
|
|
1406
1425
|
return /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
|
|
1407
|
-
},
|
|
1408
|
-
const { state:
|
|
1426
|
+
}, it = () => {
|
|
1427
|
+
const { state: t, actions: e } = de(), n = U(), s = T(null), r = P(
|
|
1409
1428
|
() => ({
|
|
1410
|
-
height: ae(
|
|
1411
|
-
maxHeight: ae(
|
|
1412
|
-
minHeight: ae(
|
|
1429
|
+
height: ae(n.initialHeight),
|
|
1430
|
+
maxHeight: ae(n.maxHeight),
|
|
1431
|
+
minHeight: ae(n.minHeight)
|
|
1413
1432
|
}),
|
|
1414
|
-
[
|
|
1433
|
+
[n.initialHeight, n.maxHeight, n.minHeight]
|
|
1415
1434
|
);
|
|
1416
1435
|
return /* @__PURE__ */ m(
|
|
1417
1436
|
"div",
|
|
@@ -1422,7 +1441,7 @@ const tt = () => {
|
|
|
1422
1441
|
children: /* @__PURE__ */ m(
|
|
1423
1442
|
Ne,
|
|
1424
1443
|
{
|
|
1425
|
-
state:
|
|
1444
|
+
state: t,
|
|
1426
1445
|
actions: e,
|
|
1427
1446
|
outputRef: s
|
|
1428
1447
|
}
|
|
@@ -1443,6 +1462,10 @@ const tt = () => {
|
|
|
1443
1462
|
--citadel-min-height: 200px;
|
|
1444
1463
|
--citadel-max-height: 80vh;
|
|
1445
1464
|
--citadel-default-height: 35vh;
|
|
1465
|
+
--citadel-panel-enter-duration: 200ms;
|
|
1466
|
+
--citadel-panel-exit-duration: 200ms;
|
|
1467
|
+
--citadel-panel-enter-easing: cubic-bezier(0.16, 1, 0.3, 1);
|
|
1468
|
+
--citadel-panel-exit-easing: cubic-bezier(0.4, 0, 1, 1);
|
|
1446
1469
|
|
|
1447
1470
|
display: block;
|
|
1448
1471
|
pointer-events: auto;
|
|
@@ -1502,6 +1525,8 @@ const tt = () => {
|
|
|
1502
1525
|
padding: 0;
|
|
1503
1526
|
background-color: var(--citadel-bg);
|
|
1504
1527
|
overflow: hidden;
|
|
1528
|
+
transform: translateY(0);
|
|
1529
|
+
will-change: transform;
|
|
1505
1530
|
}
|
|
1506
1531
|
|
|
1507
1532
|
.innerContainer {
|
|
@@ -1569,11 +1594,18 @@ const tt = () => {
|
|
|
1569
1594
|
}
|
|
1570
1595
|
|
|
1571
1596
|
.citadel_slideUp {
|
|
1572
|
-
animation: citadel_slideUp
|
|
1597
|
+
animation: citadel_slideUp var(--citadel-panel-enter-duration) var(--citadel-panel-enter-easing) forwards;
|
|
1573
1598
|
}
|
|
1574
1599
|
|
|
1575
1600
|
.citadel_slideDown {
|
|
1576
|
-
animation: citadel_slideDown
|
|
1601
|
+
animation: citadel_slideDown var(--citadel-panel-exit-duration) var(--citadel-panel-exit-easing) forwards;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1605
|
+
:host {
|
|
1606
|
+
--citadel-panel-enter-duration: 1ms;
|
|
1607
|
+
--citadel-panel-exit-duration: 1ms;
|
|
1608
|
+
}
|
|
1577
1609
|
}
|
|
1578
1610
|
|
|
1579
1611
|
.inlineContainer {
|
|
@@ -1888,18 +1920,18 @@ const tt = () => {
|
|
|
1888
1920
|
object-fit: contain;
|
|
1889
1921
|
border-radius: 0.5rem;
|
|
1890
1922
|
}
|
|
1891
|
-
`,
|
|
1892
|
-
config:
|
|
1923
|
+
`, vt = ({
|
|
1924
|
+
config: t = x,
|
|
1893
1925
|
commandRegistry: e,
|
|
1894
|
-
containerId:
|
|
1926
|
+
containerId: n = null
|
|
1895
1927
|
}) => {
|
|
1896
|
-
const s =
|
|
1897
|
-
return
|
|
1898
|
-
|
|
1899
|
-
level:
|
|
1928
|
+
const s = T(new ee()), r = e ?? s.current, o = T(null), a = P(() => ({ width: "100%", height: "100%" }), []), c = t.displayMode ?? x.displayMode ?? "panel";
|
|
1929
|
+
return I(() => {
|
|
1930
|
+
b.configure({
|
|
1931
|
+
level: t.logLevel || x.logLevel || ie.ERROR,
|
|
1900
1932
|
prefix: "[Citadel]"
|
|
1901
1933
|
});
|
|
1902
|
-
const i = new
|
|
1934
|
+
const i = new Ae(r, t), d = c === "inline" && !n, g = d ? o.current : n ? document.getElementById(n) : document.body;
|
|
1903
1935
|
if (g)
|
|
1904
1936
|
g.appendChild(i);
|
|
1905
1937
|
else {
|
|
@@ -1907,31 +1939,31 @@ const tt = () => {
|
|
|
1907
1939
|
console.warn("[Citadel] No host available for inline mode; skipping mount.");
|
|
1908
1940
|
return;
|
|
1909
1941
|
}
|
|
1910
|
-
console.warn(`Container with id "${
|
|
1942
|
+
console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(i);
|
|
1911
1943
|
}
|
|
1912
1944
|
return () => {
|
|
1913
1945
|
var u;
|
|
1914
1946
|
(u = i.parentElement) == null || u.removeChild(i);
|
|
1915
1947
|
};
|
|
1916
|
-
}, [r,
|
|
1948
|
+
}, [r, n, t, c]), c === "inline" && !n ? /* @__PURE__ */ m("div", { ref: o, style: a }) : null;
|
|
1917
1949
|
};
|
|
1918
|
-
class
|
|
1919
|
-
constructor(
|
|
1920
|
-
var
|
|
1950
|
+
class Ae extends HTMLElement {
|
|
1951
|
+
constructor(n, s) {
|
|
1952
|
+
var o;
|
|
1921
1953
|
super();
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry =
|
|
1927
|
-
const r = ((
|
|
1954
|
+
y(this, "shadow");
|
|
1955
|
+
y(this, "root", null);
|
|
1956
|
+
y(this, "commandRegistry");
|
|
1957
|
+
y(this, "config");
|
|
1958
|
+
this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = n, this.config = s;
|
|
1959
|
+
const r = ((o = this.config) == null ? void 0 : o.displayMode) ?? "panel";
|
|
1928
1960
|
this.setAttribute("data-display-mode", r);
|
|
1929
1961
|
}
|
|
1930
1962
|
connectedCallback() {
|
|
1931
1963
|
try {
|
|
1932
1964
|
const s = [ye].map((r) => {
|
|
1933
|
-
const
|
|
1934
|
-
return
|
|
1965
|
+
const o = new CSSStyleSheet();
|
|
1966
|
+
return o.replaceSync(r), o;
|
|
1935
1967
|
});
|
|
1936
1968
|
this.shadow.adoptedStyleSheets = [...s];
|
|
1937
1969
|
} catch {
|
|
@@ -1939,27 +1971,27 @@ class Ie extends HTMLElement {
|
|
|
1939
1971
|
`), r = document.createElement("style");
|
|
1940
1972
|
r.textContent = s, this.shadow.appendChild(r);
|
|
1941
1973
|
}
|
|
1942
|
-
const
|
|
1943
|
-
|
|
1944
|
-
/* @__PURE__ */ m(We, { config: this.config ||
|
|
1974
|
+
const n = document.createElement("div");
|
|
1975
|
+
n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root = Te(n), this.root.render(
|
|
1976
|
+
/* @__PURE__ */ m(We, { config: this.config || x, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(ct, {}) })
|
|
1945
1977
|
);
|
|
1946
1978
|
}
|
|
1947
1979
|
disconnectedCallback() {
|
|
1948
|
-
const
|
|
1949
|
-
if (this.root = null, !
|
|
1980
|
+
const n = this.root;
|
|
1981
|
+
if (this.root = null, !n) {
|
|
1950
1982
|
this.shadow.replaceChildren();
|
|
1951
1983
|
return;
|
|
1952
1984
|
}
|
|
1953
1985
|
queueMicrotask(() => {
|
|
1954
|
-
|
|
1986
|
+
n.unmount(), this.shadow.replaceChildren();
|
|
1955
1987
|
});
|
|
1956
1988
|
}
|
|
1957
1989
|
}
|
|
1958
|
-
typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element",
|
|
1959
|
-
const
|
|
1960
|
-
class
|
|
1990
|
+
typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element", Ae);
|
|
1991
|
+
const ct = () => (U().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(it, {}) : /* @__PURE__ */ m(ot, {});
|
|
1992
|
+
class lt {
|
|
1961
1993
|
constructor() {
|
|
1962
|
-
|
|
1994
|
+
y(this, "_description");
|
|
1963
1995
|
}
|
|
1964
1996
|
describe(e) {
|
|
1965
1997
|
return this._description = e, this;
|
|
@@ -1968,13 +2000,13 @@ class it {
|
|
|
1968
2000
|
return this._description;
|
|
1969
2001
|
}
|
|
1970
2002
|
}
|
|
1971
|
-
class
|
|
2003
|
+
class dt {
|
|
1972
2004
|
constructor(e) {
|
|
1973
|
-
|
|
2005
|
+
y(this, "state");
|
|
1974
2006
|
this.state = {
|
|
1975
2007
|
path: e,
|
|
1976
2008
|
description: "",
|
|
1977
|
-
segments:
|
|
2009
|
+
segments: mt(e)
|
|
1978
2010
|
};
|
|
1979
2011
|
}
|
|
1980
2012
|
describe(e) {
|
|
@@ -1983,9 +2015,9 @@ class ct {
|
|
|
1983
2015
|
details(e) {
|
|
1984
2016
|
return this.state.details = e, this;
|
|
1985
2017
|
}
|
|
1986
|
-
arg(e,
|
|
1987
|
-
const s = new
|
|
1988
|
-
return
|
|
2018
|
+
arg(e, n) {
|
|
2019
|
+
const s = new lt();
|
|
2020
|
+
return n == null || n(s), this.state.segments.push({
|
|
1989
2021
|
type: "argument",
|
|
1990
2022
|
name: e,
|
|
1991
2023
|
description: s.description
|
|
@@ -2001,85 +2033,90 @@ class ct {
|
|
|
2001
2033
|
};
|
|
2002
2034
|
}
|
|
2003
2035
|
}
|
|
2004
|
-
function
|
|
2005
|
-
const e =
|
|
2036
|
+
function mt(t) {
|
|
2037
|
+
const e = t.trim();
|
|
2006
2038
|
if (!e)
|
|
2007
2039
|
throw new Error("Command path cannot be empty");
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2010
|
-
throw new Error(`Invalid command path "${
|
|
2011
|
-
if (
|
|
2040
|
+
const n = e.split(".");
|
|
2041
|
+
if (n.some((s) => s.trim() === ""))
|
|
2042
|
+
throw new Error(`Invalid command path "${t}". Empty segments are not allowed.`);
|
|
2043
|
+
if (n.some((s) => s.includes(" ")))
|
|
2012
2044
|
throw new Error(
|
|
2013
|
-
`Invalid command path "${
|
|
2045
|
+
`Invalid command path "${t}". Use dot-delimited words (e.g. "user.show").`
|
|
2014
2046
|
);
|
|
2015
|
-
return
|
|
2047
|
+
return n.map((s) => ({
|
|
2016
2048
|
type: "word",
|
|
2017
2049
|
name: s
|
|
2018
2050
|
}));
|
|
2019
2051
|
}
|
|
2020
|
-
function
|
|
2021
|
-
return
|
|
2052
|
+
function ut(t) {
|
|
2053
|
+
return t.flatMap((e) => e.type === "argument" ? [e.name] : []);
|
|
2022
2054
|
}
|
|
2023
|
-
function
|
|
2024
|
-
const e =
|
|
2025
|
-
return async (
|
|
2026
|
-
const s = e.reduce((r,
|
|
2055
|
+
function pt(t) {
|
|
2056
|
+
const e = ut(t.segments);
|
|
2057
|
+
return async (n) => {
|
|
2058
|
+
const s = e.reduce((r, o, a) => (r[o] = n[a], r), {});
|
|
2027
2059
|
return Promise.resolve(
|
|
2028
|
-
|
|
2029
|
-
rawArgs:
|
|
2060
|
+
t.handler({
|
|
2061
|
+
rawArgs: n,
|
|
2030
2062
|
namedArgs: s,
|
|
2031
|
-
commandPath:
|
|
2063
|
+
commandPath: t.path
|
|
2032
2064
|
})
|
|
2033
2065
|
);
|
|
2034
2066
|
};
|
|
2035
2067
|
}
|
|
2036
|
-
function
|
|
2037
|
-
return new
|
|
2068
|
+
function St(t) {
|
|
2069
|
+
return new dt(t);
|
|
2038
2070
|
}
|
|
2039
|
-
function
|
|
2040
|
-
|
|
2071
|
+
function ht(t, e) {
|
|
2072
|
+
t.addCommand(
|
|
2041
2073
|
e.segments,
|
|
2042
2074
|
e.description,
|
|
2043
|
-
|
|
2075
|
+
pt(e)
|
|
2044
2076
|
);
|
|
2045
2077
|
}
|
|
2046
|
-
function
|
|
2047
|
-
return e.forEach((
|
|
2078
|
+
function gt(t, e) {
|
|
2079
|
+
return e.forEach((n) => ht(t, n)), t;
|
|
2080
|
+
}
|
|
2081
|
+
function xt(t) {
|
|
2082
|
+
const e = new ee();
|
|
2083
|
+
return gt(e, t);
|
|
2048
2084
|
}
|
|
2049
|
-
function
|
|
2050
|
-
|
|
2051
|
-
return pt(e, n);
|
|
2085
|
+
function bt(t) {
|
|
2086
|
+
return new G(t);
|
|
2052
2087
|
}
|
|
2053
|
-
function
|
|
2054
|
-
return new
|
|
2088
|
+
function kt(t, e = "true", n = "false") {
|
|
2089
|
+
return new De(t, e, n);
|
|
2055
2090
|
}
|
|
2056
|
-
function
|
|
2057
|
-
return new ze(
|
|
2091
|
+
function Et(t) {
|
|
2092
|
+
return new ze(t);
|
|
2058
2093
|
}
|
|
2059
|
-
function
|
|
2060
|
-
return new Fe(
|
|
2094
|
+
function Nt(t, e = "") {
|
|
2095
|
+
return new Fe(t, e);
|
|
2061
2096
|
}
|
|
2062
|
-
function
|
|
2063
|
-
return new we(
|
|
2097
|
+
function At(t) {
|
|
2098
|
+
return new we(t);
|
|
2064
2099
|
}
|
|
2065
2100
|
export {
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2101
|
+
De as BooleanCommandResult,
|
|
2102
|
+
vt as Citadel,
|
|
2103
|
+
ee as CommandRegistry,
|
|
2104
|
+
K as CommandResult,
|
|
2105
|
+
V as CommandStatus,
|
|
2106
|
+
Ze as DEFAULT_CURSOR_CONFIGS,
|
|
2071
2107
|
we as ErrorCommandResult,
|
|
2072
2108
|
Fe as ImageCommandResult,
|
|
2073
2109
|
ze as JsonCommandResult,
|
|
2074
2110
|
oe as OutputItem,
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2111
|
+
Oe as PendingCommandResult,
|
|
2112
|
+
G as TextCommandResult,
|
|
2113
|
+
kt as bool,
|
|
2114
|
+
St as command,
|
|
2115
|
+
xt as createCommandRegistry,
|
|
2116
|
+
At as error,
|
|
2117
|
+
Nt as image,
|
|
2118
|
+
Et as json,
|
|
2119
|
+
ht as registerCommand,
|
|
2120
|
+
gt as registerCommands,
|
|
2121
|
+
bt as text
|
|
2085
2122
|
};
|