toolcraft-openapi 0.0.127 → 0.0.129
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/composition.json +2 -2
- package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.js +21 -2
- package/node_modules/toolcraft-design/dist/explorer/state.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/explorer/state.js +9 -6
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +3 -3
package/dist/composition.json
CHANGED
|
@@ -6,6 +6,7 @@ type ExplorerKeypressEvent = Extract<ExplorerEvent, {
|
|
|
6
6
|
}>["key"];
|
|
7
7
|
export type ActionRuntimeHandles = {
|
|
8
8
|
refresh: () => Promise<void>;
|
|
9
|
+
reloadDetail: (rowId?: string) => void;
|
|
9
10
|
suspendAnd: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
10
11
|
openModal: (content: {
|
|
11
12
|
title: string;
|
|
@@ -19,6 +19,7 @@ export function buildActionContext(state, _action, source, runtimeHandles, rowsO
|
|
|
19
19
|
item: source === "detail" ? currentDetailItem(state) : undefined,
|
|
20
20
|
filter: state.filter,
|
|
21
21
|
refresh: runtimeHandles.refresh,
|
|
22
|
+
reloadDetail: runtimeHandles.reloadDetail,
|
|
22
23
|
suspendAnd: runtimeHandles.suspendAnd,
|
|
23
24
|
openModal: runtimeHandles.openModal,
|
|
24
25
|
toast: runtimeHandles.toast,
|
|
@@ -4,6 +4,7 @@ import { REGION_ALL, REGION_DETAIL, REGION_FOOTER, REGION_HEADER, REGION_LIST, R
|
|
|
4
4
|
const NO_EFFECTS = [];
|
|
5
5
|
const DEFAULT_ACTION_HANDLES = {
|
|
6
6
|
refresh: async () => undefined,
|
|
7
|
+
reloadDetail: () => undefined,
|
|
7
8
|
suspendAnd: async (fn) => fn(),
|
|
8
9
|
openModal: () => undefined,
|
|
9
10
|
toast: () => undefined,
|
|
@@ -44,6 +44,9 @@ class ExplorerRuntime {
|
|
|
44
44
|
refresh: async () => {
|
|
45
45
|
await this.refreshRowsFromSource();
|
|
46
46
|
},
|
|
47
|
+
reloadDetail: (rowId) => {
|
|
48
|
+
this.reloadFocusedDetail(rowId);
|
|
49
|
+
},
|
|
47
50
|
suspendAnd: async (fn) => this.suspendAnd(fn),
|
|
48
51
|
openModal: (content) => {
|
|
49
52
|
this.dispatch({ type: "modalOpened", title: content.title, content: content.content });
|
|
@@ -62,6 +65,10 @@ class ExplorerRuntime {
|
|
|
62
65
|
this.settle = { resolve, reject };
|
|
63
66
|
try {
|
|
64
67
|
this.startTerminal();
|
|
68
|
+
if (this.config.initialRows !== undefined && this.config.initialRows.length > 0) {
|
|
69
|
+
// Seed list/detail before first paint so callers with known rows avoid an empty flash.
|
|
70
|
+
this.dispatch({ type: "rowsLoaded", rows: this.config.initialRows });
|
|
71
|
+
}
|
|
65
72
|
this.render();
|
|
66
73
|
this.loadRows().catch((error) => {
|
|
67
74
|
this.fail(error);
|
|
@@ -145,13 +152,25 @@ class ExplorerRuntime {
|
|
|
145
152
|
rows: this.state.size.rows,
|
|
146
153
|
detailHidden: this.state.layout === "narrow-list-only" || this.state.layout === "too-narrow"
|
|
147
154
|
});
|
|
148
|
-
|
|
155
|
+
const reloadDetail = () => this.reloadFocusedDetail(rowId);
|
|
156
|
+
void this.detailJobs.schedule(rowId, (ctx) => this.config.detail.items(row, { ...ctx, reloadDetail }), {
|
|
149
157
|
width: layout.detail.width,
|
|
150
158
|
height: layout.detail.height,
|
|
151
159
|
row,
|
|
152
|
-
signal: new AbortController().signal
|
|
160
|
+
signal: new AbortController().signal,
|
|
161
|
+
reloadDetail
|
|
153
162
|
});
|
|
154
163
|
}
|
|
164
|
+
reloadFocusedDetail(rowId) {
|
|
165
|
+
const focusedId = this.state.detail.rowId;
|
|
166
|
+
if (focusedId === null) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (rowId !== undefined && rowId !== focusedId) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.renderDetail(focusedId);
|
|
173
|
+
}
|
|
155
174
|
loadDetailContent(rowId, token, items) {
|
|
156
175
|
const row = this.state.rows.find((candidate) => candidate.id === rowId);
|
|
157
176
|
if (row === undefined) {
|
|
@@ -30,6 +30,8 @@ export interface DetailCtx {
|
|
|
30
30
|
height: number;
|
|
31
31
|
signal: AbortSignal;
|
|
32
32
|
row: Row;
|
|
33
|
+
/** Re-run detail.items for the focused row and repaint the preview pane. */
|
|
34
|
+
reloadDetail?: () => void;
|
|
33
35
|
}
|
|
34
36
|
export interface Action<R> {
|
|
35
37
|
id: string;
|
|
@@ -47,6 +49,8 @@ export interface ActionContext<R> {
|
|
|
47
49
|
item?: DetailItem;
|
|
48
50
|
filter: string;
|
|
49
51
|
refresh: () => Promise<void>;
|
|
52
|
+
/** Re-run detail.items for the focused row and repaint the preview pane. */
|
|
53
|
+
reloadDetail: () => void;
|
|
50
54
|
suspendAnd: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
51
55
|
openModal: (content: {
|
|
52
56
|
title: string;
|
|
@@ -73,6 +77,8 @@ export interface ExplorerConfig<R> {
|
|
|
73
77
|
keybindOverrides?: Record<string, string | string[]>;
|
|
74
78
|
emptyHint?: string;
|
|
75
79
|
initialFilter?: string;
|
|
80
|
+
/** Synchronous first paint rows; still refreshed via `rows()` after start. */
|
|
81
|
+
initialRows?: Row[];
|
|
76
82
|
}
|
|
77
83
|
export declare const REGION_HEADER: number;
|
|
78
84
|
export declare const REGION_LIST: number;
|
|
@@ -17,23 +17,26 @@ export function createInitialState(config, size) {
|
|
|
17
17
|
rows: normalizeSize(size.rows)
|
|
18
18
|
};
|
|
19
19
|
const multiSelect = config.multiSelect ?? true;
|
|
20
|
+
const initialRows = config.initialRows ?? [];
|
|
21
|
+
const initialFilter = config.initialFilter ?? "";
|
|
22
|
+
// Defer filtering to first rowsLoaded when empty; seed list immediately when provided.
|
|
20
23
|
return {
|
|
21
24
|
title: config.title,
|
|
22
25
|
emptyHint: config.emptyHint ?? "No detail",
|
|
23
|
-
rows:
|
|
24
|
-
filtered:
|
|
26
|
+
rows: initialRows,
|
|
27
|
+
filtered: initialRows.map((_, index) => index),
|
|
25
28
|
matchPositions: new Map(),
|
|
26
29
|
cursor: 0,
|
|
27
|
-
filter:
|
|
30
|
+
filter: initialFilter,
|
|
28
31
|
filterFocused: false,
|
|
29
32
|
focused: "list",
|
|
30
33
|
detail: {
|
|
31
|
-
rowId: null,
|
|
34
|
+
rowId: initialRows[0]?.id ?? null,
|
|
32
35
|
items: null,
|
|
33
36
|
cursor: 0,
|
|
34
37
|
scroll: 0,
|
|
35
|
-
token: 0,
|
|
36
|
-
loading:
|
|
38
|
+
token: initialRows.length > 0 ? 1 : 0,
|
|
39
|
+
loading: initialRows.length > 0
|
|
37
40
|
},
|
|
38
41
|
selected: new Set(),
|
|
39
42
|
multiSelect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft-openapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.129",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"toolcraft-openapi-generate": "dist/bin/generate.js"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"toolcraft": "0.0.
|
|
33
|
+
"toolcraft": "0.0.129",
|
|
34
34
|
"auth-store": "^0.0.1",
|
|
35
35
|
"fast-string-width": "^3.0.2",
|
|
36
36
|
"fast-wrap-ansi": "^0.2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"directory": "packages/toolcraft-openapi"
|
|
47
47
|
},
|
|
48
48
|
"optionalDependencies": {
|
|
49
|
-
"toolcraft-schema": "0.0.
|
|
49
|
+
"toolcraft-schema": "0.0.129",
|
|
50
50
|
"toolcraft-design": "*",
|
|
51
51
|
"@poe-code/frontmatter": "*"
|
|
52
52
|
},
|