toolcraft-openapi 0.0.17 → 0.0.18
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/dist/bin/generate.js +7 -0
- package/dist/define-client.js +2 -2
- package/dist/generate.js +2 -2
- package/dist/http.d.ts +21 -2
- package/dist/http.js +147 -22
- package/dist/index.d.ts +1 -1
- package/dist/lock.d.ts +1 -1
- package/dist/lock.js +109 -5
- package/dist/mock/fetch.js +1 -1
- package/dist/network-error.d.ts +2 -0
- package/dist/network-error.js +83 -0
- package/dist/spec-source.js +103 -3
- package/node_modules/@poe-code/design-system/dist/components/help-formatter-plain.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter-plain.js +1 -1
- package/node_modules/@poe-code/design-system/dist/components/text.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.js +8 -1
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.js +146 -12
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.js +31 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/explorer/actions.d.ts +16 -0
- package/node_modules/@poe-code/design-system/dist/explorer/actions.js +39 -0
- package/node_modules/@poe-code/design-system/dist/explorer/demo.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/explorer/demo.js +297 -0
- package/node_modules/@poe-code/design-system/dist/explorer/events.d.ts +61 -0
- package/node_modules/@poe-code/design-system/dist/explorer/events.js +1 -0
- package/node_modules/@poe-code/design-system/dist/explorer/filter.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/explorer/filter.js +95 -0
- package/node_modules/@poe-code/design-system/dist/explorer/index.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/explorer/index.js +8 -0
- package/node_modules/@poe-code/design-system/dist/explorer/jobs.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/explorer/jobs.js +59 -0
- package/node_modules/@poe-code/design-system/dist/explorer/keymap.d.ts +21 -0
- package/node_modules/@poe-code/design-system/dist/explorer/keymap.js +363 -0
- package/node_modules/@poe-code/design-system/dist/explorer/layout.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/explorer/layout.js +73 -0
- package/node_modules/@poe-code/design-system/dist/explorer/reducer.d.ts +9 -0
- package/node_modules/@poe-code/design-system/dist/explorer/reducer.js +704 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/detail.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/detail.js +96 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/footer.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/footer.js +49 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/header.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/header.js +56 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/index.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/index.js +61 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/list.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/list.js +106 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/modal.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/modal.js +91 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/test-fixtures.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/explorer/render/test-fixtures.js +156 -0
- package/node_modules/@poe-code/design-system/dist/explorer/runtime.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/explorer/runtime.js +282 -0
- package/node_modules/@poe-code/design-system/dist/explorer/runtime.test-helpers.d.ts +50 -0
- package/node_modules/@poe-code/design-system/dist/explorer/runtime.test-helpers.js +101 -0
- package/node_modules/@poe-code/design-system/dist/explorer/state.d.ts +130 -0
- package/node_modules/@poe-code/design-system/dist/explorer/state.js +87 -0
- package/node_modules/@poe-code/design-system/dist/explorer/theme.d.ts +27 -0
- package/node_modules/@poe-code/design-system/dist/explorer/theme.js +97 -0
- package/node_modules/@poe-code/design-system/dist/index.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/index.js +3 -0
- package/node_modules/@poe-code/design-system/package.json +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
const builtinBindings = {
|
|
2
|
+
quit: ["q", "Ctrl+c"],
|
|
3
|
+
filter: ["/"],
|
|
4
|
+
help: ["?"],
|
|
5
|
+
palette: ["Ctrl+p", "Ctrl+k"],
|
|
6
|
+
cursorUp: ["up", "k"],
|
|
7
|
+
cursorDown: ["down", "j"],
|
|
8
|
+
top: ["home", "gg"],
|
|
9
|
+
bottom: ["end", "G"],
|
|
10
|
+
pageUp: ["Ctrl+u"],
|
|
11
|
+
pageDown: ["Ctrl+d"],
|
|
12
|
+
focusNext: ["tab"],
|
|
13
|
+
escape: ["escape"],
|
|
14
|
+
confirm: ["return", "enter"],
|
|
15
|
+
toggleSelect: ["space"],
|
|
16
|
+
selectAll: ["Ctrl+a"],
|
|
17
|
+
clearSelection: ["Ctrl+/"],
|
|
18
|
+
detailScrollDown: ["Ctrl+f"],
|
|
19
|
+
detailScrollUp: ["Ctrl+b"],
|
|
20
|
+
extendSelectionUp: ["Shift+up"],
|
|
21
|
+
extendSelectionDown: ["Shift+down"],
|
|
22
|
+
reorderUp: ["Ctrl+up", "K"],
|
|
23
|
+
reorderDown: ["Ctrl+down", "J"]
|
|
24
|
+
};
|
|
25
|
+
const baseBuiltinCommands = [
|
|
26
|
+
"quit",
|
|
27
|
+
"filter",
|
|
28
|
+
"help",
|
|
29
|
+
"palette",
|
|
30
|
+
"cursorUp",
|
|
31
|
+
"cursorDown",
|
|
32
|
+
"top",
|
|
33
|
+
"bottom",
|
|
34
|
+
"pageUp",
|
|
35
|
+
"pageDown",
|
|
36
|
+
"focusNext",
|
|
37
|
+
"escape",
|
|
38
|
+
"confirm",
|
|
39
|
+
"toggleSelect",
|
|
40
|
+
"selectAll",
|
|
41
|
+
"clearSelection",
|
|
42
|
+
"detailScrollDown",
|
|
43
|
+
"detailScrollUp",
|
|
44
|
+
"extendSelectionUp",
|
|
45
|
+
"extendSelectionDown"
|
|
46
|
+
];
|
|
47
|
+
const reorderCommands = ["reorderUp", "reorderDown"];
|
|
48
|
+
const reservedActionIds = new Set(["quit"]);
|
|
49
|
+
export function resolveBindings(config, defaults = {}) {
|
|
50
|
+
const commands = config.reorder === undefined
|
|
51
|
+
? baseBuiltinCommands
|
|
52
|
+
: [...baseBuiltinCommands, ...reorderCommands];
|
|
53
|
+
const commandBindings = new Map();
|
|
54
|
+
const flatBindings = new Map();
|
|
55
|
+
const targetKeys = new Map();
|
|
56
|
+
const targetsByCommand = new Map();
|
|
57
|
+
const claimed = new Map();
|
|
58
|
+
const conflicts = new Map();
|
|
59
|
+
for (const command of commands) {
|
|
60
|
+
const target = { type: "builtin", id: command };
|
|
61
|
+
const keys = command === "quit"
|
|
62
|
+
? builtinBindings.quit
|
|
63
|
+
: defaults[command] ?? builtinBindings[command];
|
|
64
|
+
addBindings({
|
|
65
|
+
keys,
|
|
66
|
+
owner: command,
|
|
67
|
+
commandId: `builtin:${command}`,
|
|
68
|
+
target,
|
|
69
|
+
commandBindings,
|
|
70
|
+
flatBindings,
|
|
71
|
+
targetKeys,
|
|
72
|
+
targetsByCommand,
|
|
73
|
+
claimed,
|
|
74
|
+
conflicts,
|
|
75
|
+
warn: false
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
for (const action of [...config.actions, ...(config.detail.actions ?? [])]) {
|
|
79
|
+
if (reservedActionIds.has(action.id)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const keys = toBindingArray(config.keybindOverrides?.[action.id] ?? action.key);
|
|
83
|
+
addBindings({
|
|
84
|
+
keys,
|
|
85
|
+
owner: action.id,
|
|
86
|
+
commandId: `action:${action.id}`,
|
|
87
|
+
target: { type: "action", id: action.id },
|
|
88
|
+
commandBindings,
|
|
89
|
+
flatBindings,
|
|
90
|
+
targetKeys,
|
|
91
|
+
targetsByCommand,
|
|
92
|
+
claimed,
|
|
93
|
+
conflicts,
|
|
94
|
+
warn: true
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (process.env.NODE_ENV !== "production") {
|
|
98
|
+
for (const warning of conflicts.values()) {
|
|
99
|
+
process.stderr.write(`${warning}\n`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const commandIds = Array.from(commandBindings.keys());
|
|
103
|
+
const defaultKeymapBindings = Object.fromEntries(Array.from(commandBindings.entries()));
|
|
104
|
+
const resolveCommand = createKeymap(commandIds, defaultKeymapBindings);
|
|
105
|
+
return {
|
|
106
|
+
bindings: flatBindings,
|
|
107
|
+
keysByTarget: targetKeys,
|
|
108
|
+
resolve: (event) => {
|
|
109
|
+
const command = resolveCommand(event);
|
|
110
|
+
return command === undefined ? undefined : targetsByCommand.get(command);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function addBindings(opts) {
|
|
115
|
+
const accepted = [];
|
|
116
|
+
for (const key of opts.keys) {
|
|
117
|
+
const canonical = canonicalizeBinding(key);
|
|
118
|
+
if (canonical === undefined) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const existing = opts.claimed.get(canonical);
|
|
122
|
+
if (existing !== undefined) {
|
|
123
|
+
if (existing !== opts.owner && opts.warn) {
|
|
124
|
+
opts.conflicts.set(`${opts.owner}:${canonical}`, `Explorer key binding conflict: ${key} for ${opts.owner} is already bound to ${existing}`);
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
opts.claimed.set(canonical, opts.owner);
|
|
129
|
+
opts.flatBindings.set(canonical, opts.target);
|
|
130
|
+
accepted.push(key);
|
|
131
|
+
}
|
|
132
|
+
if (accepted.length > 0) {
|
|
133
|
+
opts.commandBindings.set(opts.commandId, accepted);
|
|
134
|
+
opts.targetKeys.set(targetKey(opts.target), accepted);
|
|
135
|
+
opts.targetsByCommand.set(opts.commandId, opts.target);
|
|
136
|
+
}
|
|
137
|
+
return accepted;
|
|
138
|
+
}
|
|
139
|
+
function targetKey(target) {
|
|
140
|
+
return `${target.type}:${target.id}`;
|
|
141
|
+
}
|
|
142
|
+
function toBindingArray(value) {
|
|
143
|
+
if (value === undefined) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
return Array.isArray(value) ? value : [value];
|
|
147
|
+
}
|
|
148
|
+
function createKeymap(commands, defaultBindings) {
|
|
149
|
+
const bindings = new Map();
|
|
150
|
+
const sequences = new Set();
|
|
151
|
+
let pendingSequence = "";
|
|
152
|
+
for (const command of commands) {
|
|
153
|
+
const commandBindings = defaultBindings[command]
|
|
154
|
+
.map(parseBinding)
|
|
155
|
+
.filter((binding) => binding !== undefined);
|
|
156
|
+
for (const binding of commandBindings) {
|
|
157
|
+
if (binding.sequence !== undefined) {
|
|
158
|
+
sequences.add(binding.sequence);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
bindings.set(command, commandBindings);
|
|
162
|
+
}
|
|
163
|
+
return (event) => {
|
|
164
|
+
for (const command of commands) {
|
|
165
|
+
const commandBindings = bindings.get(command);
|
|
166
|
+
if (commandBindings?.some((binding) => matchesSingleKey(binding, event))) {
|
|
167
|
+
pendingSequence = "";
|
|
168
|
+
return command;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const token = eventToSequenceToken(event);
|
|
172
|
+
if (token === undefined) {
|
|
173
|
+
pendingSequence = "";
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
pendingSequence = `${pendingSequence}${token}`;
|
|
177
|
+
for (const command of commands) {
|
|
178
|
+
const commandBindings = bindings.get(command);
|
|
179
|
+
if (commandBindings?.some((binding) => binding.sequence === pendingSequence)) {
|
|
180
|
+
pendingSequence = "";
|
|
181
|
+
return command;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (hasSequencePrefix(sequences, pendingSequence)) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
pendingSequence = token;
|
|
188
|
+
if (hasSequencePrefix(sequences, pendingSequence)) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
pendingSequence = "";
|
|
192
|
+
return undefined;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function canonicalizeBinding(binding) {
|
|
196
|
+
const parsed = parseBinding(binding);
|
|
197
|
+
if (parsed === undefined) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
const modifiers = [
|
|
201
|
+
parsed.ctrl ? "ctrl" : undefined,
|
|
202
|
+
parsed.meta ? "meta" : undefined,
|
|
203
|
+
parsed.shift ? "shift" : undefined
|
|
204
|
+
].filter((modifier) => modifier !== undefined);
|
|
205
|
+
const key = parsed.name ?? parsed.ch;
|
|
206
|
+
if (parsed.sequence !== undefined) {
|
|
207
|
+
return parsed.sequence.toLowerCase();
|
|
208
|
+
}
|
|
209
|
+
return key === undefined ? undefined : [...modifiers, key.toLowerCase()].join("+");
|
|
210
|
+
}
|
|
211
|
+
function parseBinding(binding) {
|
|
212
|
+
const value = binding.trim();
|
|
213
|
+
if (value.length === 0) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
const parts = value.split("+").map((part) => part.trim()).filter(Boolean);
|
|
217
|
+
if (parts.length === 0) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
let ctrl = false;
|
|
221
|
+
let meta = false;
|
|
222
|
+
let shift = false;
|
|
223
|
+
const key = parts.at(-1);
|
|
224
|
+
if (key === undefined) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
for (const modifier of parts.slice(0, -1)) {
|
|
228
|
+
const normalized = modifier.toLowerCase();
|
|
229
|
+
if (normalized === "ctrl" || normalized === "control") {
|
|
230
|
+
ctrl = true;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (normalized === "meta" || normalized === "alt") {
|
|
234
|
+
meta = true;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (normalized === "shift") {
|
|
238
|
+
shift = true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const normalizedKey = normalizeKeyName(key);
|
|
242
|
+
if (parts.length === 1 && isShiftedCharacter(normalizedKey)) {
|
|
243
|
+
shift = true;
|
|
244
|
+
}
|
|
245
|
+
if (normalizedKey.length === 1) {
|
|
246
|
+
return {
|
|
247
|
+
ch: normalizeBindingCharacter(normalizedKey, shift),
|
|
248
|
+
ctrl,
|
|
249
|
+
meta,
|
|
250
|
+
shift
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (!ctrl &&
|
|
254
|
+
!meta &&
|
|
255
|
+
!shift &&
|
|
256
|
+
!isNamedKey(normalizedKey) &&
|
|
257
|
+
isPrintableSequence(normalizedKey)) {
|
|
258
|
+
return {
|
|
259
|
+
sequence: normalizedKey,
|
|
260
|
+
ctrl,
|
|
261
|
+
meta,
|
|
262
|
+
shift
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
name: normalizedKey.toLowerCase(),
|
|
267
|
+
ctrl,
|
|
268
|
+
meta,
|
|
269
|
+
shift
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function matchesSingleKey(binding, event) {
|
|
273
|
+
if (binding.sequence !== undefined) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
if (binding.ctrl !== event.ctrl ||
|
|
277
|
+
binding.meta !== event.meta ||
|
|
278
|
+
binding.shift !== event.shift) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (binding.ch !== undefined) {
|
|
282
|
+
if (binding.ch === " " && event.name === "space") {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
return event.ch === binding.ch || event.name === binding.ch.toLowerCase();
|
|
286
|
+
}
|
|
287
|
+
if (binding.name !== undefined) {
|
|
288
|
+
return event.name === binding.name;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
function eventToSequenceToken(event) {
|
|
293
|
+
if (event.ctrl || event.meta || event.ch === undefined) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
return event.ch;
|
|
297
|
+
}
|
|
298
|
+
function hasSequencePrefix(sequences, prefix) {
|
|
299
|
+
for (const sequence of sequences) {
|
|
300
|
+
if (sequence.startsWith(prefix)) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
function isShiftedCharacter(value) {
|
|
307
|
+
return value.length === 1 && value.toLowerCase() !== value && value.toUpperCase() === value;
|
|
308
|
+
}
|
|
309
|
+
function normalizeBindingCharacter(value, shift) {
|
|
310
|
+
if (!shift || value.toLowerCase() === value.toUpperCase()) {
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
313
|
+
return value.toUpperCase();
|
|
314
|
+
}
|
|
315
|
+
function normalizeKeyName(value) {
|
|
316
|
+
if (value.toLowerCase() === "space") {
|
|
317
|
+
return " ";
|
|
318
|
+
}
|
|
319
|
+
if (value === "↑") {
|
|
320
|
+
return "up";
|
|
321
|
+
}
|
|
322
|
+
if (value === "↓") {
|
|
323
|
+
return "down";
|
|
324
|
+
}
|
|
325
|
+
if (value === "←") {
|
|
326
|
+
return "left";
|
|
327
|
+
}
|
|
328
|
+
if (value === "→") {
|
|
329
|
+
return "right";
|
|
330
|
+
}
|
|
331
|
+
return value;
|
|
332
|
+
}
|
|
333
|
+
function isNamedKey(value) {
|
|
334
|
+
return namedKeys.has(value.toLowerCase());
|
|
335
|
+
}
|
|
336
|
+
function isPrintableSequence(value) {
|
|
337
|
+
if (Array.from(value).length <= 1) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
for (const char of value) {
|
|
341
|
+
const codePoint = char.codePointAt(0);
|
|
342
|
+
if (codePoint === undefined || codePoint < 0x20 || codePoint === 0x7f) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
const namedKeys = new Set([
|
|
349
|
+
"backspace",
|
|
350
|
+
"delete",
|
|
351
|
+
"down",
|
|
352
|
+
"end",
|
|
353
|
+
"enter",
|
|
354
|
+
"escape",
|
|
355
|
+
"home",
|
|
356
|
+
"left",
|
|
357
|
+
"pagedown",
|
|
358
|
+
"pageup",
|
|
359
|
+
"return",
|
|
360
|
+
"right",
|
|
361
|
+
"tab",
|
|
362
|
+
"up"
|
|
363
|
+
]);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ExplorerLayoutMode = "wide" | "medium" | "narrow-vertical" | "narrow-list-only" | "too-narrow";
|
|
2
|
+
export interface Rect {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ExplorerLayoutOptions {
|
|
9
|
+
cols: number;
|
|
10
|
+
rows: number;
|
|
11
|
+
detailHidden?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ExplorerLayout {
|
|
14
|
+
mode: ExplorerLayoutMode;
|
|
15
|
+
header: Rect;
|
|
16
|
+
list: Rect;
|
|
17
|
+
detail: Rect;
|
|
18
|
+
footer: Rect;
|
|
19
|
+
}
|
|
20
|
+
export declare function computeExplorerLayout(opts: ExplorerLayoutOptions): ExplorerLayout;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const HEADER_HEIGHT = 3;
|
|
2
|
+
const FOOTER_HEIGHT = 1;
|
|
3
|
+
export function computeExplorerLayout(opts) {
|
|
4
|
+
const cols = normalizeSize(opts.cols);
|
|
5
|
+
const rows = normalizeSize(opts.rows);
|
|
6
|
+
const mode = resolveMode(cols);
|
|
7
|
+
const footerHeight = rows > 0 ? Math.min(FOOTER_HEIGHT, rows) : 0;
|
|
8
|
+
const headerHeight = Math.min(HEADER_HEIGHT, Math.max(0, rows - footerHeight));
|
|
9
|
+
const contentY = headerHeight;
|
|
10
|
+
const contentHeight = Math.max(0, rows - headerHeight - footerHeight);
|
|
11
|
+
const footerY = headerHeight + contentHeight;
|
|
12
|
+
const header = { x: 0, y: 0, width: cols, height: headerHeight };
|
|
13
|
+
const footer = { x: 0, y: footerY, width: cols, height: footerHeight };
|
|
14
|
+
if (mode === "too-narrow" || mode === "narrow-list-only") {
|
|
15
|
+
return {
|
|
16
|
+
mode,
|
|
17
|
+
header,
|
|
18
|
+
list: { x: 0, y: contentY, width: cols, height: contentHeight },
|
|
19
|
+
detail: { x: 0, y: contentY + contentHeight, width: 0, height: 0 },
|
|
20
|
+
footer
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (opts.detailHidden === true) {
|
|
24
|
+
return {
|
|
25
|
+
mode,
|
|
26
|
+
header,
|
|
27
|
+
list: { x: 0, y: contentY, width: cols, height: contentHeight },
|
|
28
|
+
detail: { x: cols, y: contentY, width: 0, height: contentHeight },
|
|
29
|
+
footer
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (mode === "narrow-vertical") {
|
|
33
|
+
const listHeight = Math.ceil(contentHeight / 2);
|
|
34
|
+
const detailHeight = contentHeight - listHeight;
|
|
35
|
+
return {
|
|
36
|
+
mode,
|
|
37
|
+
header,
|
|
38
|
+
list: { x: 0, y: contentY, width: cols, height: listHeight },
|
|
39
|
+
detail: { x: 0, y: contentY + listHeight, width: cols, height: detailHeight },
|
|
40
|
+
footer
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const listWidth = mode === "wide" ? Math.floor((cols * 5) / 12) : Math.floor((cols * 2) / 5);
|
|
44
|
+
const detailWidth = cols - listWidth;
|
|
45
|
+
return {
|
|
46
|
+
mode,
|
|
47
|
+
header,
|
|
48
|
+
list: { x: 0, y: contentY, width: listWidth, height: contentHeight },
|
|
49
|
+
detail: { x: listWidth, y: contentY, width: detailWidth, height: contentHeight },
|
|
50
|
+
footer
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function resolveMode(cols) {
|
|
54
|
+
if (cols < 40) {
|
|
55
|
+
return "too-narrow";
|
|
56
|
+
}
|
|
57
|
+
if (cols < 80) {
|
|
58
|
+
return "narrow-list-only";
|
|
59
|
+
}
|
|
60
|
+
if (cols < 100) {
|
|
61
|
+
return "narrow-vertical";
|
|
62
|
+
}
|
|
63
|
+
if (cols < 120) {
|
|
64
|
+
return "medium";
|
|
65
|
+
}
|
|
66
|
+
return "wide";
|
|
67
|
+
}
|
|
68
|
+
function normalizeSize(value) {
|
|
69
|
+
if (!Number.isFinite(value)) {
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
return Math.max(0, Math.floor(value));
|
|
73
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ActionRuntimeHandles } from "./actions.js";
|
|
2
|
+
import type { Effect, ExplorerEvent } from "./events.js";
|
|
3
|
+
import { type ExplorerState } from "./state.js";
|
|
4
|
+
type StepResult = {
|
|
5
|
+
state: ExplorerState;
|
|
6
|
+
effects: Effect[];
|
|
7
|
+
};
|
|
8
|
+
export declare function step(state: ExplorerState, event: ExplorerEvent, runtimeHandles?: ActionRuntimeHandles): StepResult;
|
|
9
|
+
export {};
|