@kubohiroya/turbowarp-plus-editor-workbench 0.25.0 → 0.26.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 +2 -0
- package/dist/sprite-tabs.d.ts +5 -1
- package/dist/sprite-tabs.js +32 -5
- package/package.json +2 -2
- package/src/sprite-layout-menu.css +1 -1
- package/src/sprite-tabs.ts +39 -6
package/README.ja.md
CHANGED
|
@@ -240,6 +240,8 @@ Editor のルートから、`site/source.json` の GUI を `npm run build:pages`
|
|
|
240
240
|
|
|
241
241
|
スプライト編集タブの中のペイン(素材と変数、メッセージ、設定フォーム、セクション切り替えのツールバー)は `@kubohiroya/turbowarp-plus-editor-sprite-panes` に移った。このパッケージはそれらをタブや分割に並べる。以前の配布アーカイブのソース `b0390c3` から移設したウィンドウ部品は、`@kubohiroya/turbowarp-plus-editor-windows` に移った。Scratch GUI の本家実装はこのパッケージに取り込んでいないため、GPL のコードを含まず、GPL のモジュールも import しない。ライセンスは MPL-2.0 とする。MPL-2.0 は GPL を二次ライセンスとして認めるので、GPL-3.0 の Editor に組み込んで配信できる。ソースに「Incompatible With Secondary Licenses」の表示は付けない。付けると Editor に組み込めなくなる。
|
|
242
242
|
|
|
243
|
+
スプライトの「呼び出し関係」では、図の方向を切り替える LR/TD と、関数・メッセージの表示を切り替えるボタンを縦ツールバーの下端に置く。方向と表示の選択はビューごとに管理し、分割した別ビューの選択を変えない。ホストが `renderToolbar` でツールバーを描く場合は、受け取る `actions.sectionControls` を `SpriteEditorToolbar` の `sectionControls` に渡す。図で選んだスクリプトは `openRelationScript` で開き、ホストが対象のスプライトとブロックへ移動する。
|
|
244
|
+
|
|
243
245
|
## デバッガーのタブ
|
|
244
246
|
|
|
245
247
|
`attachDebuggerPanel(debugger, {document, vm})` は、デバッガーアドオンのウィンドウを Dockview のタブとして開く。ホストはアドオンのウィンドウ要素、アドオン自身の表示切り替え関数、GUI の言語を返す関数を渡す。ワークスペースがパネルを受け付けるときは「デバッガー」タブで開き、タブとデバッガーの開閉を連動させる。受け付けないときは従来どおり浮動ウィンドウのままにする。タブは一時パネルとして扱い、保存するレイアウトには含めない。
|
package/dist/sprite-tabs.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { WorkspaceLayoutStore, WorkspaceProjectIdentity } from './workspace
|
|
|
8
8
|
import type { ProjectScreenState } from './project-screen-state.ts';
|
|
9
9
|
import type { SpriteVariableEdit, SpriteVariableEditError } from '@kubohiroya/turbowarp-plus-editor-project-model/sprite-variable-edit';
|
|
10
10
|
import type { MessageRenameError } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-message-pane';
|
|
11
|
-
import type { FunctionKind, FunctionPaneData, MountFunctionEditor, OpenScriptOptions, SpriteFunction, SpriteHatScript } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
11
|
+
import type { FunctionKind, FunctionPaneData, MountFunctionEditor, OpenScriptOptions, ScriptEndpoint, SpriteFunction, SpriteHatScript } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
12
12
|
import type { MessageUse, ProjectMessage, TargetMessages } from '@kubohiroya/turbowarp-plus-editor-project-model/project-messages';
|
|
13
13
|
export { getDocumentWorkspace } from './document-workspace.ts';
|
|
14
14
|
export { createWorkspaceLayoutStore, workspaceLayoutDatabase, workspaceLayoutLimit } from './workspace-layout-store.ts';
|
|
@@ -123,6 +123,8 @@ interface TabOptions<Snapshot = unknown> {
|
|
|
123
123
|
interface ToolbarActions {
|
|
124
124
|
activate(): void;
|
|
125
125
|
setSection(section: number): void;
|
|
126
|
+
/** Controls for the displayed section, separate from the rail's section tabs. */
|
|
127
|
+
sectionControls?: React.ReactNode;
|
|
126
128
|
}
|
|
127
129
|
interface ToolbarSlot {
|
|
128
130
|
view: SpriteTabView;
|
|
@@ -220,6 +222,8 @@ type SpriteTabsProps<Snapshot> = Omit<TabOptions<Snapshot>, 'activateSection' |
|
|
|
220
222
|
* `options.block` asks to show one block, such as a call picked in the list of a function's uses.
|
|
221
223
|
*/
|
|
222
224
|
openScript?(targetId: string, hat: SpriteHatScript, options?: OpenScriptOptions): void;
|
|
225
|
+
/** Open a script chosen in the relationship graph, including one on another target. */
|
|
226
|
+
openRelationScript?(endpoint: ScriptEndpoint): void;
|
|
223
227
|
/** The function or hat script shown beside the sprite, which the list of hats and functions highlights. */
|
|
224
228
|
selectedScript?: {
|
|
225
229
|
targetId: string;
|
package/dist/sprite-tabs.js
CHANGED
|
@@ -10,7 +10,7 @@ import { projectFolderIconPath } from "./drawer-views.js";
|
|
|
10
10
|
import { dockPopoutGroups, positionOnScreen, readWorkspaceLayout, workspaceWithoutTransientPanels } from "./workspace-layout.js";
|
|
11
11
|
import { createWorkspaceLayoutStore } from "./workspace-layout-store.js";
|
|
12
12
|
import { SpriteMessagePane } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-message-pane';
|
|
13
|
-
import { functionLabel, SpriteFunctionPane } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
13
|
+
import { FunctionFlowToggle, FunctionRelationToggles, functionLabel, SpriteFunctionPane } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
14
14
|
import { createTargetTabMenuItem, spriteRenameLabel } from "./target-tab-menu.js";
|
|
15
15
|
export { getDocumentWorkspace } from "./document-workspace.js";
|
|
16
16
|
export { createWorkspaceLayoutStore, workspaceLayoutDatabase, workspaceLayoutLimit } from "./workspace-layout-store.js";
|
|
@@ -1498,7 +1498,14 @@ function SpriteTabs(props) {
|
|
|
1498
1498
|
const [toolbarSlots, setToolbarSlots] = React.useState([]);
|
|
1499
1499
|
const [assetPreviewSlots, setAssetPreviewSlots] = React.useState([]);
|
|
1500
1500
|
// The functions pane remounts when its view switches sections; keep the view, order and flow each view chose.
|
|
1501
|
-
const [functionSettings] = React.useState(() => new Map());
|
|
1501
|
+
const [functionSettings, setFunctionSettings] = React.useState(() => new Map());
|
|
1502
|
+
const changeFunctionSettings = (id, patch) => setFunctionSettings(previous => {
|
|
1503
|
+
const current = previous.get(id) ?? {};
|
|
1504
|
+
const next = { ...current, ...patch };
|
|
1505
|
+
if (Object.keys(next).every(key => current[key] === next[key]))
|
|
1506
|
+
return previous;
|
|
1507
|
+
return new Map(previous).set(id, next);
|
|
1508
|
+
});
|
|
1502
1509
|
const controller = React.useRef(null);
|
|
1503
1510
|
const hasVariables = Boolean(props.getVariables);
|
|
1504
1511
|
const hasMessages = Boolean(props.getMessages);
|
|
@@ -1584,14 +1591,30 @@ function SpriteTabs(props) {
|
|
|
1584
1591
|
};
|
|
1585
1592
|
return React.createElement('div', { className: props.className,
|
|
1586
1593
|
'data-multi-view': props.enabled && props.multiView || undefined }, React.createElement('div', { ref: root, onClick: isolateDockviewTabs, onKeyDown: isolateDockviewTabs }), React.createElement('div', { ref: parking, hidden: true }), createPortal(React.createElement(React.Fragment, null, props.multiView && props.getVariables ? React.createElement('div', { hidden: true }, props.children) : props.children, React.createElement('div', { ref: sections, className: 'tw-plus-sprite-tab-sections' })), content), toolbarSlots.map(({ view, element }) => {
|
|
1594
|
+
const currentSection = spriteEditorSections[view.section] ?? 'code';
|
|
1595
|
+
const sectionControls = currentSection === 'calls' && props.getFunctions ? React.createElement(React.Fragment, null, React.createElement(FunctionFlowToggle, {
|
|
1596
|
+
locale: props.locale,
|
|
1597
|
+
value: functionSettings.get(view.id)?.direction ?? 'LR',
|
|
1598
|
+
onChange: (direction) => {
|
|
1599
|
+
workspace?.activateView(view.id);
|
|
1600
|
+
changeFunctionSettings(view.id, { direction });
|
|
1601
|
+
}
|
|
1602
|
+
}), React.createElement(FunctionRelationToggles, {
|
|
1603
|
+
locale: props.locale,
|
|
1604
|
+
value: functionSettings.get(view.id)?.relationVisibility ?? { function: true, message: true },
|
|
1605
|
+
onChange: (relationVisibility) => {
|
|
1606
|
+
workspace?.activateView(view.id);
|
|
1607
|
+
changeFunctionSettings(view.id, { relationVisibility });
|
|
1608
|
+
}
|
|
1609
|
+
})) : undefined;
|
|
1587
1610
|
const actions = {
|
|
1588
1611
|
activate: () => { workspace?.activateView(view.id); },
|
|
1589
1612
|
setSection: (section) => {
|
|
1590
1613
|
workspace?.setViewSection(view.id, section);
|
|
1591
1614
|
workspace?.activateView(view.id);
|
|
1592
|
-
}
|
|
1615
|
+
},
|
|
1616
|
+
sectionControls
|
|
1593
1617
|
};
|
|
1594
|
-
const currentSection = spriteEditorSections[view.section] ?? 'code';
|
|
1595
1618
|
const toolbar = props.renderToolbar?.(view, actions) ?? (props.getVariables &&
|
|
1596
1619
|
React.createElement(SpriteEditorToolbar, {
|
|
1597
1620
|
viewId: view.id, locale: props.locale, section: currentSection, isStage: view.isStage,
|
|
@@ -1600,6 +1623,7 @@ function SpriteTabs(props) {
|
|
|
1600
1623
|
availableSections: spriteEditorSections.filter(section => (section !== 'messages' || Boolean(props.getMessages)) &&
|
|
1601
1624
|
(section !== 'functions' && section !== 'calls' || Boolean(props.getFunctions))),
|
|
1602
1625
|
actions: view.active && currentSection !== 'variables' ? props.activeTools : undefined,
|
|
1626
|
+
sectionControls,
|
|
1603
1627
|
onSectionChange: section => actions.setSection(spriteEditorSections.indexOf(section)),
|
|
1604
1628
|
search: {
|
|
1605
1629
|
onFocus: actions.activate,
|
|
@@ -1665,12 +1689,15 @@ function SpriteTabs(props) {
|
|
|
1665
1689
|
kind: 'functions', view: kind === 'calls' ? 'graph' : 'list',
|
|
1666
1690
|
locale: props.locale, editable, data: props.getFunctions(targetId),
|
|
1667
1691
|
defaultSettings: functionSettings.get(id),
|
|
1668
|
-
|
|
1692
|
+
direction: functionSettings.get(id)?.direction ?? 'LR',
|
|
1693
|
+
relationVisibility: functionSettings.get(id)?.relationVisibility,
|
|
1694
|
+
onSettingsChange: (settings) => changeFunctionSettings(id, settings),
|
|
1669
1695
|
mountEditor: props.mountFunctionEditor,
|
|
1670
1696
|
onOpenFunction: props.openFunction &&
|
|
1671
1697
|
((fn, options) => props.openFunction(targetId, fn, options)),
|
|
1672
1698
|
onOpenScript: props.openScript &&
|
|
1673
1699
|
((hat, options) => props.openScript(targetId, hat, options)),
|
|
1700
|
+
onOpenRelationScript: props.openRelationScript,
|
|
1674
1701
|
selectedId: props.selectedScript?.targetId === targetId ? props.selectedScript.id : undefined,
|
|
1675
1702
|
onCreate: props.createFunction && (async (functionKind, name) => {
|
|
1676
1703
|
const created = await props.createFunction(targetId, functionKind, name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-plus-editor-workbench",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "The TurboWarp Plus Editor workbench: layout, dockable sprite tabs, stage, debugger tab and file menu",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
},
|
|
159
159
|
"dependencies": {
|
|
160
160
|
"@kubohiroya/turbowarp-plus-editor-project-model": "0.2.0",
|
|
161
|
-
"@kubohiroya/turbowarp-plus-editor-sprite-panes": "0.
|
|
161
|
+
"@kubohiroya/turbowarp-plus-editor-sprite-panes": "0.10.0",
|
|
162
162
|
"@kubohiroya/turbowarp-script-transfer": "0.1.5",
|
|
163
163
|
"dockview": "8.8.3"
|
|
164
164
|
},
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/* The layout menu can hide the section buttons at the left of every sprite tab. */
|
|
139
|
-
.tw-plus-sprite-tab-toolbar[data-sections-hidden] .tw-plus-sprite-toolbar-sections {
|
|
139
|
+
.tw-plus-sprite-tab-toolbar[data-sections-hidden] :is(.tw-plus-sprite-toolbar-rail, .tw-plus-sprite-toolbar-sections) {
|
|
140
140
|
display: none;
|
|
141
141
|
}
|
|
142
142
|
|
package/src/sprite-tabs.ts
CHANGED
|
@@ -23,8 +23,9 @@ import type {ProjectScreenState, SavedScreenState} from './project-screen-state.
|
|
|
23
23
|
import type {SpriteVariableEdit, SpriteVariableEditError} from '@kubohiroya/turbowarp-plus-editor-project-model/sprite-variable-edit';
|
|
24
24
|
import {SpriteMessagePane} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-message-pane';
|
|
25
25
|
import type {MessageRenameError} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-message-pane';
|
|
26
|
-
import {functionLabel, SpriteFunctionPane} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
27
|
-
import type {FunctionKind, FunctionPaneData, FunctionPaneSettings,
|
|
26
|
+
import {FunctionFlowToggle, FunctionRelationToggles, functionLabel, SpriteFunctionPane} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
27
|
+
import type {CallGraphDirection, FunctionKind, FunctionPaneData, FunctionPaneSettings, FunctionRelationVisibility,
|
|
28
|
+
MountFunctionEditor, OpenScriptOptions, ScriptEndpoint, SpriteFunction, SpriteHatScript} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-function-pane';
|
|
28
29
|
import type {MessageUse, ProjectMessage, TargetMessages} from '@kubohiroya/turbowarp-plus-editor-project-model/project-messages';
|
|
29
30
|
import {createTargetTabMenuItem, spriteRenameLabel} from './target-tab-menu.ts';
|
|
30
31
|
|
|
@@ -194,6 +195,8 @@ interface TabOptions<Snapshot = unknown> {
|
|
|
194
195
|
interface ToolbarActions {
|
|
195
196
|
activate(): void;
|
|
196
197
|
setSection(section: number): void;
|
|
198
|
+
/** Controls for the displayed section, separate from the rail's section tabs. */
|
|
199
|
+
sectionControls?: React.ReactNode;
|
|
197
200
|
}
|
|
198
201
|
|
|
199
202
|
interface ToolbarSlot {
|
|
@@ -1566,6 +1569,8 @@ type SpriteTabsProps<Snapshot> = Omit<TabOptions<Snapshot>, 'activateSection' |
|
|
|
1566
1569
|
* `options.block` asks to show one block, such as a call picked in the list of a function's uses.
|
|
1567
1570
|
*/
|
|
1568
1571
|
openScript?(targetId: string, hat: SpriteHatScript, options?: OpenScriptOptions): void;
|
|
1572
|
+
/** Open a script chosen in the relationship graph, including one on another target. */
|
|
1573
|
+
openRelationScript?(endpoint: ScriptEndpoint): void;
|
|
1569
1574
|
/** The function or hat script shown beside the sprite, which the list of hats and functions highlights. */
|
|
1570
1575
|
selectedScript?: {targetId: string; id: string};
|
|
1571
1576
|
/**
|
|
@@ -1630,7 +1635,13 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1630
1635
|
const [toolbarSlots, setToolbarSlots] = React.useState<readonly ToolbarSlot[]>([]);
|
|
1631
1636
|
const [assetPreviewSlots, setAssetPreviewSlots] = React.useState<readonly AssetPreviewSlot[]>([]);
|
|
1632
1637
|
// The functions pane remounts when its view switches sections; keep the view, order and flow each view chose.
|
|
1633
|
-
const [functionSettings] = React.useState(() => new Map<string, FunctionPaneSettings
|
|
1638
|
+
const [functionSettings, setFunctionSettings] = React.useState(() => new Map<string, Partial<FunctionPaneSettings>>());
|
|
1639
|
+
const changeFunctionSettings = (id: string, patch: Partial<FunctionPaneSettings>) => setFunctionSettings(previous => {
|
|
1640
|
+
const current = previous.get(id) ?? {};
|
|
1641
|
+
const next = {...current, ...patch};
|
|
1642
|
+
if (Object.keys(next).every(key => current[key] === next[key])) return previous;
|
|
1643
|
+
return new Map(previous).set(id, next);
|
|
1644
|
+
});
|
|
1634
1645
|
const controller = React.useRef<SpriteTabsController<Snapshot>>(null);
|
|
1635
1646
|
const hasVariables = Boolean(props.getVariables);
|
|
1636
1647
|
const hasMessages = Boolean(props.getMessages);
|
|
@@ -1719,14 +1730,32 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1719
1730
|
createPortal(React.createElement(React.Fragment, null,
|
|
1720
1731
|
props.multiView && props.getVariables ? React.createElement('div', {hidden: true}, props.children) : props.children,
|
|
1721
1732
|
React.createElement('div', {ref: sections, className: 'tw-plus-sprite-tab-sections'})), content), toolbarSlots.map(({view, element}) => {
|
|
1733
|
+
const currentSection = spriteEditorSections[view.section] ?? 'code';
|
|
1734
|
+
const sectionControls = currentSection === 'calls' && props.getFunctions ? React.createElement(React.Fragment, null,
|
|
1735
|
+
React.createElement(FunctionFlowToggle, {
|
|
1736
|
+
locale: props.locale,
|
|
1737
|
+
value: functionSettings.get(view.id)?.direction ?? 'LR',
|
|
1738
|
+
onChange: (direction: CallGraphDirection) => {
|
|
1739
|
+
workspace?.activateView(view.id);
|
|
1740
|
+
changeFunctionSettings(view.id, {direction});
|
|
1741
|
+
}
|
|
1742
|
+
}),
|
|
1743
|
+
React.createElement(FunctionRelationToggles, {
|
|
1744
|
+
locale: props.locale,
|
|
1745
|
+
value: functionSettings.get(view.id)?.relationVisibility ?? {function: true, message: true},
|
|
1746
|
+
onChange: (relationVisibility: FunctionRelationVisibility) => {
|
|
1747
|
+
workspace?.activateView(view.id);
|
|
1748
|
+
changeFunctionSettings(view.id, {relationVisibility});
|
|
1749
|
+
}
|
|
1750
|
+
})) : undefined;
|
|
1722
1751
|
const actions = {
|
|
1723
1752
|
activate: () => { workspace?.activateView(view.id); },
|
|
1724
1753
|
setSection: (section: number) => {
|
|
1725
1754
|
workspace?.setViewSection(view.id, section);
|
|
1726
1755
|
workspace?.activateView(view.id);
|
|
1727
|
-
}
|
|
1756
|
+
},
|
|
1757
|
+
sectionControls
|
|
1728
1758
|
};
|
|
1729
|
-
const currentSection = spriteEditorSections[view.section] ?? 'code';
|
|
1730
1759
|
const toolbar = props.renderToolbar?.(view, actions) ?? (props.getVariables &&
|
|
1731
1760
|
React.createElement(SpriteEditorToolbar, {
|
|
1732
1761
|
viewId: view.id, locale: props.locale, section: currentSection, isStage: view.isStage,
|
|
@@ -1736,6 +1765,7 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1736
1765
|
(section !== 'messages' || Boolean(props.getMessages)) &&
|
|
1737
1766
|
(section !== 'functions' && section !== 'calls' || Boolean(props.getFunctions))),
|
|
1738
1767
|
actions: view.active && currentSection !== 'variables' ? props.activeTools : undefined,
|
|
1768
|
+
sectionControls,
|
|
1739
1769
|
onSectionChange: section => actions.setSection(spriteEditorSections.indexOf(section)),
|
|
1740
1770
|
search: {
|
|
1741
1771
|
onFocus: actions.activate,
|
|
@@ -1793,12 +1823,15 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1793
1823
|
kind: 'functions', view: kind === 'calls' ? 'graph' : 'list',
|
|
1794
1824
|
locale: props.locale, editable, data: props.getFunctions!(targetId),
|
|
1795
1825
|
defaultSettings: functionSettings.get(id),
|
|
1796
|
-
|
|
1826
|
+
direction: functionSettings.get(id)?.direction ?? 'LR',
|
|
1827
|
+
relationVisibility: functionSettings.get(id)?.relationVisibility,
|
|
1828
|
+
onSettingsChange: (settings: FunctionPaneSettings) => changeFunctionSettings(id, settings),
|
|
1797
1829
|
mountEditor: props.mountFunctionEditor,
|
|
1798
1830
|
onOpenFunction: props.openFunction &&
|
|
1799
1831
|
((fn: SpriteFunction, options?: OpenScriptOptions) => props.openFunction!(targetId, fn, options)),
|
|
1800
1832
|
onOpenScript: props.openScript &&
|
|
1801
1833
|
((hat: SpriteHatScript, options?: OpenScriptOptions) => props.openScript!(targetId, hat, options)),
|
|
1834
|
+
onOpenRelationScript: props.openRelationScript,
|
|
1802
1835
|
selectedId: props.selectedScript?.targetId === targetId ? props.selectedScript.id : undefined,
|
|
1803
1836
|
onCreate: props.createFunction && (async (functionKind: FunctionKind, name: string) => {
|
|
1804
1837
|
const created = await props.createFunction!(targetId, functionKind, name);
|