@kubohiroya/turbowarp-plus-editor-workbench 0.26.0 → 0.27.1
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/EDITOR-MIGRATION.md +5 -0
- package/README.ja.md +7 -0
- package/dist/basic-panel.d.ts +52 -0
- package/dist/basic-panel.js +153 -0
- package/dist/editor-tabs.d.ts +37 -0
- package/dist/editor-tabs.js +538 -0
- package/dist/popup-layout.d.ts +20 -0
- package/dist/popup-layout.js +59 -0
- package/dist/project-folder-workflows.d.ts +31 -0
- package/dist/project-folder-workflows.js +1 -0
- package/dist/project-payload-forms.d.ts +8 -0
- package/dist/project-payload-forms.js +184 -0
- package/dist/project-tools/diagnostics.d.ts +13 -0
- package/dist/project-tools/diagnostics.js +65 -0
- package/dist/project-tools/dialog.d.ts +21 -0
- package/dist/project-tools/dialog.js +363 -0
- package/dist/project-tools/history.d.ts +8 -0
- package/dist/project-tools/history.js +22 -0
- package/dist/project-tools/integration.d.ts +65 -0
- package/dist/project-tools/integration.js +356 -0
- package/dist/project-tools/links.d.ts +3 -0
- package/dist/project-tools/links.js +36 -0
- package/dist/project-tools/properties.d.ts +51 -0
- package/dist/project-tools/properties.js +268 -0
- package/dist/sprite-tabs.d.ts +7 -1
- package/dist/sprite-tabs.js +11 -1
- package/dist/stage-display-menu.d.ts +21 -0
- package/dist/stage-display-menu.js +156 -0
- package/dist/stage-panel.d.ts +29 -0
- package/dist/stage-panel.js +105 -0
- package/package.json +78 -9
- package/src/basic-panel.tsx +207 -0
- package/src/editor-tabs.tsx +580 -0
- package/src/popup-layout.css +4 -0
- package/src/popup-layout.tsx +81 -0
- package/src/project-dialog.css +39 -0
- package/src/project-folder-workflows.ts +32 -0
- package/src/project-payload-forms.ts +179 -0
- package/src/project-snackbar.css +85 -0
- package/src/project-tools/diagnostics.ts +51 -0
- package/src/project-tools/dialog.ts +341 -0
- package/src/project-tools/history.ts +20 -0
- package/src/project-tools/integration.ts +366 -0
- package/src/project-tools/links.ts +31 -0
- package/src/project-tools/properties.ts +251 -0
- package/src/sprite-tabs.ts +17 -1
- package/src/stage-display-menu.css +28 -0
- package/src/stage-display-menu.tsx +177 -0
- package/src/stage-panel.tsx +127 -0
package/README.ja.md
CHANGED
|
@@ -242,6 +242,8 @@ Editor のルートから、`site/source.json` の GUI を `npm run build:pages`
|
|
|
242
242
|
|
|
243
243
|
スプライトの「呼び出し関係」では、図の方向を切り替える LR/TD と、関数・メッセージの表示を切り替えるボタンを縦ツールバーの下端に置く。方向と表示の選択はビューごとに管理し、分割した別ビューの選択を変えない。ホストが `renderToolbar` でツールバーを描く場合は、受け取る `actions.sectionControls` を `SpriteEditorToolbar` の `sectionControls` に渡す。図で選んだスクリプトは `openRelationScript` で開き、ホストが対象のスプライトとブロックへ移動する。
|
|
244
244
|
|
|
245
|
+
コードペインのアダプターに `relations` がある場合、「自由配置」にも同じ関数・メッセージの2ボタンを縦ツールバー下端に置く。表示状態の所有者はコードペインで、`getVisibility(paneId)`・`setVisibility(paneId, value)`・`subscribe(listener)` を使って描画へ反映する。関数だけ、メッセージだけ、両方、両方非表示を選べ、分割した別のペインや呼び出し関係パネルの設定は変えない。両方とも既定で表示する。アダプターにこの接続がなければボタンを追加しない。切り戻しは workbench と code-views の固定依存を導入前の版へ戻して再ビルドする。
|
|
246
|
+
|
|
245
247
|
## デバッガーのタブ
|
|
246
248
|
|
|
247
249
|
`attachDebuggerPanel(debugger, {document, vm})` は、デバッガーアドオンのウィンドウを Dockview のタブとして開く。ホストはアドオンのウィンドウ要素、アドオン自身の表示切り替え関数、GUI の言語を返す関数を渡す。ワークスペースがパネルを受け付けるときは「デバッガー」タブで開き、タブとデバッガーの開閉を連動させる。受け付けないときは従来どおり浮動ウィンドウのままにする。タブは一時パネルとして扱い、保存するレイアウトには含めない。
|
|
@@ -288,3 +290,8 @@ Web 版の Plus 標準配置で `twPlusDockview=1` を付けて起動すると
|
|
|
288
290
|
`@kubohiroya/turbowarp-plus-editor-sprite-panes` のツールバーが決め、保存済みのレイアウトが持つセクションの番号は変わらない。「呼び出し関係」は次の番号を使う)。`SpriteFunctionPane` が、前者ではホストが `hats` で渡すハットのスクリプトとブロック定義を
|
|
289
291
|
一覧し(並べ方は名前順・Z順・N順)、後者では LR・TD の呼び出し図を表示する。並べ方・流れはビューごとに保つ。どちらで選んだ関数もホストの `openFunction` で、ハットのスクリプトは `openScript` で開く(スプライトの横のタブなど)。`openFunction` が無ければ関数はダイアログで開く。`createFunction(targetId, kind, name)` を渡すと、一覧の下と図の左下の「+ 新しい関数を追加」で、名前を入れて標準のブロック定義か TurboWarp-Plus の名前付き関数を作れる。ダイアログはホストの
|
|
290
292
|
`mountFunctionEditor` を呼び、その定義のコード編集画面はホストが持つ。このパッケージは Scratch Blocks のコードを持たないためである。
|
|
293
|
+
|
|
294
|
+
## Editor の実装との責務分担
|
|
295
|
+
|
|
296
|
+
Editor 独自実装の移管元とライセンス確認は [EDITOR-MIGRATION.md](EDITOR-MIGRATION.md) に記録しています。
|
|
297
|
+
追加した公開 API は GUI モジュールを import せず、ホストから必要な値・データ・コールバックを受け取ります。
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SurfaceHost, SurfaceRecovery } from '@kubohiroya/turbowarp-plus-editor-windows/surfaces';
|
|
3
|
+
import type { SurfaceState } from '@kubohiroya/turbowarp-plus-editor-windows/surfaces';
|
|
4
|
+
export interface PanelMount {
|
|
5
|
+
mount: HTMLElement;
|
|
6
|
+
presentation?: 'internal' | 'external';
|
|
7
|
+
}
|
|
8
|
+
export interface PanelRequest {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
rememberPlacement: boolean;
|
|
12
|
+
presentation: 'internal';
|
|
13
|
+
layer?: 'utility';
|
|
14
|
+
openExternal?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface PanelProps {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
render?: (floating: boolean, mount?: HTMLElement | null) => React.ReactNode;
|
|
21
|
+
actionMount?: HTMLElement | null;
|
|
22
|
+
dockHeight?: number;
|
|
23
|
+
className?: string;
|
|
24
|
+
externalOnly?: boolean;
|
|
25
|
+
externalHost?: SurfaceHost<undefined, PanelMount>;
|
|
26
|
+
decorate?: (document: Document) => () => void;
|
|
27
|
+
renderInExternalDocument?: boolean;
|
|
28
|
+
onDockActionChange?: (actions: {
|
|
29
|
+
kind: SurfaceState<PanelMount>['kind'];
|
|
30
|
+
dock(): void;
|
|
31
|
+
undock(): void;
|
|
32
|
+
external: boolean;
|
|
33
|
+
mount?: HTMLElement;
|
|
34
|
+
} | null) => void;
|
|
35
|
+
alwaysShowUndock?: boolean;
|
|
36
|
+
openLabel?: string;
|
|
37
|
+
dockRequest?: number;
|
|
38
|
+
renderDockHeading?: (action: React.ReactNode) => React.ReactNode;
|
|
39
|
+
layer?: 'utility';
|
|
40
|
+
}
|
|
41
|
+
export declare function createBasicPanel({ WindowLayoutContext, PopupLayout, surfaceRecovery, styles }: {
|
|
42
|
+
WindowLayoutContext: React.Context<any>;
|
|
43
|
+
PopupLayout: React.ComponentType<{
|
|
44
|
+
window: Window;
|
|
45
|
+
locale: string;
|
|
46
|
+
onDock(): void;
|
|
47
|
+
}>;
|
|
48
|
+
surfaceRecovery: SurfaceRecovery;
|
|
49
|
+
styles: Record<string, string>;
|
|
50
|
+
}): {
|
|
51
|
+
BasicPanel: ({ children, ...options }: PanelProps) => React.JSX.Element;
|
|
52
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createPortal, flushSync } from 'react-dom';
|
|
4
|
+
import { createSurface, pendingSurfaceEdits, recordSurface } from '@kubohiroya/turbowarp-plus-editor-windows/surfaces';
|
|
5
|
+
import { DockablePanel, OpenWindowButton, useWindowHost } from '@kubohiroya/turbowarp-plus-editor-windows';
|
|
6
|
+
export function createBasicPanel({ WindowLayoutContext, PopupLayout, surfaceRecovery, styles }) {
|
|
7
|
+
// React 16 needs an explicit subscription to the external layout state.
|
|
8
|
+
function useLostWindow(recovery, id) {
|
|
9
|
+
const [lost, setLost] = React.useState(() => Boolean(recovery?.isLost(id)));
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (!recovery)
|
|
12
|
+
return;
|
|
13
|
+
const update = () => setLost(recovery.isLost(id));
|
|
14
|
+
update();
|
|
15
|
+
return recovery.subscribe(update);
|
|
16
|
+
}, [recovery, id]);
|
|
17
|
+
return Boolean(recovery) && lost;
|
|
18
|
+
}
|
|
19
|
+
// Inputs commit on blur, so blurring the external document collects an unfinished edit.
|
|
20
|
+
const commitInput = (mount) => {
|
|
21
|
+
const active = mount?.ownerDocument.activeElement;
|
|
22
|
+
if (active && active !== mount.ownerDocument.body)
|
|
23
|
+
active.blur?.();
|
|
24
|
+
};
|
|
25
|
+
function DockableBasicPanel({ host, id, title, children, render, actionMount, dockHeight, className, externalHost, externalOnly, decorate, renderInExternalDocument, onDockActionChange, alwaysShowUndock, openLabel, renderDockHeading, layer, dockRequest }) {
|
|
26
|
+
const { showUndock, locale, plusLayout } = React.useContext(WindowLayoutContext);
|
|
27
|
+
const canUndock = alwaysShowUndock || showUndock;
|
|
28
|
+
const [state, setState] = React.useState({ kind: 'docked' });
|
|
29
|
+
const action = React.useRef(null);
|
|
30
|
+
const undecorate = React.useRef(null);
|
|
31
|
+
const unmounting = React.useRef(false);
|
|
32
|
+
const fallback = React.useRef(null);
|
|
33
|
+
const surface = React.useMemo(() => createSurface({
|
|
34
|
+
open: request => request?.presentation === 'internal' ? host.open(request) : externalHost?.open(undefined)
|
|
35
|
+
}, next => {
|
|
36
|
+
if (externalHost)
|
|
37
|
+
recordSurface(surfaceRecovery, id, next, target => target.presentation !== 'internal');
|
|
38
|
+
if (next.kind === 'external' && next.target.presentation !== 'internal') {
|
|
39
|
+
undecorate.current = decorate(next.target.mount.ownerDocument);
|
|
40
|
+
}
|
|
41
|
+
if (next.kind === 'docked' && fallback.current) {
|
|
42
|
+
const retry = fallback.current;
|
|
43
|
+
fallback.current = null;
|
|
44
|
+
if (next.reason === 'blocked' || next.reason === 'failed') {
|
|
45
|
+
surface.undock(retry);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (next.kind === 'docked' && undecorate.current) {
|
|
50
|
+
if (!unmounting.current)
|
|
51
|
+
flushSync(() => setState(next));
|
|
52
|
+
undecorate.current();
|
|
53
|
+
undecorate.current = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!unmounting.current)
|
|
57
|
+
setState(next);
|
|
58
|
+
}), [host, externalHost, decorate, id]);
|
|
59
|
+
const lost = useLostWindow(externalHost ? surfaceRecovery : null, id);
|
|
60
|
+
React.useLayoutEffect(() => {
|
|
61
|
+
unmounting.current = false;
|
|
62
|
+
return () => {
|
|
63
|
+
unmounting.current = true;
|
|
64
|
+
fallback.current = null;
|
|
65
|
+
surface.dock();
|
|
66
|
+
};
|
|
67
|
+
}, [surface]);
|
|
68
|
+
React.useLayoutEffect(() => {
|
|
69
|
+
if (!canUndock || state.kind !== 'docked' || state.reason !== 'returned' && state.reason !== 'disconnected')
|
|
70
|
+
return;
|
|
71
|
+
const frame = requestAnimationFrame(() => action.current?.querySelector('button')?.focus({ preventScroll: true }));
|
|
72
|
+
return () => cancelAnimationFrame(frame);
|
|
73
|
+
}, [canUndock, state]);
|
|
74
|
+
const undock = React.useCallback(() => {
|
|
75
|
+
// A window that was external when the editor closed reopens there, one panel per click.
|
|
76
|
+
if (externalOnly || (externalHost && (!plusLayout || lost))) {
|
|
77
|
+
surface.undock(undefined);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const request = { id, title, rememberPlacement: true, presentation: 'internal', layer };
|
|
81
|
+
if (externalHost)
|
|
82
|
+
request.openExternal = () => {
|
|
83
|
+
surface.dock();
|
|
84
|
+
fallback.current = request;
|
|
85
|
+
surface.undock(undefined);
|
|
86
|
+
};
|
|
87
|
+
surface.undock(request);
|
|
88
|
+
}, [surface, id, title, externalHost, externalOnly, plusLayout, layer, lost]);
|
|
89
|
+
const japanese = /^ja(?:-|$)/i.test(locale);
|
|
90
|
+
const mount = state.kind === 'external' ? state.target.mount : undefined;
|
|
91
|
+
const externalMount = state.kind === 'external' && state.target.presentation !== 'internal' ? state.target.mount : null;
|
|
92
|
+
const returnHere = React.useCallback(() => {
|
|
93
|
+
commitInput(externalMount);
|
|
94
|
+
surface.dock();
|
|
95
|
+
}, [surface, externalMount]);
|
|
96
|
+
const lastDockRequest = React.useRef(dockRequest);
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
if (dockRequest === lastDockRequest.current)
|
|
99
|
+
return;
|
|
100
|
+
lastDockRequest.current = dockRequest;
|
|
101
|
+
if (!dockRequest || state.kind === 'docked')
|
|
102
|
+
return;
|
|
103
|
+
// Returning an external panel flushes React before its document is closed.
|
|
104
|
+
queueMicrotask(() => {
|
|
105
|
+
if (!unmounting.current)
|
|
106
|
+
returnHere();
|
|
107
|
+
});
|
|
108
|
+
}, [dockRequest, state.kind, returnHere]);
|
|
109
|
+
React.useEffect(() => externalMount ? pendingSurfaceEdits.register(() => commitInput(externalMount)) : undefined, [externalMount]);
|
|
110
|
+
React.useLayoutEffect(() => {
|
|
111
|
+
if (!onDockActionChange)
|
|
112
|
+
return;
|
|
113
|
+
onDockActionChange({ kind: state.kind, dock: returnHere, undock,
|
|
114
|
+
external: Boolean(externalHost && (externalOnly || !plusLayout || lost)), mount: externalMount ?? undefined });
|
|
115
|
+
return () => onDockActionChange(null);
|
|
116
|
+
}, [onDockActionChange, state.kind, returnHere, undock, externalHost, externalOnly, plusLayout, externalMount, lost]);
|
|
117
|
+
React.useLayoutEffect(() => {
|
|
118
|
+
if (externalMount)
|
|
119
|
+
externalMount.ownerDocument.title = title;
|
|
120
|
+
}, [externalMount, title]);
|
|
121
|
+
const content = render ? render(Boolean(mount), externalMount) : children;
|
|
122
|
+
// Create target controls in the child document so React delegates input there.
|
|
123
|
+
const nativeContent = externalMount && renderInExternalDocument ?
|
|
124
|
+
createPortal(React.createElement("div", { className: styles.externalPanel },
|
|
125
|
+
plusLayout && React.createElement("div", { className: styles.popupTools },
|
|
126
|
+
React.createElement(PopupLayout, { window: externalMount.ownerDocument.defaultView, locale: locale, onDock: returnHere })),
|
|
127
|
+
content), externalMount) : null;
|
|
128
|
+
const openAction = canUndock && !mount && React.createElement("span", { className: styles.openWindowAction, ref: action },
|
|
129
|
+
React.createElement(OpenWindowButton, { disabled: state.kind === 'opening', label: lost ? (japanese ? '別画面で開き直す' : 'Reopen in another window') :
|
|
130
|
+
openLabel ?? (japanese ? '別画面で開く' : 'Open in another window'), onOpen: undock }));
|
|
131
|
+
const focusable = Boolean(openAction && actionMount === undefined);
|
|
132
|
+
return React.createElement("div", { className: className ? `${styles.basicPanel} ${className}` : styles.basicPanel, style: mount ? { minBlockSize: dockHeight } : undefined, tabIndex: focusable ? -1 : undefined, onClick: focusable ? event => {
|
|
133
|
+
const node = event.currentTarget;
|
|
134
|
+
const target = event.target;
|
|
135
|
+
if (node.contains(target) && !target.closest('button, input, a, select, textarea, [tabindex]') &&
|
|
136
|
+
!node.contains(node.ownerDocument.activeElement))
|
|
137
|
+
node.focus({ preventScroll: true });
|
|
138
|
+
} : undefined },
|
|
139
|
+
actionMount === undefined ? (renderDockHeading ? !mount && renderDockHeading(openAction) : React.createElement("div", { className: styles.basicPanelHeading },
|
|
140
|
+
React.createElement("h2", null, title),
|
|
141
|
+
openAction)) : (actionMount && openAction && createPortal(openAction, actionMount)),
|
|
142
|
+
React.createElement(DockablePanel, { dockLabel: japanese ? 'ここに戻す' : 'Return here', mount: mount, onDock: returnHere }, nativeContent ? null : content),
|
|
143
|
+
nativeContent);
|
|
144
|
+
}
|
|
145
|
+
function BasicPanel({ children, ...options }) {
|
|
146
|
+
const host = useWindowHost();
|
|
147
|
+
return host ? React.createElement(DockableBasicPanel, { ...options, host: host }, children) :
|
|
148
|
+
React.createElement(React.Fragment, null,
|
|
149
|
+
options.renderDockHeading?.(null),
|
|
150
|
+
options.render ? options.render(false) : children);
|
|
151
|
+
}
|
|
152
|
+
return { BasicPanel };
|
|
153
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface EditorTabPorts {
|
|
3
|
+
WindowLayoutContext: React.Context<any>;
|
|
4
|
+
StageDisplayMenuContext: React.Context<any>;
|
|
5
|
+
TargetSwitchContext: React.Context<any>;
|
|
6
|
+
desktopCodeEnabled: any;
|
|
7
|
+
openDesktopCode: any;
|
|
8
|
+
styles: any;
|
|
9
|
+
desktopProjectKey: any;
|
|
10
|
+
desktopWorkspaceLayoutStore: any;
|
|
11
|
+
dockviewMultiViewEnabled: any;
|
|
12
|
+
dockviewSpriteTabsEnabled: any;
|
|
13
|
+
layoutFlags: any;
|
|
14
|
+
isProjectLoading: any;
|
|
15
|
+
loadedProjectTitle: any;
|
|
16
|
+
projectScreenState: any;
|
|
17
|
+
subscribeProjectLoad: any;
|
|
18
|
+
projectFolderDirectory: any;
|
|
19
|
+
openDetachedBlockPalette: any;
|
|
20
|
+
categoryArtwork: any;
|
|
21
|
+
decorateSurface: any;
|
|
22
|
+
plusCatalog: any;
|
|
23
|
+
loadPlusExtensions: any;
|
|
24
|
+
beginPlusReview: any;
|
|
25
|
+
canLoadPlusExtension: any;
|
|
26
|
+
attachBackpackDrop: any;
|
|
27
|
+
attachCodePreviewMinimap: any;
|
|
28
|
+
attachCodeNavigation: any;
|
|
29
|
+
getScratchBlocks: any;
|
|
30
|
+
assetTransferPort: any;
|
|
31
|
+
readOpenedFile: any;
|
|
32
|
+
popupURL: any;
|
|
33
|
+
connectEditorTabs: any;
|
|
34
|
+
}
|
|
35
|
+
export declare function createEditorTabLayout({ desktopCodeEnabled, openDesktopCode, styles, desktopProjectKey, desktopWorkspaceLayoutStore, dockviewMultiViewEnabled, dockviewSpriteTabsEnabled, layoutFlags, WindowLayoutContext, isProjectLoading, loadedProjectTitle, projectScreenState, subscribeProjectLoad, projectFolderDirectory, StageDisplayMenuContext, TargetSwitchContext, openDetachedBlockPalette, categoryArtwork, decorateSurface, plusCatalog, loadPlusExtensions, beginPlusReview, canLoadPlusExtension, attachBackpackDrop, attachCodePreviewMinimap, attachCodeNavigation, getScratchBlocks, assetTransferPort, readOpenedFile, popupURL, connectEditorTabs }: EditorTabPorts): {
|
|
36
|
+
EditorTabLayout: any;
|
|
37
|
+
};
|