@kubohiroya/turbowarp-plus-editor-workbench 0.14.0 → 0.16.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.
Files changed (53) hide show
  1. package/NOTICE +26 -0
  2. package/README.ja.md +22 -0
  3. package/README.md +22 -0
  4. package/dist/backpack-script.d.ts +2 -0
  5. package/dist/backpack-script.js +23 -0
  6. package/dist/backpack.d.ts +60 -0
  7. package/dist/backpack.js +226 -0
  8. package/dist/browser-tab-title.d.ts +2 -0
  9. package/dist/browser-tab-title.js +5 -0
  10. package/dist/busy-cursor.d.ts +22 -0
  11. package/dist/busy-cursor.js +107 -0
  12. package/dist/edit-menu.d.ts +57 -0
  13. package/dist/edit-menu.js +99 -0
  14. package/dist/info-menu.d.ts +39 -0
  15. package/dist/info-menu.js +157 -0
  16. package/dist/project-file-dialogs.d.ts +70 -0
  17. package/dist/project-file-dialogs.js +625 -0
  18. package/dist/project-file-menu.d.ts +43 -0
  19. package/dist/project-file-menu.js +90 -0
  20. package/dist/project-load-progress-view.d.ts +6 -0
  21. package/dist/project-load-progress-view.js +66 -0
  22. package/dist/project-load-progress.d.ts +26 -0
  23. package/dist/project-load-progress.js +104 -0
  24. package/dist/project-search-box.d.ts +43 -0
  25. package/dist/project-search-box.js +437 -0
  26. package/dist/project-size-approval.d.ts +10 -0
  27. package/dist/project-size-approval.js +64 -0
  28. package/dist/stage-controls-view.d.ts +45 -0
  29. package/dist/stage-controls-view.js +127 -0
  30. package/dist/stage-controls.d.ts +98 -0
  31. package/dist/stage-controls.js +110 -0
  32. package/package.json +97 -28
  33. package/src/backpack-script.ts +21 -0
  34. package/src/backpack.tsx +260 -0
  35. package/src/browser-tab-title.ts +6 -0
  36. package/src/busy-cursor.ts +108 -0
  37. package/src/edit-menu.css +42 -0
  38. package/src/edit-menu.tsx +139 -0
  39. package/src/info-menu.css +172 -0
  40. package/src/info-menu.tsx +221 -0
  41. package/src/project-file-dialogs.ts +654 -0
  42. package/src/project-file-menu.css +94 -0
  43. package/src/project-file-menu.tsx +137 -0
  44. package/src/project-load-progress-view.tsx +75 -0
  45. package/src/project-load-progress.css +57 -0
  46. package/src/project-load-progress.ts +118 -0
  47. package/src/project-search-box.tsx +469 -0
  48. package/src/project-search.css +116 -0
  49. package/src/project-size-approval.ts +74 -0
  50. package/src/sprite-layout-menu.css +2 -1
  51. package/src/stage-controls-view.tsx +178 -0
  52. package/src/stage-controls.css +192 -0
  53. package/src/stage-controls.ts +124 -0
@@ -0,0 +1,172 @@
1
+ .tw-info-menu {
2
+ align-self: center;
3
+ position: relative;
4
+ margin-inline-end: 0.5rem;
5
+ color: var(--text-primary);
6
+ z-index: 120;
7
+ }
8
+
9
+ .tw-info-menu__leading {
10
+ flex-shrink: 0;
11
+ margin-inline: 0.5rem 0;
12
+ }
13
+
14
+ .tw-info-menu__project-title-group {
15
+ min-inline-size: 0;
16
+ max-inline-size: 12rem;
17
+ }
18
+
19
+ input.tw-info-menu__project-title-field {
20
+ field-sizing: content;
21
+ min-inline-size: 2rem;
22
+ }
23
+
24
+ input.tw-info-menu__project-title-field:not(:focus),
25
+ input.tw-info-menu__project-title-field:focus {
26
+ background-color: transparent;
27
+ border-color: transparent;
28
+ box-shadow: none;
29
+ color: var(--menu-bar-foreground);
30
+ transition: none;
31
+ }
32
+
33
+ input.tw-info-menu__project-title-field:focus {
34
+ border-color: currentColor;
35
+ }
36
+
37
+ .tw-info-menu > summary {
38
+ display: grid;
39
+ place-items: center;
40
+ width: 2.25rem;
41
+ height: 2.25rem;
42
+ border-radius: 0.25rem;
43
+ background: transparent;
44
+ cursor: pointer;
45
+ }
46
+
47
+ .tw-info-menu > summary::-webkit-details-marker {
48
+ display: none;
49
+ }
50
+
51
+ .tw-info-menu > summary img {
52
+ width: 1.875rem;
53
+ height: 1.875rem;
54
+ }
55
+
56
+ .tw-info-menu > nav,
57
+ .tw-info-menu__flyout {
58
+ position: absolute;
59
+ width: max-content;
60
+ padding: 0.25rem;
61
+ border: 1px solid var(--ui-black-transparent);
62
+ border-radius: 0.25rem;
63
+ background: var(--ui-white);
64
+ box-shadow: 0 2px 8px var(--ui-black-transparent);
65
+ }
66
+
67
+ .tw-info-menu > nav {
68
+ inset-block-start: calc(100% + 0.25rem);
69
+ inset-inline-end: 0;
70
+ }
71
+
72
+ .tw-info-menu__leading > nav {
73
+ inset-inline: 0 auto;
74
+ }
75
+
76
+ .tw-info-menu__branch {
77
+ position: relative;
78
+ }
79
+
80
+ .tw-info-menu__flyout {
81
+ inset-block-start: 0;
82
+ inset-inline-end: 100%;
83
+ }
84
+
85
+ .tw-info-menu__leading .tw-info-menu__flyout {
86
+ inset-inline: 100% auto;
87
+ }
88
+
89
+ .tw-info-menu__divider {
90
+ margin: 0.25rem 0;
91
+ border: 0;
92
+ border-block-start: 1px solid var(--ui-black-transparent);
93
+ }
94
+
95
+ .tw-info-menu__display {
96
+ margin: 0;
97
+ list-style: none;
98
+ }
99
+
100
+ .tw-info-menu__display > li > div > ul {
101
+ max-block-size: min(60vh, 28rem);
102
+ background-color: var(--ui-white);
103
+ color: var(--text-primary);
104
+ scrollbar-color: var(--text-primary) var(--ui-white);
105
+ }
106
+
107
+ .tw-info-menu__display > li > div > ul::-webkit-scrollbar-track {
108
+ background: var(--ui-white);
109
+ }
110
+
111
+ .tw-info-menu__display > li > div > ul::-webkit-scrollbar-thumb {
112
+ background-color: var(--text-primary);
113
+ border-color: var(--ui-white);
114
+ }
115
+
116
+ .tw-info-menu__display li:focus-visible {
117
+ outline: 2px solid var(--looks-secondary, #4c97ff);
118
+ outline-offset: -2px;
119
+ }
120
+
121
+ .tw-info-menu__entry {
122
+ display: flex;
123
+ align-items: center;
124
+ gap: 0.5rem;
125
+ padding: 0.5rem 0.75rem;
126
+ color: inherit;
127
+ text-decoration: none;
128
+ }
129
+
130
+ button.tw-info-menu__entry {
131
+ width: 100%;
132
+ border: 0;
133
+ background: transparent;
134
+ font: inherit;
135
+ text-align: start;
136
+ cursor: pointer;
137
+ }
138
+
139
+ .tw-info-menu__entry > svg,
140
+ .tw-info-menu__entry > img {
141
+ flex: none;
142
+ width: 1rem;
143
+ height: 1rem;
144
+ }
145
+
146
+ .tw-info-menu__new-tab-icon {
147
+ margin-inline-start: auto;
148
+ }
149
+
150
+ .tw-info-menu__entry.tw-info-menu__indented {
151
+ padding-inline-start: 2.25rem;
152
+ }
153
+
154
+ .tw-info-menu__entry:hover,
155
+ .tw-info-menu__entry:focus-visible,
156
+ .tw-info-menu__entry[aria-expanded="true"] {
157
+ background: var(--looks-light-transparent);
158
+ }
159
+
160
+ .tw-info-menu__caret {
161
+ margin-inline-start: auto;
162
+ font-size: 1.25em;
163
+ line-height: 1;
164
+ }
165
+
166
+ .tw-info-menu__caret:dir(rtl)::before {
167
+ content: '‹';
168
+ }
169
+
170
+ .tw-info-menu__caret::before {
171
+ content: '›';
172
+ }
@@ -0,0 +1,221 @@
1
+ import React from 'react';
2
+
3
+ export const projectTitleFieldClassName = 'tw-info-menu__project-title-field';
4
+ export const projectTitleGroupClassName = 'tw-info-menu__project-title-group';
5
+
6
+ type MenuAction = {
7
+ /** An image URL, or an inline icon such as an SVG drawn with `currentColor`. */
8
+ icon: string | React.ReactNode;
9
+ onClick: React.MouseEventHandler<HTMLButtonElement>;
10
+ };
11
+
12
+ type RuntimeItemProps = {
13
+ children: React.ReactNode;
14
+ className?: string;
15
+ closeOnSelect?: boolean;
16
+ onClick: React.MouseEventHandler<HTMLButtonElement>;
17
+ };
18
+
19
+ export interface ProjectSettingsMenuProps {
20
+ leading?: boolean;
21
+ displaySettings?: {
22
+ items: React.ReactNode;
23
+ open: boolean;
24
+ onOpen(): void;
25
+ onClose(): void;
26
+ };
27
+ renderRuntimeSettings?: (Item: React.ComponentType<RuntimeItemProps>) => React.ReactNode;
28
+ addons?: MenuAction;
29
+ advanced?: MenuAction;
30
+ /** Opens the AI agent settings; listed right after the advanced settings. */
31
+ aiAgents?: MenuAction;
32
+ }
33
+
34
+ interface ProjectInfoMenuProps extends ProjectSettingsMenuProps {
35
+ locale: string;
36
+ version: string;
37
+ logo: string;
38
+ openAbout?(): void;
39
+ openPrivacy?(): void;
40
+ sourceUrl?: string;
41
+ githubConnection?: MenuAction;
42
+ }
43
+
44
+ type Submenu = 'display' | 'runtime';
45
+
46
+ // Octicons mark-github-16 and law-16. See the distribution's NOTICE.
47
+ const githubPath = 'M6.766 11.328c-2.063-.25-3.516-1.734-3.516-3.656 0-.781.281-1.625.75-2.188-.203-.515-.172-1.609.063-2.062.625-.078 1.468.25 1.968.703.594-.187 1.219-.281 1.985-.281.765 0 1.39.094 1.953.265.484-.437 1.344-.765 1.969-.687.218.422.25 1.515.046 2.047.5.593.766 1.39.766 2.203 0 1.922-1.453 3.375-3.547 3.64.531.344.89 1.094.89 1.954v1.625c0 .468.391.734.86.547C13.781 14.359 16 11.53 16 8.03 16 3.61 12.406 0 7.984 0 3.563 0 0 3.61 0 8.031a7.88 7.88 0 0 0 5.172 7.422c.422.156.828-.125.828-.547v-1.25c-.219.094-.5.156-.75.156-1.031 0-1.64-.562-2.078-1.609-.172-.422-.36-.672-.719-.719-.187-.015-.25-.093-.25-.187 0-.188.313-.328.625-.328.453 0 .844.281 1.25.86.313.452.64.655 1.031.655s.641-.14 1-.5c.266-.265.47-.5.657-.656';
48
+ const licensePath = 'M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.245.245 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z';
49
+
50
+ const newTabIcon = (
51
+ <svg className="tw-info-menu__new-tab-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor"
52
+ strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
53
+ <path d="M8 3H3v10h10V8M10 3h3v3m0-3L7 9" />
54
+ </svg>
55
+ );
56
+
57
+ export function ProjectInfoMenu({
58
+ locale, version, logo, leading, displaySettings, renderRuntimeSettings, addons, advanced, githubConnection, aiAgents,
59
+ openAbout, openPrivacy, sourceUrl = 'https://github.com/kubohiroya/turbowarp-plus-editor'
60
+ }: ProjectInfoMenuProps) {
61
+ const menu = React.useRef<HTMLDetailsElement>(null);
62
+ const trigger = React.useRef<HTMLElement>(null);
63
+ const displayTrigger = React.useRef<HTMLButtonElement>(null);
64
+ const runtimeTrigger = React.useRef<HTMLButtonElement>(null);
65
+ const displayList = React.useRef<HTMLUListElement>(null);
66
+ const [open, setOpen] = React.useState(false);
67
+ const [submenu, setSubmenu] = React.useState<Submenu>(null);
68
+ const japanese = /^ja(?:-|$)/i.test(locale);
69
+ const label = japanese ? 'TurboWarp Plus プロジェクト情報' : 'TurboWarp Plus project information';
70
+ const product = `TurboWarp Plus Editor ${version}`;
71
+ const displayLabel = japanese ? '表示設定' : 'Display settings';
72
+ const runtimeLabel = japanese ? '動作設定' : 'Runtime settings';
73
+ const newTabLabel = japanese ? '別のタブで開きます' : 'Opens in a new tab';
74
+ const aboutLabel = japanese ? `${product}について` : `About ${product}`;
75
+
76
+ const closeDisplay = displaySettings?.onClose;
77
+ const close = React.useCallback(() => {
78
+ if (submenu === 'display') closeDisplay?.();
79
+ setSubmenu(null);
80
+ setOpen(false);
81
+ }, [submenu, closeDisplay]);
82
+ const closeAndFocus = React.useCallback(() => {
83
+ close();
84
+ trigger.current.focus({preventScroll: true});
85
+ }, [close]);
86
+
87
+ React.useEffect(() => {
88
+ if (!open) return;
89
+ const node = menu.current;
90
+ const dismiss = (event: PointerEvent) => {
91
+ if (!node.contains(event.target as Node)) close();
92
+ };
93
+ node.ownerDocument.addEventListener('pointerdown', dismiss, true);
94
+ return () => node.ownerDocument.removeEventListener('pointerdown', dismiss, true);
95
+ }, [open, close]);
96
+
97
+ // The native theme and language actions close the GUI settings menu when selected.
98
+ React.useEffect(() => {
99
+ if (submenu === 'display' && !displaySettings?.open) closeAndFocus();
100
+ }, [submenu, displaySettings?.open, closeAndFocus]);
101
+
102
+ React.useLayoutEffect(() => {
103
+ if (!displayList.current) return;
104
+ // The reused GUI settings are list items whose click handlers live on the item or its content.
105
+ for (const item of displayList.current.querySelectorAll('li')) item.tabIndex = 0;
106
+ }, [submenu]);
107
+
108
+ const RuntimeItem = React.useCallback(function RuntimeItem({children, className, closeOnSelect, onClick}: RuntimeItemProps) {
109
+ return <button className={className ? `tw-info-menu__entry ${className}` : 'tw-info-menu__entry'} type="button"
110
+ onClick={event => {
111
+ if (closeOnSelect) close();
112
+ onClick(event);
113
+ }}>
114
+ {children}
115
+ </button>;
116
+ }, [close]);
117
+
118
+ const toggleSubmenu = (name: Submenu) => {
119
+ if (submenu === 'display') closeDisplay?.();
120
+ if (submenu === name) {
121
+ setSubmenu(null);
122
+ return;
123
+ }
124
+ if (name === 'display') displaySettings.onOpen();
125
+ setSubmenu(name);
126
+ };
127
+ const action = (label: string, item: MenuAction, opensInNewTab = false) => item && (
128
+ <button className="tw-info-menu__entry" type="button" title={opensInNewTab ? newTabLabel : undefined} onClick={event => {
129
+ close();
130
+ item.onClick(event);
131
+ }}>
132
+ {typeof item.icon === 'string' ? <img src={item.icon} alt="" draggable={false} /> : item.icon}
133
+ {label}
134
+ {opensInNewTab && newTabIcon}
135
+ </button>
136
+ );
137
+ const activateDisplayItem = (event: React.KeyboardEvent<HTMLUListElement>) => {
138
+ if ((event.key !== 'Enter' && event.key !== ' ') || !(event.target instanceof HTMLLIElement)) return;
139
+ event.preventDefault();
140
+ const content = event.target.firstElementChild;
141
+ (content instanceof HTMLElement ? content : event.target).click();
142
+ };
143
+
144
+ const className = leading ? `tw-info-menu tw-info-menu__leading` : 'tw-info-menu';
145
+ return <details className={className} ref={menu} open={open} onKeyDown={event => {
146
+ if (event.key === ' ' &&
147
+ (event.target instanceof HTMLButtonElement || event.target === trigger.current)) {
148
+ event.preventDefault();
149
+ event.stopPropagation();
150
+ if (!event.repeat) (event.target as HTMLElement).click();
151
+ return;
152
+ }
153
+ if (event.key !== 'Escape' || !open) return;
154
+ event.preventDefault();
155
+ event.stopPropagation();
156
+ if (submenu) {
157
+ const button = submenu === 'display' ? displayTrigger : runtimeTrigger;
158
+ toggleSubmenu(submenu);
159
+ button.current.focus({preventScroll: true});
160
+ return;
161
+ }
162
+ closeAndFocus();
163
+ }}>
164
+ <summary ref={trigger} aria-label={label} title={label} onClick={event => {
165
+ event.preventDefault();
166
+ if (open) close();
167
+ else setOpen(true);
168
+ }}><img src={logo} alt="" draggable={false} /></summary>
169
+ <nav aria-label={label}>
170
+ {openAbout ? <button className={`tw-info-menu__entry tw-info-menu__indented`} type="button" onClick={() => {
171
+ close();
172
+ openAbout();
173
+ }}>{aboutLabel}</button> :
174
+ <a className={`tw-info-menu__entry tw-info-menu__indented`} href="./" target="_blank" rel="noreferrer"
175
+ title={newTabLabel} onClick={close}>
176
+ {aboutLabel}
177
+ {newTabIcon}
178
+ </a>}
179
+ {openPrivacy && <button className={`tw-info-menu__entry tw-info-menu__indented`} type="button" onClick={() => {
180
+ close();
181
+ openPrivacy();
182
+ }}>{japanese ? 'プライバシー' : 'Privacy'}</button>}
183
+ {displaySettings && <div className="tw-info-menu__branch">
184
+ <button className={`tw-info-menu__entry tw-info-menu__indented`} type="button" ref={displayTrigger}
185
+ aria-expanded={submenu === 'display'} onClick={() => toggleSubmenu('display')}>
186
+ {displayLabel}<span className="tw-info-menu__caret" aria-hidden="true" />
187
+ </button>
188
+ {submenu === 'display' && <ul className={`tw-info-menu__flyout tw-info-menu__display`} ref={displayList}
189
+ aria-label={displayLabel} onKeyDown={activateDisplayItem}>
190
+ {displaySettings.items}
191
+ </ul>}
192
+ </div>}
193
+ {renderRuntimeSettings && <div className="tw-info-menu__branch">
194
+ <button className={`tw-info-menu__entry tw-info-menu__indented`} type="button" ref={runtimeTrigger}
195
+ aria-expanded={submenu === 'runtime'} onClick={() => toggleSubmenu('runtime')}>
196
+ {runtimeLabel}<span className="tw-info-menu__caret" aria-hidden="true" />
197
+ </button>
198
+ {submenu === 'runtime' && <div className="tw-info-menu__flyout" role="group" aria-label={runtimeLabel}>
199
+ {renderRuntimeSettings(RuntimeItem)}
200
+ </div>}
201
+ </div>}
202
+ {action(japanese ? 'アドオン' : 'Addons', addons, true)}
203
+ {action(japanese ? '高度な設定' : 'Advanced Settings', advanced)}
204
+ {action(japanese ? 'GitHub 接続設定…' : 'GitHub Connection Settings…', githubConnection)}
205
+ {action(japanese ? 'AI エージェント設定…' : 'AI agent settings…', aiAgents)}
206
+ <hr className="tw-info-menu__divider" />
207
+ <a className="tw-info-menu__entry" href={sourceUrl}
208
+ target="_blank" rel="noreferrer" title={newTabLabel} onClick={close}>
209
+ <svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d={githubPath} /></svg>
210
+ {japanese ? 'ソースコード' : 'Source code'}
211
+ {newTabIcon}
212
+ </a>
213
+ <a className="tw-info-menu__entry" href="credits.html" target="_blank" rel="noreferrer"
214
+ title={newTabLabel} onClick={close}>
215
+ <svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d={licensePath} /></svg>
216
+ {japanese ? 'ライセンスとクレジット' : 'Licenses and credits'}
217
+ {newTabIcon}
218
+ </a>
219
+ </nav>
220
+ </details>;
221
+ }