@kubohiroya/turbowarp-plus-editor-workbench 0.9.0 → 0.11.0
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.ja.md +1 -0
- package/README.md +1 -0
- package/dist/ai-agent-settings.d.ts +8 -5
- package/dist/ai-agent-settings.js +14 -11
- package/dist/ai-agents.d.ts +11 -3
- package/dist/ai-agents.js +61 -17
- package/dist/desktop-ai-agents.d.ts +80 -0
- package/dist/desktop-ai-agents.js +236 -0
- package/dist/document-workspace.d.ts +29 -5
- package/dist/document-workspace.js +37 -3
- package/dist/drawer-views.d.ts +10 -1
- package/dist/drawer-views.js +7 -5
- package/dist/sprite-tabs.js +88 -11
- package/dist/standard-layout.d.ts +11 -2
- package/dist/standard-layout.js +61 -20
- package/package.json +1 -1
- package/src/ai-agent-settings.ts +18 -12
- package/src/ai-agents.ts +65 -19
- package/src/desktop-ai-agents.ts +265 -0
- package/src/document-workspace.ts +52 -3
- package/src/drawer-views.ts +17 -6
- package/src/editor.css +43 -12
- package/src/sprite-tabs.ts +82 -11
- package/src/standard-layout.ts +85 -31
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import {isJapanese} from './drawer-views.ts';
|
|
2
|
+
|
|
3
|
+
export interface DesktopAgentDraft {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
cwd: string;
|
|
8
|
+
selection?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DesktopAgent extends DesktopAgentDraft {
|
|
13
|
+
application: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type AgentContext = Record<'projectFolder' | 'repository' | 'branch', string | null>;
|
|
17
|
+
type AgentList = {revision: string | null; entries: DesktopAgent[]};
|
|
18
|
+
type Result<T> = {ok: true; value: T} | {ok: false; code: string};
|
|
19
|
+
|
|
20
|
+
/** The Desktop host owns the executable paths, confirmations and launch settings. */
|
|
21
|
+
export interface DesktopAiAgentsPort {
|
|
22
|
+
list(): Promise<Result<AgentList>>;
|
|
23
|
+
context(): Promise<Result<AgentContext>>;
|
|
24
|
+
chooseContext(kind: 'project' | 'repository'): Promise<Result<AgentContext | null>>;
|
|
25
|
+
chooseApp(): Promise<Result<{selection: string; application: string} | null>>;
|
|
26
|
+
save(revision: string | null, entries: DesktopAgentDraft[]): Promise<Result<AgentList>>;
|
|
27
|
+
launch(id: string): Promise<Result<null>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const defaultDirectory = '{projectFolder}';
|
|
31
|
+
const variables = /\{(projectFolder|repository|branch)\}/gu;
|
|
32
|
+
const strings = {
|
|
33
|
+
section: ['Desktop applications', 'デスクトップアプリ'],
|
|
34
|
+
opensApp: ['Launches a desktop application', 'デスクトップアプリを起動します'],
|
|
35
|
+
add: ['Add an application', 'アプリを追加'],
|
|
36
|
+
name: ['Name', '名前'],
|
|
37
|
+
application: ['Application', 'アプリ'],
|
|
38
|
+
choose: ['Choose…', '選択…'],
|
|
39
|
+
unselected: ['No application selected', 'アプリが選択されていません'],
|
|
40
|
+
args: ['Arguments (one per line)', '引数(1 行に 1 つ)'],
|
|
41
|
+
cwd: ['Working directory', '作業ディレクトリ'],
|
|
42
|
+
url: ['Fallback website (optional)', '代わりに開く Web サイト(任意)'],
|
|
43
|
+
openFallback: ['Open the website', 'Web サイトを開く'],
|
|
44
|
+
'invalid-url': ['Enter an HTTPS address for the fallback website.', '代わりに開く Web サイトには HTTPS の URL を入力してください。'],
|
|
45
|
+
variables: ['Available placeholders: {projectFolder}, {repository}, {branch}.', '使える置き換えは {projectFolder}・{repository}・{branch} です。'],
|
|
46
|
+
chooseProject: ['Choose project folder…', 'プロジェクトフォルダを選択…'],
|
|
47
|
+
chooseRepository: ['Choose Git repository…', 'Git リポジトリを選択…'],
|
|
48
|
+
projectFolder: ['Project folder', 'プロジェクトフォルダ'],
|
|
49
|
+
repository: ['Git repository', 'Git リポジトリ'],
|
|
50
|
+
branch: ['Branch', 'ブランチ'],
|
|
51
|
+
preview: ['Expanded arguments', '置き換え後の引数'],
|
|
52
|
+
up: ['Move up', '上へ移動'],
|
|
53
|
+
down: ['Move down', '下へ移動'],
|
|
54
|
+
remove: ['Remove application', 'アプリを削除'],
|
|
55
|
+
save: ['Save applications', 'アプリの設定を保存'],
|
|
56
|
+
saved: ['Application settings saved.', 'アプリの設定を保存しました。'],
|
|
57
|
+
test: ['Try launching', '試しに起動'],
|
|
58
|
+
saveFirst: ['Save the application before trying it.', '試しに起動するには、先にアプリの設定を保存してください。'],
|
|
59
|
+
launched: ['Launch requested.', 'アプリを起動しました。'],
|
|
60
|
+
invalid: ['Enter a name and choose an application for each entry.', '各項目の名前を入力し、アプリを選択してください。'],
|
|
61
|
+
conflict: ['The application settings changed. Reopen the settings and try again.', 'アプリの設定が変更されました。設定を開き直してからやり直してください。'],
|
|
62
|
+
busy: ['Another application operation is in progress.', '別のアプリ操作を実行中です。'],
|
|
63
|
+
cancelled: ['The operation was cancelled.', '操作をキャンセルしました。'],
|
|
64
|
+
unknown: ['This application is no longer registered.', 'このアプリは登録されていません。'],
|
|
65
|
+
'missing-context': ['Choose the folder or repository used by the launch arguments. A branch is required for {branch}.',
|
|
66
|
+
'引数で使うフォルダまたはリポジトリを選択してください。{branch} にはブランチが必要です。'],
|
|
67
|
+
'invalid-directory': ['The working directory is unavailable.', '作業ディレクトリを利用できません。'],
|
|
68
|
+
'app-missing': ['The selected application is missing or cannot run.', '選択したアプリが見つからないか、起動できません。'],
|
|
69
|
+
'launch-failed': ['The application could not start.', 'アプリを起動できませんでした。'],
|
|
70
|
+
unavailable: ['Desktop application settings are unavailable.', 'デスクトップアプリの設定を利用できません。']
|
|
71
|
+
} as const;
|
|
72
|
+
|
|
73
|
+
export const desktopAgentText = (key: keyof typeof strings, locale: string) => strings[key][isJapanese(locale) ? 1 : 0];
|
|
74
|
+
export const desktopAgentError = (code: string, locale: string) =>
|
|
75
|
+
desktopAgentText(Object.hasOwn(strings, code) ? code as keyof typeof strings : 'unavailable', locale);
|
|
76
|
+
|
|
77
|
+
export async function agentRequest<T>(request: () => Promise<Result<T>>): Promise<Result<T>> {
|
|
78
|
+
try {
|
|
79
|
+
return await request();
|
|
80
|
+
} catch {
|
|
81
|
+
return {ok: false, code: 'unavailable'};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** An optional section of the existing settings dialog. Its changes are saved by the Desktop host. */
|
|
86
|
+
export function desktopAgentSettings(doc: Document, port: DesktopAiAgentsPort, locale: string,
|
|
87
|
+
styles: Record<string, string>, onSave?: () => void) {
|
|
88
|
+
const text = (key: keyof typeof strings) => desktopAgentText(key, locale);
|
|
89
|
+
const make = <K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, content?: string) => {
|
|
90
|
+
const node = doc.createElement(tag);
|
|
91
|
+
if (className) node.className = className;
|
|
92
|
+
if (content) node.textContent = content;
|
|
93
|
+
return node;
|
|
94
|
+
};
|
|
95
|
+
const button = (key: keyof typeof strings, action: () => void) => {
|
|
96
|
+
const node = make('button', styles.aiAgentDialogButton, text(key));
|
|
97
|
+
node.type = 'button';
|
|
98
|
+
node.addEventListener('click', action);
|
|
99
|
+
return node;
|
|
100
|
+
};
|
|
101
|
+
const field = (key: keyof typeof strings, input: HTMLElement) => {
|
|
102
|
+
const label = make('label', styles.aiAgentDialogField, text(key));
|
|
103
|
+
label.append(input);
|
|
104
|
+
return label;
|
|
105
|
+
};
|
|
106
|
+
const list = make('div', styles.aiAgentDialogList);
|
|
107
|
+
const status = make('p', styles.aiAgentDialogNote);
|
|
108
|
+
status.setAttribute('role', 'status');
|
|
109
|
+
const section = make('fieldset', styles.aiAgentDialogSection);
|
|
110
|
+
let entries: DesktopAgent[] = [];
|
|
111
|
+
let saved: AgentList = {revision: null, entries: []};
|
|
112
|
+
let context: AgentContext | null = null;
|
|
113
|
+
const previews = new Map<string, () => void>();
|
|
114
|
+
|
|
115
|
+
const run = async <T,>(request: () => Promise<Result<T>>, done: (value: T) => void) => {
|
|
116
|
+
const focused = doc.activeElement as HTMLElement | null;
|
|
117
|
+
section.disabled = true;
|
|
118
|
+
status.textContent = '';
|
|
119
|
+
const result = await agentRequest(request);
|
|
120
|
+
if (!section.isConnected) return;
|
|
121
|
+
section.disabled = false;
|
|
122
|
+
if ('code' in result) status.textContent = desktopAgentError(result.code, locale);
|
|
123
|
+
else done(result.value);
|
|
124
|
+
if (doc.activeElement === doc.body && focused?.isConnected && section.contains(focused)) focused.focus();
|
|
125
|
+
};
|
|
126
|
+
const contextSummary = make('p', styles.aiAgentDialogNote);
|
|
127
|
+
contextSummary.style.overflowWrap = 'anywhere';
|
|
128
|
+
const refreshPreviews = () => {
|
|
129
|
+
contextSummary.textContent = (['projectFolder', 'repository', 'branch'] as const)
|
|
130
|
+
.map(key => `${text(key)} ${context?.[key] ?? '—'}`).join(' · ');
|
|
131
|
+
previews.forEach(render => render());
|
|
132
|
+
};
|
|
133
|
+
const chooseContext = (kind: 'project' | 'repository') => {
|
|
134
|
+
void run(() => port.chooseContext(kind), value => {
|
|
135
|
+
if (value) context = value;
|
|
136
|
+
refreshPreviews();
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const add = button('add', () => {
|
|
140
|
+
const entry = {id: globalThis.crypto.randomUUID(), name: '', application: '', args: [], cwd: defaultDirectory};
|
|
141
|
+
entries.push(entry);
|
|
142
|
+
render();
|
|
143
|
+
list.lastElementChild?.querySelector('input')?.focus();
|
|
144
|
+
});
|
|
145
|
+
const toDraft = ({id, name, args, cwd, selection, url}: DesktopAgent): DesktopAgentDraft =>
|
|
146
|
+
({id, name, args, cwd, ...(selection ? {selection} : {}), ...(url?.trim() ? {url: url.trim()} : {})});
|
|
147
|
+
const save = button('save', () => {
|
|
148
|
+
if (entries.some(entry => !entry.name.trim() || !entry.application)) {
|
|
149
|
+
status.textContent = text('invalid');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
void run(() => port.save(saved.revision, entries.map(toDraft)), value => {
|
|
153
|
+
saved = value;
|
|
154
|
+
entries = value.entries.map(entry => ({...entry}));
|
|
155
|
+
render();
|
|
156
|
+
status.textContent = text('saved');
|
|
157
|
+
onSave?.();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
function render() {
|
|
162
|
+
previews.clear();
|
|
163
|
+
list.replaceChildren();
|
|
164
|
+
for (const [index, entry] of entries.entries()) {
|
|
165
|
+
const row = make('div', styles.aiAgentDialogRow);
|
|
166
|
+
row.setAttribute('role', 'group');
|
|
167
|
+
row.setAttribute('aria-label', entry.name || text('application'));
|
|
168
|
+
const name = make('input');
|
|
169
|
+
name.maxLength = 120;
|
|
170
|
+
name.value = entry.name;
|
|
171
|
+
name.oninput = () => {
|
|
172
|
+
entry.name = name.value;
|
|
173
|
+
row.setAttribute('aria-label', entry.name || text('application'));
|
|
174
|
+
};
|
|
175
|
+
const application = make('p', styles.aiAgentDialogNote, entry.application || text('unselected'));
|
|
176
|
+
const choose = button('choose', () => {
|
|
177
|
+
void run(() => port.chooseApp(), value => {
|
|
178
|
+
if (value) Object.assign(entry, value);
|
|
179
|
+
application.textContent = entry.application || text('unselected');
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
choose.setAttribute('aria-label', `${text('application')} ${text('choose')}`);
|
|
183
|
+
const args = make('textarea');
|
|
184
|
+
args.rows = 3;
|
|
185
|
+
args.value = entry.args.join('\n');
|
|
186
|
+
const cwd = make('input');
|
|
187
|
+
cwd.placeholder = defaultDirectory;
|
|
188
|
+
cwd.maxLength = 1024;
|
|
189
|
+
cwd.value = entry.cwd;
|
|
190
|
+
const url = make('input');
|
|
191
|
+
url.type = 'url';
|
|
192
|
+
url.maxLength = 2048;
|
|
193
|
+
url.value = entry.url ?? '';
|
|
194
|
+
url.oninput = () => { entry.url = url.value; };
|
|
195
|
+
const preview = make('p', styles.aiAgentDialogNote);
|
|
196
|
+
const updatePreview = () => {
|
|
197
|
+
const expand = (value: string) => value.replace(variables, (match, key: keyof AgentContext) => context?.[key] ?? match);
|
|
198
|
+
const directory = (entry.cwd.trim() || defaultDirectory);
|
|
199
|
+
preview.textContent = `${text('preview')} ${JSON.stringify(entry.args.map(expand))}\n${text('cwd')} ${
|
|
200
|
+
directory === defaultDirectory && !context?.projectFolder ? '—' : expand(directory)}`;
|
|
201
|
+
};
|
|
202
|
+
preview.style.whiteSpace = 'pre-wrap';
|
|
203
|
+
preview.style.overflowWrap = 'anywhere';
|
|
204
|
+
previews.set(entry.id, updatePreview);
|
|
205
|
+
updatePreview();
|
|
206
|
+
args.oninput = () => {
|
|
207
|
+
entry.args = args.value ? args.value.split('\n') : [];
|
|
208
|
+
updatePreview();
|
|
209
|
+
};
|
|
210
|
+
cwd.oninput = () => {
|
|
211
|
+
entry.cwd = cwd.value;
|
|
212
|
+
updatePreview();
|
|
213
|
+
};
|
|
214
|
+
const move = (offset: number) => {
|
|
215
|
+
entries.splice(index, 1);
|
|
216
|
+
entries.splice(index + offset, 0, entry);
|
|
217
|
+
render();
|
|
218
|
+
list.children[index + offset].querySelector('input')?.focus();
|
|
219
|
+
};
|
|
220
|
+
const up = button('up', () => move(-1));
|
|
221
|
+
const down = button('down', () => move(1));
|
|
222
|
+
up.disabled = index === 0;
|
|
223
|
+
down.disabled = index === entries.length - 1;
|
|
224
|
+
const remove = button('remove', () => {
|
|
225
|
+
entries.splice(index, 1);
|
|
226
|
+
render();
|
|
227
|
+
(list.children[Math.min(index, entries.length - 1)]?.querySelector('input') ?? add).focus();
|
|
228
|
+
});
|
|
229
|
+
const tryLaunch = button('test', () => {
|
|
230
|
+
const original = saved.entries.find(item => item.id === entry.id);
|
|
231
|
+
if (!original || JSON.stringify(toDraft(original)) !== JSON.stringify(toDraft(entry))) {
|
|
232
|
+
status.textContent = text('saveFirst');
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
void run(() => port.launch(entry.id), () => { status.textContent = text('launched'); });
|
|
236
|
+
});
|
|
237
|
+
row.append(field('name', name), application, choose, field('args', args), field('cwd', cwd), preview, field('url', url),
|
|
238
|
+
up, down, remove, tryLaunch);
|
|
239
|
+
list.append(row);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
section.addEventListener('keydown', event => {
|
|
244
|
+
if (event.key === 'Enter' && (event.target as HTMLElement).tagName === 'INPUT') event.preventDefault();
|
|
245
|
+
});
|
|
246
|
+
section.append(make('legend', undefined, text('section')), make('p', styles.aiAgentDialogNote, text('variables')),
|
|
247
|
+
button('chooseProject', () => chooseContext('project')), button('chooseRepository', () => chooseContext('repository')),
|
|
248
|
+
contextSummary, list, add, save, status);
|
|
249
|
+
section.disabled = true;
|
|
250
|
+
// The dialog attaches this section to the document before the requests resolve.
|
|
251
|
+
void Promise.all([agentRequest(() => port.list()), agentRequest(() => port.context())]).then(([settings, current]) => {
|
|
252
|
+
if (!section.isConnected) return;
|
|
253
|
+
if ('code' in settings) {
|
|
254
|
+
status.textContent = desktopAgentError(settings.code, locale);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
saved = settings.value;
|
|
258
|
+
entries = saved.entries.map(entry => ({...entry}));
|
|
259
|
+
if ('value' in current) context = current.value;
|
|
260
|
+
refreshPreviews();
|
|
261
|
+
section.disabled = false;
|
|
262
|
+
render();
|
|
263
|
+
});
|
|
264
|
+
return section;
|
|
265
|
+
}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
interface DocumentPanelSession {
|
|
2
|
+
requestClose(): void;
|
|
3
|
+
dispose(): void;
|
|
4
|
+
save?(): void | Promise<void>;
|
|
5
|
+
readonly fileEdit?: {
|
|
6
|
+
directory: FileSystemDirectoryHandle;
|
|
7
|
+
path: string;
|
|
8
|
+
isDirty(): boolean;
|
|
9
|
+
readUnsaved?(): Uint8Array | undefined;
|
|
10
|
+
save(): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
1
14
|
export interface DocumentPanelRequest {
|
|
2
15
|
reference: {providerId: string; documentId: string};
|
|
3
16
|
filename: string;
|
|
4
17
|
/** What the tab shows. Without it the tab names the file and where it comes from. */
|
|
5
18
|
title?: string;
|
|
6
19
|
transient?: boolean;
|
|
20
|
+
/** Keeps this utility tab first while the host enables the project folder drawer. */
|
|
21
|
+
pinWithProjectFolder?: boolean;
|
|
7
22
|
/**
|
|
8
23
|
* Opens the tab beside the other open tabs of the same area, in one split panel. The first tab of an area
|
|
9
24
|
* opens in a new split to the right of the active panel, so the area does not mix with the sprite tabs.
|
|
@@ -16,7 +31,7 @@ export interface DocumentPanelRequest {
|
|
|
16
31
|
tabGroup?: {id: string; label: string; color?: string; collapsed?: boolean};
|
|
17
32
|
/** Opens the tab behind the active one, as when many tabs are opened at once. */
|
|
18
33
|
inactive?: boolean;
|
|
19
|
-
mount(element: HTMLElement, close: () => void
|
|
34
|
+
mount(element: HTMLElement, close: () => void, onSaveAvailable?: () => void): DocumentPanelSession;
|
|
20
35
|
}
|
|
21
36
|
|
|
22
37
|
export const documentPanelTitle = ({title, filename, reference: {providerId, documentId}}: DocumentPanelRequest) =>
|
|
@@ -31,6 +46,11 @@ function createDocumentWorkspace() {
|
|
|
31
46
|
let open: ((request: DocumentPanelRequest) => void) | undefined;
|
|
32
47
|
let source: DocumentPanelSource | undefined;
|
|
33
48
|
const listeners = new Set<() => void>();
|
|
49
|
+
let saveScope: 'project' | 'tab' = 'project';
|
|
50
|
+
let activeSession: (() => DocumentPanelSession | undefined) | undefined;
|
|
51
|
+
let sessions: (() => Iterable<DocumentPanelSession | undefined>) | undefined;
|
|
52
|
+
const saveListeners = new Set<() => void>();
|
|
53
|
+
const notifySave = () => saveListeners.forEach(listener => listener());
|
|
34
54
|
const notify = () => listeners.forEach(listener => listener());
|
|
35
55
|
return {
|
|
36
56
|
open(request: DocumentPanelRequest) {
|
|
@@ -38,9 +58,38 @@ function createDocumentWorkspace() {
|
|
|
38
58
|
open(request);
|
|
39
59
|
return true;
|
|
40
60
|
},
|
|
41
|
-
connect(handler: NonNullable<typeof open
|
|
61
|
+
connect(handler: NonNullable<typeof open>, getActiveSession?: NonNullable<typeof activeSession>,
|
|
62
|
+
getSessions?: NonNullable<typeof sessions>) {
|
|
42
63
|
open = handler;
|
|
43
|
-
|
|
64
|
+
activeSession = getActiveSession;
|
|
65
|
+
sessions = getSessions;
|
|
66
|
+
notifySave();
|
|
67
|
+
return () => {
|
|
68
|
+
if (open !== handler) return;
|
|
69
|
+
open = undefined;
|
|
70
|
+
activeSession = undefined;
|
|
71
|
+
sessions = undefined;
|
|
72
|
+
notifySave();
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
setSaveScope(scope: typeof saveScope) {
|
|
76
|
+
if (scope === saveScope) return;
|
|
77
|
+
saveScope = scope;
|
|
78
|
+
notifySave();
|
|
79
|
+
},
|
|
80
|
+
get saveScope() {return saveScope;},
|
|
81
|
+
get canSaveActive() {return Boolean(activeSession?.()?.save);},
|
|
82
|
+
saveActive() {return activeSession?.()?.save?.();},
|
|
83
|
+
fileEdits() {
|
|
84
|
+
return Array.from(sessions?.() ?? []).flatMap(session => {
|
|
85
|
+
const file = session?.fileEdit;
|
|
86
|
+
return file?.isDirty() ? [file] : [];
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
notifySave,
|
|
90
|
+
subscribeSave(listener: () => void) {
|
|
91
|
+
saveListeners.add(listener);
|
|
92
|
+
return () => {saveListeners.delete(listener);};
|
|
44
93
|
},
|
|
45
94
|
connectSource(next: DocumentPanelSource) {
|
|
46
95
|
source = next;
|
package/src/drawer-views.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type {ReactNode} from 'react';
|
|
2
2
|
|
|
3
3
|
/** The contents the left drawer can show. `sprites` is the GUI's sprite list and backdrop, always available. */
|
|
4
|
-
export type DrawerViewId = 'sprites' | 'project' | 'git-history';
|
|
4
|
+
export type DrawerViewId = 'sprites' | 'project' | 'git-history' | 'agents';
|
|
5
5
|
/** The contents a host supplies. */
|
|
6
6
|
export type HostDrawerViewId = Exclude<DrawerViewId, 'sprites'>;
|
|
7
7
|
|
|
8
8
|
export interface DrawerRenderProps {
|
|
9
9
|
/** The Editor locale, for example `ja` or `en`. */
|
|
10
10
|
locale: string;
|
|
11
|
+
/** The search text supplied by the drawer's search field. */
|
|
12
|
+
query?: string;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/** A drawer content supplied by the host. Its button appears only while the host supplies it. */
|
|
@@ -21,6 +23,8 @@ export interface DrawerView {
|
|
|
21
23
|
render(props: DrawerRenderProps): ReactNode;
|
|
22
24
|
/** The view's own tools, shown where the sprite list shows search, pin and undock. */
|
|
23
25
|
tools?(props: DrawerRenderProps): ReactNode;
|
|
26
|
+
/** The accessible name of the search field, if this view supports search. */
|
|
27
|
+
searchLabel?(locale: string): string;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export interface DrawerMenuRenderProps extends DrawerRenderProps {
|
|
@@ -40,9 +44,13 @@ export interface DrawerMenu {
|
|
|
40
44
|
export interface DrawerViews {
|
|
41
45
|
views?: readonly DrawerView[];
|
|
42
46
|
agents?: DrawerMenu;
|
|
47
|
+
/** Reports the drawer view presented by the standard layout. */
|
|
48
|
+
onSelectionChange?(view: DrawerViewId): void;
|
|
49
|
+
/** Exposes the drawer's reveal action to other panels in the same Editor. */
|
|
50
|
+
registerReveal?(reveal: (id: HostDrawerViewId) => void): () => void;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
export const drawerViewIds: readonly DrawerViewId[] = ['sprites', 'project', 'git-history'];
|
|
53
|
+
export const drawerViewIds: readonly DrawerViewId[] = ['sprites', 'project', 'git-history', 'agents'];
|
|
46
54
|
const hostIds = new Set<string>(drawerViewIds.slice(1));
|
|
47
55
|
|
|
48
56
|
const names = {
|
|
@@ -104,6 +112,8 @@ export function writeDrawerView(storage: DrawerStorage | null | undefined, stora
|
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
|
|
115
|
+
export const projectFolderIconPath = 'M1.5 4V13h13V5.5H8L6.5 3.5h-4A1 1 0 0 0 1.5 4.5Z';
|
|
116
|
+
|
|
107
117
|
let nextMenuId = 0;
|
|
108
118
|
|
|
109
119
|
export function createDrawerViewBar(React, styles) {
|
|
@@ -116,7 +126,7 @@ export function createDrawerViewBar(React, styles) {
|
|
|
116
126
|
sprites: () => svg(element('rect', {x: 2, y: 2, width: 5, height: 5, rx: 1}),
|
|
117
127
|
element('rect', {x: 9, y: 2, width: 5, height: 5, rx: 1}),
|
|
118
128
|
element('rect', {x: 2, y: 9, width: 12, height: 5, rx: 1})),
|
|
119
|
-
project: () => svg(element('path', {d:
|
|
129
|
+
project: () => svg(element('path', {d: projectFolderIconPath})),
|
|
120
130
|
'git-history': () => svg(element('circle', {cx: 5, cy: 3.5, r: 1.5}), element('circle', {cx: 5, cy: 12.5, r: 1.5}),
|
|
121
131
|
element('circle', {cx: 11, cy: 6.5, r: 1.5}), element('path', {d: 'M5 5v6M11 8c0 2.5-6 1.5-6 3'})),
|
|
122
132
|
agents: () => svg(element('path', {d: agentsIconPath}))
|
|
@@ -172,7 +182,8 @@ export function createDrawerViewBar(React, styles) {
|
|
|
172
182
|
...views.map(view => ({id: view.id, label: view.label ?? drawerLabel(view.id, locale),
|
|
173
183
|
icon: view.icon ?? icons[view.id]()}))
|
|
174
184
|
];
|
|
175
|
-
const
|
|
185
|
+
const menu = entries.some(entry => entry.id === 'agents') ? undefined : agents;
|
|
186
|
+
const count = entries.length + (menu ? 1 : 0);
|
|
176
187
|
const [focused, setFocused] = useState(() => Math.max(0, entries.findIndex(entry => entry.id === selected)));
|
|
177
188
|
const current = Math.min(focused, count - 1);
|
|
178
189
|
const move = (event, index) => {
|
|
@@ -200,8 +211,8 @@ export function createDrawerViewBar(React, styles) {
|
|
|
200
211
|
onClick: () => onSelect(entry.id),
|
|
201
212
|
onKeyDown: event => move(event, index)
|
|
202
213
|
}, entry.icon)),
|
|
203
|
-
|
|
204
|
-
menu
|
|
214
|
+
menu && element(AgentMenu, {
|
|
215
|
+
menu, locale, button: agentButton,
|
|
205
216
|
tabIndex: current === entries.length ? 0 : -1,
|
|
206
217
|
onFocus: () => setFocused(entries.length),
|
|
207
218
|
onKeyDown: event => move(event, entries.length)
|
package/src/editor.css
CHANGED
|
@@ -717,8 +717,10 @@ details.layout-menu button {
|
|
|
717
717
|
.target-list-tools {
|
|
718
718
|
display: flex;
|
|
719
719
|
align-items: center;
|
|
720
|
-
justify-content:
|
|
721
|
-
|
|
720
|
+
justify-content: flex-end;
|
|
721
|
+
flex: none;
|
|
722
|
+
gap: 0.25rem;
|
|
723
|
+
padding: 0.125rem 0.25rem;
|
|
722
724
|
}
|
|
723
725
|
|
|
724
726
|
.target-list-tools button,
|
|
@@ -728,19 +730,22 @@ details.layout-menu button {
|
|
|
728
730
|
min-width: 1.5rem;
|
|
729
731
|
min-height: 1.5rem;
|
|
730
732
|
padding: 0.125rem;
|
|
731
|
-
border:
|
|
733
|
+
border: 0;
|
|
732
734
|
border-radius: 0.25rem;
|
|
733
735
|
background: transparent;
|
|
734
736
|
color: var(--text-primary);
|
|
735
737
|
cursor: pointer;
|
|
736
738
|
}
|
|
737
739
|
|
|
738
|
-
.target-list-tools button:hover
|
|
739
|
-
.target-list-tools button:focus-visible {
|
|
740
|
-
border-color: var(--ui-black-transparent);
|
|
740
|
+
.target-list-tools button:hover {
|
|
741
741
|
background: var(--ui-primary);
|
|
742
742
|
}
|
|
743
743
|
|
|
744
|
+
.target-list-tools button:focus-visible {
|
|
745
|
+
outline: 2px solid var(--looks-secondary);
|
|
746
|
+
outline-offset: -2px;
|
|
747
|
+
}
|
|
748
|
+
|
|
744
749
|
.target-list-tools svg {
|
|
745
750
|
width: 0.875rem;
|
|
746
751
|
height: 0.875rem;
|
|
@@ -940,7 +945,8 @@ details.layout-menu button {
|
|
|
940
945
|
gap: 0.125rem;
|
|
941
946
|
}
|
|
942
947
|
|
|
943
|
-
.ai-agent-dialog-field input
|
|
948
|
+
.ai-agent-dialog-field input,
|
|
949
|
+
.ai-agent-dialog-field textarea {
|
|
944
950
|
box-sizing: border-box;
|
|
945
951
|
inline-size: 100%;
|
|
946
952
|
padding: 0.375rem 0.5rem;
|
|
@@ -1003,12 +1009,23 @@ details.layout-menu button {
|
|
|
1003
1009
|
color: #fff;
|
|
1004
1010
|
}
|
|
1005
1011
|
|
|
1006
|
-
.drawer-view
|
|
1012
|
+
.drawer-host-view {
|
|
1007
1013
|
display: flex;
|
|
1008
|
-
flex:
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1014
|
+
flex: 1;
|
|
1015
|
+
flex-direction: column;
|
|
1016
|
+
min-block-size: 0;
|
|
1017
|
+
min-inline-size: 0;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.drawer-host-view[hidden] {
|
|
1021
|
+
display: none;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
.drawer-host-view > .basic-panel {
|
|
1025
|
+
display: flex;
|
|
1026
|
+
flex: 1;
|
|
1027
|
+
flex-direction: column;
|
|
1028
|
+
min-block-size: 0;
|
|
1012
1029
|
}
|
|
1013
1030
|
|
|
1014
1031
|
.drawer-sprites {
|
|
@@ -1118,6 +1135,20 @@ details.layout-menu button {
|
|
|
1118
1135
|
object-fit: contain;
|
|
1119
1136
|
}
|
|
1120
1137
|
|
|
1138
|
+
:global(.tw-plus-folder-tab-icon) {
|
|
1139
|
+
display: none;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
:global([data-fixed-project-tab] .tw-plus-folder-tab-icon) {
|
|
1143
|
+
display: block;
|
|
1144
|
+
color: var(--looks-secondary, #855cd6);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
:global([data-fixed-project-tab] .dv-default-tab-action),
|
|
1148
|
+
:global([data-fixed-project-tab] img.tw-plus-sprite-tab-icon[hidden]) {
|
|
1149
|
+
display: none;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1121
1152
|
.sprite-tabs :global(.tw-plus-sprite-rename) {
|
|
1122
1153
|
border: 1px solid var(--ui-black-transparent);
|
|
1123
1154
|
border-radius: 0.5rem;
|