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