@kubohiroya/turbowarp-plus-editor-workbench 0.4.0 → 0.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.
@@ -0,0 +1,66 @@
1
+ import type { ReactNode } from 'react';
2
+ /** The contents the left drawer can show. `sprites` is the GUI's sprite list and backdrop, always available. */
3
+ export type DrawerViewId = 'sprites' | 'project' | 'git-history';
4
+ /** The contents a host supplies. */
5
+ export type HostDrawerViewId = Exclude<DrawerViewId, 'sprites'>;
6
+ export interface DrawerRenderProps {
7
+ /** The Editor locale, for example `ja` or `en`. */
8
+ locale: string;
9
+ }
10
+ /** A drawer content supplied by the host. Its button appears only while the host supplies it. */
11
+ export interface DrawerView {
12
+ id: HostDrawerViewId;
13
+ /** The button's name. Defaults to the package's Japanese or English name for `id`. */
14
+ label?: string;
15
+ /** A 16 px inline icon drawn with `currentColor`. Defaults to the package's icon for `id`. */
16
+ icon?: ReactNode;
17
+ /** The content. Rendered only while the view is selected. */
18
+ render(props: DrawerRenderProps): ReactNode;
19
+ /** The view's own tools, shown where the sprite list shows search, pin and undock. */
20
+ tools?(props: DrawerRenderProps): ReactNode;
21
+ }
22
+ export interface DrawerMenuRenderProps extends DrawerRenderProps {
23
+ /** Close the menu and return focus to its button. */
24
+ close(): void;
25
+ }
26
+ /** The AI agent menu supplied by the host. Opening it does not change the drawer's content. */
27
+ export interface DrawerMenu {
28
+ label?: string;
29
+ icon?: ReactNode;
30
+ /** The menu content, normally one `role="menu"` element with `menuitem` children. */
31
+ renderMenu(props: DrawerMenuRenderProps): ReactNode;
32
+ }
33
+ /** What the host passes to `StandardLayout` as `drawerViews`. */
34
+ export interface DrawerViews {
35
+ views?: readonly DrawerView[];
36
+ agents?: DrawerMenu;
37
+ }
38
+ export declare const drawerViewIds: readonly DrawerViewId[];
39
+ declare const names: {
40
+ readonly sprites: readonly ["スプライト一覧", "Sprites"];
41
+ readonly project: readonly ["プロジェクトフォルダ", "Project folder"];
42
+ readonly 'git-history': readonly ["Git 履歴", "Git history"];
43
+ readonly agents: readonly ["AI エージェント", "AI agents"];
44
+ readonly bar: readonly ["ドロワーの表示", "Drawer views"];
45
+ };
46
+ /** The AI agent button's sparkle, also used beside the host's entry for the AI agent settings. */
47
+ export declare const agentsIconPath = "M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6Z";
48
+ export declare const isJapanese: (locale: string) => boolean;
49
+ export declare const drawerLabel: (id: keyof typeof names, locale: string) => "スプライト一覧" | "Sprites" | "プロジェクトフォルダ" | "Project folder" | "Git 履歴" | "Git history" | "AI エージェント" | "AI agents" | "ドロワーの表示" | "Drawer views";
50
+ /** The supported host views in button order, without unknown or repeated ids. */
51
+ export declare function availableDrawerViews(drawerViews: DrawerViews | undefined): DrawerView[];
52
+ /** The bar is shown only when the host supplies something besides the sprite list. */
53
+ export declare const hasDrawerBar: (drawerViews: DrawerViews | undefined) => boolean;
54
+ type DrawerStorage = Pick<Storage, 'getItem' | 'setItem'>;
55
+ export declare const drawerViewKey: (storageKey: string) => string;
56
+ /** The view selected last time, or `sprites`. The caller falls back to `sprites` while that view is unavailable. */
57
+ export declare function readDrawerView(storage: DrawerStorage | null | undefined, storageKey: string | undefined): DrawerViewId;
58
+ export declare function writeDrawerView(storage: DrawerStorage | null | undefined, storageKey: string | undefined, view: DrawerViewId): void;
59
+ export declare function createDrawerViewBar(React: any, styles: any): ({ locale, views, agents, selected, onSelect }: {
60
+ locale: any;
61
+ views: any;
62
+ agents: any;
63
+ selected: any;
64
+ onSelect: any;
65
+ }) => any;
66
+ export {};
@@ -0,0 +1,152 @@
1
+ export const drawerViewIds = ['sprites', 'project', 'git-history'];
2
+ const hostIds = new Set(drawerViewIds.slice(1));
3
+ const names = {
4
+ sprites: ['スプライト一覧', 'Sprites'],
5
+ project: ['プロジェクトフォルダ', 'Project folder'],
6
+ 'git-history': ['Git 履歴', 'Git history'],
7
+ agents: ['AI エージェント', 'AI agents'],
8
+ bar: ['ドロワーの表示', 'Drawer views']
9
+ };
10
+ /** The AI agent button's sparkle, also used beside the host's entry for the AI agent settings. */
11
+ export const agentsIconPath = 'M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6Z';
12
+ export const isJapanese = (locale) => /^ja(?:-|$)/i.test(locale ?? '');
13
+ export const drawerLabel = (id, locale) => names[id][isJapanese(locale) ? 0 : 1];
14
+ /** The supported host views in button order, without unknown or repeated ids. */
15
+ export function availableDrawerViews(drawerViews) {
16
+ const views = drawerViews?.views ?? [];
17
+ return drawerViewIds.slice(1).flatMap(id => {
18
+ const view = views.find(candidate => candidate && candidate.id === id && hostIds.has(candidate.id) &&
19
+ typeof candidate.render === 'function');
20
+ return view ? [view] : [];
21
+ });
22
+ }
23
+ /** The bar is shown only when the host supplies something besides the sprite list. */
24
+ export const hasDrawerBar = (drawerViews) => availableDrawerViews(drawerViews).length > 0 || typeof drawerViews?.agents?.renderMenu === 'function';
25
+ export const drawerViewKey = (storageKey) => `${storageKey}.drawer`;
26
+ /** The view selected last time, or `sprites`. The caller falls back to `sprites` while that view is unavailable. */
27
+ export function readDrawerView(storage, storageKey) {
28
+ if (!storage || !storageKey)
29
+ return 'sprites';
30
+ try {
31
+ const saved = JSON.parse(storage.getItem(drawerViewKey(storageKey)) ?? 'null');
32
+ if (saved?.version === 1 && drawerViewIds.includes(saved.view))
33
+ return saved.view;
34
+ }
35
+ catch {
36
+ // Storage can be unavailable or contain obsolete data.
37
+ }
38
+ return 'sprites';
39
+ }
40
+ export function writeDrawerView(storage, storageKey, view) {
41
+ if (!storage || !storageKey)
42
+ return;
43
+ try {
44
+ storage.setItem(drawerViewKey(storageKey), JSON.stringify({ version: 1, view }));
45
+ }
46
+ catch {
47
+ // Keep the drawer usable when persistence is denied.
48
+ }
49
+ }
50
+ let nextMenuId = 0;
51
+ export function createDrawerViewBar(React, styles) {
52
+ const { createElement: element, useLayoutEffect, useRef, useState } = React;
53
+ const svg = (...children) => element('svg', {
54
+ 'aria-hidden': true, focusable: false, width: 16, height: 16, viewBox: '0 0 16 16',
55
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', strokeLinejoin: 'round'
56
+ }, ...children);
57
+ const icons = {
58
+ sprites: () => svg(element('rect', { x: 2, y: 2, width: 5, height: 5, rx: 1 }), element('rect', { x: 9, y: 2, width: 5, height: 5, rx: 1 }), element('rect', { x: 2, y: 9, width: 12, height: 5, rx: 1 })),
59
+ project: () => svg(element('path', { d: 'M1.5 4V13h13V5.5H8L6.5 3.5h-4A1 1 0 0 0 1.5 4.5Z' })),
60
+ 'git-history': () => svg(element('circle', { cx: 5, cy: 3.5, r: 1.5 }), element('circle', { cx: 5, cy: 12.5, r: 1.5 }), element('circle', { cx: 11, cy: 6.5, r: 1.5 }), element('path', { d: 'M5 5v6M11 8c0 2.5-6 1.5-6 3' })),
61
+ agents: () => svg(element('path', { d: agentsIconPath }))
62
+ };
63
+ function AgentMenu({ menu, locale, button, onFocus, onKeyDown, tabIndex }) {
64
+ const [open, setOpen] = useState(false);
65
+ const popup = useRef(null);
66
+ const id = useRef(null);
67
+ if (!id.current)
68
+ id.current = `plus-drawer-agents-${++nextMenuId}`;
69
+ const label = menu.label ?? drawerLabel('agents', locale);
70
+ const close = (focus = true) => {
71
+ setOpen(false);
72
+ if (focus)
73
+ button.current?.focus();
74
+ };
75
+ useLayoutEffect(() => {
76
+ if (!open)
77
+ return;
78
+ const node = popup.current;
79
+ node?.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], button, a[href], input')
80
+ ?.focus({ preventScroll: true });
81
+ const doc = node?.ownerDocument;
82
+ const outside = event => {
83
+ if (!node.contains(event.target) && !button.current?.contains(event.target))
84
+ close(false);
85
+ };
86
+ doc?.addEventListener('pointerdown', outside, true);
87
+ return () => doc?.removeEventListener('pointerdown', outside, true);
88
+ }, [open]);
89
+ return element('div', { className: styles.drawerAgents }, element('button', {
90
+ type: 'button', ref: button, tabIndex, 'aria-label': label, title: label,
91
+ 'aria-haspopup': 'menu', 'aria-expanded': open, 'aria-controls': open ? id.current : undefined,
92
+ 'data-drawer-view': 'agents',
93
+ onClick: () => setOpen(value => !value),
94
+ onFocus, onKeyDown
95
+ }, menu.icon ?? icons.agents()), open && element('div', {
96
+ id: id.current, ref: popup, className: styles.drawerAgentsMenu,
97
+ onKeyDown: event => {
98
+ if (event.key !== 'Escape')
99
+ return;
100
+ event.preventDefault();
101
+ event.stopPropagation();
102
+ close();
103
+ }
104
+ }, menu.renderMenu({ locale, close: () => close() })));
105
+ }
106
+ /** The row of icon buttons at the top of the left drawer. */
107
+ return function DrawerViewBar({ locale, views, agents, selected, onSelect }) {
108
+ const bar = useRef(null);
109
+ const agentButton = useRef(null);
110
+ const entries = [
111
+ { id: 'sprites', label: drawerLabel('sprites', locale), icon: icons.sprites() },
112
+ ...views.map(view => ({ id: view.id, label: view.label ?? drawerLabel(view.id, locale),
113
+ icon: view.icon ?? icons[view.id]() }))
114
+ ];
115
+ const count = entries.length + (agents ? 1 : 0);
116
+ const [focused, setFocused] = useState(() => Math.max(0, entries.findIndex(entry => entry.id === selected)));
117
+ const current = Math.min(focused, count - 1);
118
+ const move = (event, index) => {
119
+ const buttons = bar.current.querySelectorAll('[data-drawer-view]');
120
+ const rtl = bar.current.ownerDocument.defaultView.getComputedStyle(bar.current).direction === 'rtl';
121
+ const step = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1 }[event.key];
122
+ let next;
123
+ if (event.key === 'Home')
124
+ next = 0;
125
+ else if (event.key === 'End')
126
+ next = count - 1;
127
+ else if (step)
128
+ next = (index + step + count) % count;
129
+ else
130
+ return;
131
+ event.preventDefault();
132
+ setFocused(next);
133
+ buttons[next]?.focus();
134
+ };
135
+ return element('div', {
136
+ className: styles.drawerViewBar, role: 'toolbar', ref: bar,
137
+ 'aria-label': drawerLabel('bar', locale)
138
+ }, entries.map((entry, index) => element('button', {
139
+ key: entry.id, type: 'button', 'data-drawer-view': entry.id,
140
+ 'aria-label': entry.label, title: entry.label, 'aria-pressed': entry.id === selected,
141
+ tabIndex: index === current ? 0 : -1,
142
+ onFocus: () => setFocused(index),
143
+ onClick: () => onSelect(entry.id),
144
+ onKeyDown: event => move(event, index)
145
+ }, entry.icon)), agents && element(AgentMenu, {
146
+ menu: agents, locale, button: agentButton,
147
+ tabIndex: current === entries.length ? 0 : -1,
148
+ onFocus: () => setFocused(entries.length),
149
+ onKeyDown: event => move(event, entries.length)
150
+ }));
151
+ };
152
+ }
@@ -11,6 +11,7 @@ export { getDocumentWorkspace } from './document-workspace.ts';
11
11
  export type { SpriteAssetKind, SpriteAssetPreviewItem } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
12
12
  export { editSpriteVariable } from '@kubohiroya/turbowarp-plus-editor-project-model/sprite-variable-edit';
13
13
  export { useDockviewStage } from './dockview-stage.ts';
14
+ export { SpriteTargetTabsContext, useTargetTabMenu } from './target-tab-menu.ts';
14
15
  interface CostumeAsset {
15
16
  encodeDataURI(): string;
16
17
  }
@@ -132,6 +133,11 @@ declare const renameLabels: {
132
133
  type RenameLabels = typeof renameLabels.en;
133
134
  export declare function mountSpriteTabs<Snapshot>(root: HTMLElement, content: HTMLElement, options: TabOptions<Snapshot>): {
134
135
  select: (id: string) => void;
136
+ selectFromList: (id?: string) => void;
137
+ targetTabs: (id?: string) => {
138
+ id: string;
139
+ title: string;
140
+ }[];
135
141
  openStage: () => void;
136
142
  closeStage: () => void;
137
143
  split: (direction: SpriteSplitDirection, id?: string) => string;
@@ -182,6 +188,11 @@ export declare function useSpriteTabs<Snapshot>({ available, enabled, locale, ..
182
188
  }): {
183
189
  controller: React.MutableRefObject<{
184
190
  select: (id: string) => void;
191
+ selectFromList: (id?: string) => void;
192
+ targetTabs: (id?: string) => {
193
+ id: string;
194
+ title: string;
195
+ }[];
185
196
  openStage: () => void;
186
197
  closeStage: () => void;
187
198
  split: (direction: SpriteSplitDirection, id?: string) => string;
@@ -196,6 +207,15 @@ export declare function useSpriteTabs<Snapshot>({ available, enabled, locale, ..
196
207
  views: () => SpriteTabView[];
197
208
  dispose(): void;
198
209
  }>;
210
+ listTabs: {
211
+ locale: string;
212
+ list: (id?: string) => {
213
+ id: string;
214
+ title: string;
215
+ }[];
216
+ select: (id?: string) => void;
217
+ activate: (id: string) => boolean;
218
+ };
199
219
  assetSelections: Readonly<Record<SpriteAssetKind, SpriteAssetSelection>>;
200
220
  context: {
201
221
  selectedId: string;
@@ -7,9 +7,11 @@ import { SpriteEditorToolbar, spriteEditorSections } from '@kubohiroya/turbowarp
7
7
  import { documentPanelTitle, getDocumentWorkspace } from "./document-workspace.js";
8
8
  import { dockPopoutGroups, positionOnScreen, readWorkspaceLayout, workspaceWithoutTransientPanels } from "./workspace-layout.js";
9
9
  import { SpriteMessagePane } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-message-pane';
10
+ import { createRenameMenuItem, spriteRenameLabel } from "./target-tab-menu.js";
10
11
  export { getDocumentWorkspace } from "./document-workspace.js";
11
12
  export { editSpriteVariable } from '@kubohiroya/turbowarp-plus-editor-project-model/sprite-variable-edit';
12
13
  export { useDockviewStage } from "./dockview-stage.js";
14
+ export { SpriteTargetTabsContext, useTargetTabMenu } from "./target-tab-menu.js";
13
15
  const variableSection = spriteEditorSections.indexOf('variables');
14
16
  const messageSection = spriteEditorSections.indexOf('messages');
15
17
  // The first three sections are the GUI's own panels; the rest are rendered by this package.
@@ -57,8 +59,8 @@ function createAssetSelections(target, locale, source) {
57
59
  const stagePanelId = 'tw-plus-stage-display';
58
60
  const documentComponent = 'tw-plus-document';
59
61
  const renameLabels = {
60
- en: { title: 'Rename sprite', name: 'Sprite name', cancel: 'Cancel', save: 'Rename' },
61
- ja: { title: 'スプライト名の変更', name: 'スプライト名', cancel: 'キャンセル', save: '変更' }
62
+ en: { title: spriteRenameLabel('en'), name: 'Sprite name', cancel: 'Cancel', save: 'Rename' },
63
+ ja: { title: spriteRenameLabel('ja'), name: 'スプライト名', cancel: 'キャンセル', save: '変更' }
62
64
  };
63
65
  const targetName = (target) => target.isStage ? 'Stage' : target.getName();
64
66
  const projectSignature = (targets) => JSON.stringify(targets
@@ -98,7 +100,9 @@ export function mountSpriteTabs(root, content, options) {
98
100
  const japanese = /^ja(?:-|$)/i.test(locale);
99
101
  const editLabel = japanese ? 'クリックしてこのビューで編集' : 'Activate this view to edit';
100
102
  const backdropTitle = japanese ? '背景' : 'Backdrops';
101
- const tabTitle = (target) => target.isStage ? backdropTitle : target.getName();
103
+ const baseTitle = (target) => target.isStage ? backdropTitle : target.getName();
104
+ const numberedTitle = (target, number) => `${baseTitle(target)}(${number})`;
105
+ const tabTitle = ({ target, number }) => number ? numberedTitle(target, number) : baseTitle(target);
102
106
  const chipText = japanese ?
103
107
  { collapse: 'グループを折りたたむ', expand: 'グループを展開する', close: 'このグループのタブを閉じる', closeAll: 'この分割パネルの文書タブをすべて閉じる' } :
104
108
  { collapse: 'Collapse group', expand: 'Expand group', close: 'Close the tabs of this group', closeAll: 'Close all document tabs of this split' };
@@ -154,11 +158,27 @@ export function mountSpriteTabs(root, content, options) {
154
158
  } }
155
159
  ],
156
160
  getTabContextMenuItems: ({ panel }) => {
157
- const target = views.get(panel.id)?.target;
158
- if (!target || target.isStage || !vm.renameSprite)
161
+ const view = views.get(panel.id);
162
+ if (!view)
159
163
  return [];
160
- return [{ label: text.title, action: () => openRenameDialog(target) }];
164
+ const items = [];
165
+ if (multiView)
166
+ items.push({
167
+ label: japanese ? '新しいタブで開く' : 'Open in new tab',
168
+ action: () => openInNewTab(view.id)
169
+ });
170
+ if (!view.target.isStage && vm.renameSprite)
171
+ items.push({
172
+ component: 'rename-sprite'
173
+ });
174
+ return items;
161
175
  },
176
+ createContextMenuItemComponent: ({ component }) => component === 'rename-sprite' ?
177
+ createRenameMenuItem(document, text.title, id => {
178
+ const target = views.get(id)?.target;
179
+ if (target)
180
+ openRenameDialog(target);
181
+ }) : undefined,
162
182
  createComponent: ({ name, id: componentId }) => {
163
183
  const element = document.createElement('div');
164
184
  if (name === documentComponent) {
@@ -508,23 +528,47 @@ export function mountSpriteTabs(root, content, options) {
508
528
  }
509
529
  refreshSurfaces();
510
530
  }
511
- function add(target, splitPosition, section) {
531
+ function nextTabNumber(target, titles) {
532
+ let number = 2;
533
+ while (titles.has(numberedTitle(target, number)))
534
+ number++;
535
+ return number;
536
+ }
537
+ function reservedTitles() {
538
+ return new Set([...originalTargets().map(baseTitle),
539
+ ...dockview.panels.filter(panel => !views.has(panel.id)).map(panel => panel.title)]);
540
+ }
541
+ function assignTabNumbers(items, titles = reservedTitles()) {
542
+ const originals = new Set();
543
+ for (const view of items) {
544
+ if (!view.number && !originals.has(view.target)) {
545
+ originals.add(view.target);
546
+ continue;
547
+ }
548
+ if (!view.number || titles.has(tabTitle(view)))
549
+ view.number = nextTabNumber(view.target, titles);
550
+ titles.add(tabTitle(view));
551
+ }
552
+ }
553
+ function add(target, position, section) {
512
554
  let id = target.id;
513
- if (splitPosition || views.has(id) || id === stagePanelId || documents.has(id)) {
555
+ if (position || views.has(id) || id === stagePanelId || documents.has(id)) {
514
556
  do {
515
557
  id = 'sprite-view-' + ++nextView;
516
558
  } while (views.has(id) || documents.has(id) || vm.runtime.targets.some(item => item.id === id));
517
559
  }
518
- const source = splitPosition && views.get(splitPosition.referencePanel);
560
+ const source = position && views.get(position.referencePanel);
519
561
  // An inactive panel leaves dockview without an active group, and dockview then opens each later
520
562
  // panel in a new group; keep sprites added without a split as tabs of an existing sprite group.
521
- const spriteGroup = !splitPosition && !dockview.activeGroup &&
563
+ const spriteGroup = !position && !dockview.activeGroup &&
522
564
  dockview.groups.find(group => group.panels.some(panel => views.has(panel.id)));
523
- views.set(id, { id, target, section: section ?? remembered.get(target) ?? options.getSection(),
524
- assets: createAssetSelections(target, locale, source?.assets) });
565
+ const view = { id, target, section: section ?? remembered.get(target) ?? options.getSection(),
566
+ number: source && nextTabNumber(target, new Set([...reservedTitles(), ...[...views.values()].map(tabTitle)])),
567
+ assets: createAssetSelections(target, locale, source?.assets) };
568
+ views.set(id, view);
525
569
  try {
526
- return dockview.addPanel({ id, title: tabTitle(target), component: 'sprite', inactive: !splitPosition,
527
- position: splitPosition ?? (spriteGroup ? { referenceGroup: spriteGroup } : undefined),
570
+ return dockview.addPanel({ id, title: tabTitle(view), component: 'sprite', inactive: !position,
571
+ position: position ?? (spriteGroup ? { referenceGroup: spriteGroup } : undefined),
528
572
  params: { icon: getIcon(target) } });
529
573
  }
530
574
  catch (error) {
@@ -554,6 +598,26 @@ export function mountSpriteTabs(root, content, options) {
554
598
  [...views.values()].find(item => item.target === target);
555
599
  activateView(view?.id ?? add(target).id);
556
600
  }
601
+ function targetTabs(id) {
602
+ return dockview.groups.map(group => ({ group, rect: group.element.getBoundingClientRect() }))
603
+ .sort((a, b) => Number(a.group.api.location.type !== 'grid') - Number(b.group.api.location.type !== 'grid') ||
604
+ a.rect.left - b.rect.left || a.rect.top - b.rect.top)
605
+ .flatMap(({ group }) => group.panels.flatMap(panel => {
606
+ const target = views.get(panel.id)?.target;
607
+ return target && (id === undefined ? target.isStage : target.id === id) ?
608
+ [{ id: panel.id, title: panel.title }] : [];
609
+ }));
610
+ }
611
+ function selectFromList(id) {
612
+ const first = targetTabs(id)[0];
613
+ if (first)
614
+ activateView(first.id);
615
+ else {
616
+ const target = originalTargets().find(item => id === undefined ? item.isStage : item.id === id);
617
+ if (target)
618
+ select(target.id);
619
+ }
620
+ }
557
621
  function openDocument(request) {
558
622
  if (pendingRestore)
559
623
  finishRestore();
@@ -642,7 +706,7 @@ export function mountSpriteTabs(root, content, options) {
642
706
  function closeStage() {
643
707
  dockview.getPanel(stagePanelId)?.api.close();
644
708
  }
645
- function split(direction, id = active?.id) {
709
+ function addView(direction, id = active?.id) {
646
710
  const reference = views.get(id);
647
711
  if (!multiView || !reference)
648
712
  return;
@@ -651,6 +715,8 @@ export function mountSpriteTabs(root, content, options) {
651
715
  activateView(panel.id);
652
716
  return panel.id;
653
717
  }
718
+ const split = (direction, id) => addView(direction, id);
719
+ const openInNewTab = (id) => addView('within', id);
654
720
  function closeSplit(id = active?.id) {
655
721
  const panel = dockview.getPanel(id);
656
722
  if (!multiView || !panel || !canCloseGroup(panel.api.group))
@@ -705,7 +771,8 @@ export function mountSpriteTabs(root, content, options) {
705
771
  return;
706
772
  const panels = Object.create(null);
707
773
  for (const [id, view] of views) {
708
- panels[id] = { kind: 'sprite', name: targetName(view.target), stage: view.target.isStage, section: view.section };
774
+ panels[id] = { kind: 'sprite', name: targetName(view.target), stage: view.target.isStage, section: view.section,
775
+ number: view.number };
709
776
  }
710
777
  if (dockview.getPanel(stagePanelId))
711
778
  panels[stagePanelId] = { kind: 'stage' };
@@ -776,8 +843,9 @@ export function mountSpriteTabs(root, content, options) {
776
843
  const target = targets.find(item => item.isStage === reference.stage && targetName(item) === reference.name);
777
844
  if (!target || id === stagePanelId || !sectionAvailable(reference.section))
778
845
  return finishRestore();
779
- resolvedSprites.set(id, { id, target, section: reference.section, assets: createAssetSelections(target, locale) });
780
- panels[id] = { id, title: tabTitle(target), contentComponent: 'sprite', params: { icon: getIcon(target) } };
846
+ resolvedSprites.set(id, { id, target, section: reference.section, number: reference.number,
847
+ assets: createAssetSelections(target, locale) });
848
+ panels[id] = { id, contentComponent: 'sprite', params: { icon: getIcon(target) } };
781
849
  }
782
850
  else if (reference.kind === 'stage') {
783
851
  if (!stagePane || id !== stagePanelId)
@@ -797,6 +865,10 @@ export function mountSpriteTabs(root, content, options) {
797
865
  panels[id] = { id, title: documentPanelTitle(request), contentComponent: documentComponent, renderer: 'always' };
798
866
  }
799
867
  }
868
+ assignTabNumbers(resolvedSprites.values(), new Set([...targets.map(baseTitle),
869
+ ...Object.values(panels).map(panel => panel.title)]));
870
+ for (const [id, view] of resolvedSprites)
871
+ panels[id].title = tabTitle(view);
800
872
  finishRestore();
801
873
  syncing = true;
802
874
  try {
@@ -848,10 +920,11 @@ export function mountSpriteTabs(root, content, options) {
848
920
  dockview.getPanel(id)?.api.close();
849
921
  }
850
922
  const represented = new Set();
923
+ assignTabNumbers(views.values());
851
924
  for (const [id, view] of views) {
852
925
  represented.add(view.target);
853
926
  const panel = dockview.getPanel(id);
854
- const title = tabTitle(view.target);
927
+ const title = tabTitle(view);
855
928
  if (panel && panel.title !== title)
856
929
  panel.api.setTitle(title);
857
930
  const icon = getIcon(view.target);
@@ -929,7 +1002,8 @@ export function mountSpriteTabs(root, content, options) {
929
1002
  vm.on('targetsUpdate', refresh);
930
1003
  refresh();
931
1004
  return {
932
- select, openStage, closeStage, split, closeSplit, activateView, setViewSection, syncActiveSection, refreshSurfaces,
1005
+ select, selectFromList, targetTabs, openStage, closeStage, split, closeSplit, activateView,
1006
+ setViewSection, syncActiveSection, refreshSurfaces,
933
1007
  rename(id) {
934
1008
  const target = vm.runtime.targets.find(item => item.id === id);
935
1009
  if (target)
@@ -1211,8 +1285,15 @@ export function useSpriteTabs({ available, enabled, locale, ...props }) {
1211
1285
  }, [slots, props.activeSection]);
1212
1286
  const japanese = /^ja(?:-|$)/i.test(locale);
1213
1287
  const select = (id) => controller.current?.select(id);
1288
+ const listTabs = enabled && props.multiView ? {
1289
+ locale,
1290
+ list: (id) => controller.current?.targetTabs(id) ?? [],
1291
+ select: (id) => controller.current?.selectFromList(id),
1292
+ activate: (id) => controller.current?.activateView(id)
1293
+ } : null;
1214
1294
  return {
1215
1295
  controller,
1296
+ listTabs,
1216
1297
  assetSelections: (enabled ? selection.assets : undefined) ?? defaultAssets,
1217
1298
  context: enabled ? {
1218
1299
  selectedId: selection.id, openLabel: japanese ? '開く' : 'Open', select, open: select,
@@ -1,10 +1,12 @@
1
+ import type { DrawerViews } from './drawer-views.ts';
2
+ export type { DrawerMenu, DrawerMenuRenderProps, DrawerRenderProps, DrawerView, DrawerViewId, DrawerViews, HostDrawerViewId } from './drawer-views.ts';
1
3
  export declare function createStandardLayout(React: any, { styles, targetStyles, context, LayoutMenu }: {
2
4
  styles: any;
3
5
  targetStyles: any;
4
6
  context: any;
5
7
  LayoutMenu: any;
6
8
  }): {
7
- StandardLayout: ({ enabled, splitter, windowLayout, stageActionEnabled, stageDrawer, onPaletteModeChange, windowTools, Container, render, ...props }: {
9
+ StandardLayout: ({ enabled, splitter, windowLayout, stageActionEnabled, stageDrawer, onPaletteModeChange, windowTools, Container, render, drawerViews, ...props }: {
8
10
  [x: string]: any;
9
11
  enabled: any;
10
12
  splitter: any;
@@ -15,6 +17,7 @@ export declare function createStandardLayout(React: any, { styles, targetStyles,
15
17
  windowTools: any;
16
18
  Container: any;
17
19
  render: any;
20
+ drawerViews?: DrawerViews;
18
21
  }) => any;
19
22
  EdgeDrawer: ({ edge, label, pinned, onOpenChange, portalContent, holdOpenSelector, focusPanelRef, focusBoundary, showTrigger, children }: {
20
23
  edge: any;