@kubohiroya/turbowarp-title-menu 0.2.0 → 0.2.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.
- package/README.ja.md +2 -1
- package/README.md +3 -2
- package/dist/extension-manifest.json +1 -1
- package/dist/turbowarp-title-menu.js +25 -4
- package/package.json +1 -1
- package/src/block-definitions.json +1 -1
- package/src/extension.ts +24 -3
package/README.ja.md
CHANGED
|
@@ -33,7 +33,7 @@ IndexedDBはoriginごとに分かれます。TurboWarp Web、TurboWarp Desktop
|
|
|
33
33
|
## インストール
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.
|
|
36
|
+
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.2
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
TurboWarpでは `dist/turbowarp-title-menu.js` をCustom Extensionとして読み込み、sandboxなしの実行を許可します。
|
|
@@ -203,6 +203,7 @@ IndexedDBに保管しているDSLファイルの件数を返します。
|
|
|
203
203
|
|---|---|
|
|
204
204
|
| 組み込みのメニュー項目 | `files`/`reload`/`about`/`close` は最初から登録されており、それぞれの動作を保ちます。同時にhatも発火します。`clear app menu actions` で外せます。 |
|
|
205
205
|
| メニューの変更 | 項目の追加や消去でメニューを作り直します。表示中だった場合は消えずに再表示します。 |
|
|
206
|
+
| 項目が0件のとき | 1件も登録されていない状態では `show application menu` は何もせず、すべて消すと表示中のメニューは閉じます。土台のprimitiveが0件のメニューを作れないため、自分の項目を入れる前に全消しするプロジェクトが途中で止まらないようにしています。 |
|
|
206
207
|
| ファイルの追加 | 「ファイルを追加」はファイル選択ダイアログを開き、選ばれた内容を保管します。開きはしません。使うときは「開く」を押します。 |
|
|
207
208
|
| 名前の変更 | 名前は一意です。他のファイルと同じ名前にしようとすると失敗し、どちらのファイルも変わりません。 |
|
|
208
209
|
| 削除 | 削除には確認のためもう一度クリックが必要です。開いているファイルを削除すると、開いている内容も解除されます。 |
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ The reviewed JavaScript build is committed to this repository, so users do not n
|
|
|
48
48
|
Install an exact version that you have reviewed:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.
|
|
51
|
+
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.2
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Load the standalone bundle from:
|
|
@@ -60,7 +60,7 @@ node_modules/@kubohiroya/turbowarp-title-menu/dist/turbowarp-title-menu.js
|
|
|
60
60
|
A version-pinned CDN URL is:
|
|
61
61
|
|
|
62
62
|
```text
|
|
63
|
-
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-title-menu@0.2.
|
|
63
|
+
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-title-menu@0.2.2/dist/turbowarp-title-menu.js
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Quick start
|
|
@@ -235,6 +235,7 @@ Returns the most recent DSL storage failure in the interface language, or an emp
|
|
|
235
235
|
| Official website | The title dialog opens the configured website URL in a new browser tab. |
|
|
236
236
|
| Built-in menu actions | `files`, `reload`, `about`, and `close` are pre-registered and keep their own behavior. They also start the hat, and `clear app menu actions` removes them. |
|
|
237
237
|
| Changing the menu | Adding or clearing an action rebuilds the menu. A menu that was on screen is shown again rather than disappearing. |
|
|
238
|
+
| An empty menu | `show application menu` does nothing while no action is registered, and clearing every action closes an open menu. The underlying primitive refuses to build a menu with no actions, so a project that clears the set before installing its own is not interrupted. |
|
|
238
239
|
| Adding a DSL file | `Add file` opens a browser file picker and stores the chosen source. It does not open the file; the operator presses `Open` when the project should use it. |
|
|
239
240
|
| Renaming | Names are unique. Renaming a file to a name another file already uses fails and leaves both files unchanged. |
|
|
240
241
|
| Deleting | Deleting asks for a second confirming click, and deleting the open file clears the opened source. |
|
|
@@ -1183,7 +1183,7 @@
|
|
|
1183
1183
|
});
|
|
1184
1184
|
}
|
|
1185
1185
|
const extensionName = "TurboWarp Title Menu";
|
|
1186
|
-
const menus = { "menuActions": { "acceptReporters":
|
|
1186
|
+
const menus = { "menuActions": { "acceptReporters": false, "items": "menuActionItems" } };
|
|
1187
1187
|
const blocks = [{ "opcode": "showTitle", "blockType": "COMMAND", "text": "show title dialog", "description": "Shows the configured title dialog above the TurboWarp stage." }, { "opcode": "showMenu", "blockType": "COMMAND", "text": "show application menu", "description": "Shows the application menu above the TurboWarp stage." }, { "opcode": "addAppMenuAction", "blockType": "COMMAND", "text": "add app menu action [ACTION] labelled [LABEL]", "description": "Adds an application menu action this project owns, or relabels one it already added.", "arguments": { "ACTION": { "type": "STRING", "defaultValue": "start" }, "LABEL": { "type": "STRING", "defaultValue": "Start" } } }, { "opcode": "clearAppMenuActions", "blockType": "COMMAND", "text": "clear app menu actions", "description": "Removes every application menu action, including the built-in ones, so a project can define its own set." }, { "opcode": "setAppMenuActionEnabled", "blockType": "COMMAND", "text": "set app menu action [ACTION] enabled [ENABLED]", "description": "Enables or disables one application menu action.", "arguments": { "ACTION": { "type": "STRING", "menu": "menuActions" }, "ENABLED": { "type": "BOOLEAN", "defaultValue": true } } }, { "opcode": "whenAppMenuActionSelected", "blockType": "HAT", "text": "when app menu action [ACTION] selected", "description": "Runs when the operator selects the named application menu action.", "arguments": { "ACTION": { "type": "STRING", "menu": "menuActions" } } }, { "opcode": "showDslFiles", "blockType": "COMMAND", "text": "show DSL file manager", "description": "Shows the dialog that adds, opens, renames, deletes, and sorts stored DSL files." }, { "opcode": "whenDslSourceOpened", "blockType": "HAT", "text": "when a DSL source is opened", "description": "Runs after the operator opens a stored DSL file, or after the opened source is announced again." }, { "opcode": "reloadOpenedDsl", "blockType": "COMMAND", "text": "reload the opened DSL source", "description": "Announces the currently opened DSL source again without showing a dialog." }, { "opcode": "openedDslName", "blockType": "REPORTER", "text": "opened DSL file name", "description": "Returns the name of the DSL file that is currently open, or an empty string." }, { "opcode": "openedDslSource", "blockType": "REPORTER", "text": "opened DSL source", "description": "Returns the text of the DSL file that is currently open, or an empty string." }, { "opcode": "hasSavedDsl", "blockType": "BOOLEAN", "text": "has a saved DSL file?", "description": "Reports whether at least one DSL file is stored in IndexedDB." }, { "opcode": "savedDslCount", "blockType": "REPORTER", "text": "saved DSL file count", "description": "Returns how many DSL files are stored in IndexedDB." }, { "opcode": "lastDslError", "blockType": "REPORTER", "text": "last DSL storage error", "description": "Returns the most recent DSL storage failure in the interface language, or an empty string." }];
|
|
1188
1188
|
const definitions = {
|
|
1189
1189
|
extensionName,
|
|
@@ -1307,11 +1307,26 @@
|
|
|
1307
1307
|
showTitle() {
|
|
1308
1308
|
this.ensureTitleDialog().show(this.locale());
|
|
1309
1309
|
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Shows the application menu.
|
|
1312
|
+
*
|
|
1313
|
+
* An empty registry does nothing: the underlying primitive requires at least one action, and a
|
|
1314
|
+
* project that cleared the actions to install its own should not be interrupted by an error
|
|
1315
|
+
* between the two steps.
|
|
1316
|
+
*/
|
|
1310
1317
|
showMenu() {
|
|
1318
|
+
if (this.menuActions.length === 0) return;
|
|
1311
1319
|
this.ensureApplicationMenu().show(this.locale());
|
|
1312
1320
|
this.menuVisible = true;
|
|
1313
1321
|
}
|
|
1314
|
-
/**
|
|
1322
|
+
/**
|
|
1323
|
+
* Backs the dynamic `menuActions` dropdown, so it always lists what the project registered.
|
|
1324
|
+
*
|
|
1325
|
+
* The menu must refuse reporters. Scratch turns a reporter-accepting menu argument into an input
|
|
1326
|
+
* holding a shadow block, and `startHats` matches a hat against its *fields*, so the action hat
|
|
1327
|
+
* would never fire for a specific action. Refusing reporters keeps the argument an inline
|
|
1328
|
+
* dropdown, which is what the match reads.
|
|
1329
|
+
*/
|
|
1315
1330
|
menuActionItems() {
|
|
1316
1331
|
if (this.menuActions.length === 0) return [{ text: "—", value: "" }];
|
|
1317
1332
|
const locale = this.locale();
|
|
@@ -1396,12 +1411,18 @@
|
|
|
1396
1411
|
*
|
|
1397
1412
|
* The app-shell primitive fixes its actions at construction, so a changed list means a new menu.
|
|
1398
1413
|
* A menu that was on screen is shown again, because a project that adds an action while the menu
|
|
1399
|
-
* is open should not have it silently disappear.
|
|
1414
|
+
* is open should not have it silently disappear. Clearing every action closes the menu instead,
|
|
1415
|
+
* because the primitive refuses to build one with no actions.
|
|
1400
1416
|
*/
|
|
1401
1417
|
rebuildMenu() {
|
|
1402
1418
|
this.applicationMenu?.dispose();
|
|
1403
1419
|
this.applicationMenu = null;
|
|
1404
|
-
if (this.menuVisible)
|
|
1420
|
+
if (!this.menuVisible) return;
|
|
1421
|
+
if (this.menuActions.length === 0) {
|
|
1422
|
+
this.menuVisible = false;
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
this.showMenu();
|
|
1405
1426
|
}
|
|
1406
1427
|
selectMenuAction(id) {
|
|
1407
1428
|
Scratch.vm?.runtime?.startHats?.(`${extensionConfig.id}_whenAppMenuActionSelected`, { ACTION: id });
|
package/package.json
CHANGED
package/src/extension.ts
CHANGED
|
@@ -81,12 +81,27 @@ export class TurboWarpTitleMenuExtension implements TurboWarpExtension {
|
|
|
81
81
|
this.ensureTitleDialog().show(this.locale());
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Shows the application menu.
|
|
86
|
+
*
|
|
87
|
+
* An empty registry does nothing: the underlying primitive requires at least one action, and a
|
|
88
|
+
* project that cleared the actions to install its own should not be interrupted by an error
|
|
89
|
+
* between the two steps.
|
|
90
|
+
*/
|
|
84
91
|
public showMenu(): void {
|
|
92
|
+
if (this.menuActions.length === 0) return;
|
|
85
93
|
this.ensureApplicationMenu().show(this.locale());
|
|
86
94
|
this.menuVisible = true;
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Backs the dynamic `menuActions` dropdown, so it always lists what the project registered.
|
|
99
|
+
*
|
|
100
|
+
* The menu must refuse reporters. Scratch turns a reporter-accepting menu argument into an input
|
|
101
|
+
* holding a shadow block, and `startHats` matches a hat against its *fields*, so the action hat
|
|
102
|
+
* would never fire for a specific action. Refusing reporters keeps the argument an inline
|
|
103
|
+
* dropdown, which is what the match reads.
|
|
104
|
+
*/
|
|
90
105
|
public menuActionItems(): Array<{text: string; value: string}> {
|
|
91
106
|
if (this.menuActions.length === 0) return [{text: '\u2014', value: ''}];
|
|
92
107
|
const locale = this.locale();
|
|
@@ -187,12 +202,18 @@ export class TurboWarpTitleMenuExtension implements TurboWarpExtension {
|
|
|
187
202
|
*
|
|
188
203
|
* The app-shell primitive fixes its actions at construction, so a changed list means a new menu.
|
|
189
204
|
* A menu that was on screen is shown again, because a project that adds an action while the menu
|
|
190
|
-
* is open should not have it silently disappear.
|
|
205
|
+
* is open should not have it silently disappear. Clearing every action closes the menu instead,
|
|
206
|
+
* because the primitive refuses to build one with no actions.
|
|
191
207
|
*/
|
|
192
208
|
private rebuildMenu(): void {
|
|
193
209
|
this.applicationMenu?.dispose();
|
|
194
210
|
this.applicationMenu = null;
|
|
195
|
-
if (this.menuVisible)
|
|
211
|
+
if (!this.menuVisible) return;
|
|
212
|
+
if (this.menuActions.length === 0) {
|
|
213
|
+
this.menuVisible = false;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.showMenu();
|
|
196
217
|
}
|
|
197
218
|
|
|
198
219
|
private selectMenuAction(id: string): void {
|