@kubohiroya/turbowarp-title-menu 0.2.3 → 0.2.5
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 +1 -1
- package/README.md +2 -2
- package/dist/turbowarp-title-menu.js +1498 -1473
- package/docs/index.html +33 -1
- package/package.json +5 -5
- package/schemas/extension-manifest.schema.json +0 -49
- package/src/extension-manifest.ts +0 -149
package/docs/index.html
CHANGED
|
@@ -9,8 +9,17 @@
|
|
|
9
9
|
code{background:#f3f3f3;padding:.1em .3em;border-radius:.25em}
|
|
10
10
|
pre{background:#f6f8fa;padding:1rem;overflow:auto;border-radius:.5rem}
|
|
11
11
|
</style>
|
|
12
|
+
<style id="block-reference-style">
|
|
13
|
+
#extension-block-reference{max-width:72rem;margin:2rem auto;padding:1rem;line-height:1.6;overflow-wrap:anywhere}
|
|
14
|
+
#extension-block-reference .block-reference-entry{display:block;scroll-margin-top:6rem;margin:2rem 0;padding:1rem;border:1px solid currentColor;border-radius:.5rem}
|
|
15
|
+
#extension-block-reference .block-reference-table{overflow-x:auto}
|
|
16
|
+
#extension-block-reference table{border-collapse:collapse;width:100%}
|
|
17
|
+
#extension-block-reference th,#extension-block-reference td{text-align:left;vertical-align:top;border:1px solid currentColor;padding:.5rem}
|
|
18
|
+
#extension-block-reference code{white-space:pre-wrap}
|
|
19
|
+
#extension-block-reference a:focus-visible{outline:3px solid currentColor;outline-offset:3px}
|
|
20
|
+
</style>
|
|
12
21
|
</head>
|
|
13
|
-
<body>
|
|
22
|
+
<body><p lang="en" class="complete-block-reference-link"><a href="#extension-block-reference">Complete block reference (14 blocks)</a></p>
|
|
14
23
|
<h1>TurboWarp Title Menu</h1>
|
|
15
24
|
<p>Reusable title, menu, and DSL source storage controls for TurboWarp projects.</p>
|
|
16
25
|
|
|
@@ -30,5 +39,28 @@
|
|
|
30
39
|
|
|
31
40
|
<h2>Development</h2>
|
|
32
41
|
<p>See the repository README and architecture documentation for build, test, release, and compatibility details.</p>
|
|
42
|
+
<!-- BEGIN COMPLETE BLOCK REFERENCE -->
|
|
43
|
+
<section lang="en" id="extension-block-reference" aria-labelledby="block-reference-title">
|
|
44
|
+
<h2 id="block-reference-title">TurboWarp Title Menu: complete block reference</h2>
|
|
45
|
+
<p>All 14 blocks are documented below, including compatibility blocks and blocks available through optional features. Select a block to read its behavior, arguments, default values, and menu choices. Each block has a permanent link.</p>
|
|
46
|
+
<nav aria-label="Block reference"><ul><li><a href="#block-showTitle"><code>show title dialog</code></a></li>
|
|
47
|
+
<li><a href="#block-showMenu"><code>show application menu</code></a></li>
|
|
48
|
+
<li><a href="#block-addAppMenuAction"><code>add app menu action [ACTION] labelled [LABEL]</code></a></li>
|
|
49
|
+
<li><a href="#block-clearAppMenuActions"><code>clear app menu actions</code></a></li>
|
|
50
|
+
<li><a href="#block-setAppMenuActionEnabled"><code>set app menu action [ACTION] enabled [ENABLED]</code></a></li>
|
|
51
|
+
<li><a href="#block-whenAppMenuActionSelected"><code>when app menu action [ACTION] selected</code></a></li>
|
|
52
|
+
<li><a href="#block-showDslFiles"><code>show DSL file manager</code></a></li>
|
|
53
|
+
<li><a href="#block-whenDslSourceOpened"><code>when a DSL source is opened</code></a></li>
|
|
54
|
+
<li><a href="#block-reloadOpenedDsl"><code>reload the opened DSL source</code></a></li>
|
|
55
|
+
<li><a href="#block-openedDslName"><code>opened DSL file name</code></a></li>
|
|
56
|
+
<li><a href="#block-openedDslSource"><code>opened DSL source</code></a></li>
|
|
57
|
+
<li><a href="#block-hasSavedDsl"><code>has a saved DSL file?</code></a></li>
|
|
58
|
+
<li><a href="#block-savedDslCount"><code>saved DSL file count</code></a></li>
|
|
59
|
+
<li><a href="#block-lastDslError"><code>last DSL storage error</code></a></li>
|
|
60
|
+
</ul></nav>
|
|
61
|
+
<article id="block-showTitle" class="block-reference-entry"><h3><code>show title dialog</code></h3><p>Shows the configured title dialog above the TurboWarp stage.</p><p>Block type: COMMAND. Opcode: <code>showTitle</code>. <a href="#block-showTitle">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-showMenu" class="block-reference-entry"><h3><code>show application menu</code></h3><p>Shows the application menu above the TurboWarp stage.</p><p>Block type: COMMAND. Opcode: <code>showMenu</code>. <a href="#block-showMenu">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-addAppMenuAction" class="block-reference-entry"><h3><code>add app menu action [ACTION] labelled [LABEL]</code></h3><p>Adds an application menu action this project owns, or relabels one it already added.</p><p>Block type: COMMAND. Opcode: <code>addAppMenuAction</code>. <a href="#block-addAppMenuAction">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>ACTION</code></th><td>STRING</td><td><code>start</code></td><td></td></tr><tr><th scope="row"><code>LABEL</code></th><td>STRING</td><td><code>Start</code></td><td></td></tr></tbody></table></div></article><article id="block-clearAppMenuActions" class="block-reference-entry"><h3><code>clear app menu actions</code></h3><p>Removes every application menu action, including the built-in ones, so a project can define its own set.</p><p>Block type: COMMAND. Opcode: <code>clearAppMenuActions</code>. <a href="#block-clearAppMenuActions">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-setAppMenuActionEnabled" class="block-reference-entry"><h3><code>set app menu action [ACTION] enabled [ENABLED]</code></h3><p>Enables or disables one application menu action.</p><p>Block type: COMMAND. Opcode: <code>setAppMenuActionEnabled</code>. <a href="#block-setAppMenuActionEnabled">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>ACTION</code></th><td>STRING</td><td>Not specified</td><td>Available choices depend on the current project or environment.</td></tr><tr><th scope="row"><code>ENABLED</code></th><td>BOOLEAN</td><td><code>true</code></td><td></td></tr></tbody></table></div></article><article id="block-whenAppMenuActionSelected" class="block-reference-entry"><h3><code>when app menu action [ACTION] selected</code></h3><p>Runs when the operator selects the named application menu action.</p><p>Block type: HAT. Opcode: <code>whenAppMenuActionSelected</code>. <a href="#block-whenAppMenuActionSelected">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>ACTION</code></th><td>STRING</td><td>Not specified</td><td>Available choices depend on the current project or environment.</td></tr></tbody></table></div></article><article id="block-showDslFiles" class="block-reference-entry"><h3><code>show DSL file manager</code></h3><p>Shows the dialog that adds, opens, renames, deletes, and sorts stored DSL files.</p><p>Block type: COMMAND. Opcode: <code>showDslFiles</code>. <a href="#block-showDslFiles">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-whenDslSourceOpened" class="block-reference-entry"><h3><code>when a DSL source is opened</code></h3><p>Runs after the operator opens a stored DSL file, or after the opened source is announced again.</p><p>Block type: HAT. Opcode: <code>whenDslSourceOpened</code>. <a href="#block-whenDslSourceOpened">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-reloadOpenedDsl" class="block-reference-entry"><h3><code>reload the opened DSL source</code></h3><p>Announces the currently opened DSL source again without showing a dialog.</p><p>Block type: COMMAND. Opcode: <code>reloadOpenedDsl</code>. <a href="#block-reloadOpenedDsl">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-openedDslName" class="block-reference-entry"><h3><code>opened DSL file name</code></h3><p>Returns the name of the DSL file that is currently open, or an empty string.</p><p>Block type: REPORTER. Opcode: <code>openedDslName</code>. <a href="#block-openedDslName">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-openedDslSource" class="block-reference-entry"><h3><code>opened DSL source</code></h3><p>Returns the text of the DSL file that is currently open, or an empty string.</p><p>Block type: REPORTER. Opcode: <code>openedDslSource</code>. <a href="#block-openedDslSource">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-hasSavedDsl" class="block-reference-entry"><h3><code>has a saved DSL file?</code></h3><p>Reports whether at least one DSL file is stored in IndexedDB.</p><p>Block type: BOOLEAN. Opcode: <code>hasSavedDsl</code>. <a href="#block-hasSavedDsl">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-savedDslCount" class="block-reference-entry"><h3><code>saved DSL file count</code></h3><p>Returns how many DSL files are stored in IndexedDB.</p><p>Block type: REPORTER. Opcode: <code>savedDslCount</code>. <a href="#block-savedDslCount">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-lastDslError" class="block-reference-entry"><h3><code>last DSL storage error</code></h3><p>Returns the most recent DSL storage failure in the interface language, or an empty string.</p><p>Block type: REPORTER. Opcode: <code>lastDslError</code>. <a href="#block-lastDslError">Permanent link</a></p><p>This block has no arguments.</p></article>
|
|
62
|
+
<p><a href="https://github.com/kubohiroya/turbowarp-title-menu/blob/main/README.md">Repository guide and examples</a></p>
|
|
63
|
+
</section>
|
|
64
|
+
<!-- END COMPLETE BLOCK REFERENCE -->
|
|
33
65
|
</body>
|
|
34
66
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-title-menu",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Reusable title, application menu, and DSL source storage controls for TurboWarp.",
|
|
5
5
|
"author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"dist/",
|
|
42
42
|
"docs/",
|
|
43
|
-
"schemas/",
|
|
44
43
|
"src/",
|
|
45
44
|
"README.md",
|
|
46
45
|
"README.ja.md",
|
|
@@ -69,16 +68,17 @@
|
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
71
70
|
"@eslint/js": "^9.39.5",
|
|
72
|
-
"@kubohiroya/
|
|
71
|
+
"@kubohiroya/turbowarp-extension-manifest": "0.3.2",
|
|
72
|
+
"@kubohiroya/vite-plugin-turbowarp-extension": "0.6.1",
|
|
73
73
|
"@types/node": "^24.13.3",
|
|
74
74
|
"eslint": "^9.39.5",
|
|
75
75
|
"fake-indexeddb": "6.2.5",
|
|
76
76
|
"typescript": "^5.9.3",
|
|
77
77
|
"typescript-eslint": "^8.66.0",
|
|
78
|
-
"vite": "^
|
|
78
|
+
"vite": "^8.2.2",
|
|
79
79
|
"vitest": "^4.1.10"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubohiroya/turbowarp-app-shell": "0.
|
|
82
|
+
"@kubohiroya/turbowarp-app-shell": "0.3.0"
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://raw.githubusercontent.com/kubohiroya/turbowarp-title-menu/main/schemas/extension-manifest.schema.json",
|
|
4
|
-
"title": "TurboWarp Extension API Manifest",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"additionalProperties": false,
|
|
7
|
-
"required": ["formatVersion", "id", "blocks", "menus"],
|
|
8
|
-
"properties": {
|
|
9
|
-
"formatVersion": {"const": 1},
|
|
10
|
-
"id": {"type": "string", "pattern": "^[a-z0-9]+$"},
|
|
11
|
-
"blocks": {
|
|
12
|
-
"type": "array",
|
|
13
|
-
"items": {
|
|
14
|
-
"type": "object",
|
|
15
|
-
"additionalProperties": false,
|
|
16
|
-
"required": ["opcode", "blockType", "arguments"],
|
|
17
|
-
"properties": {
|
|
18
|
-
"opcode": {"type": "string", "minLength": 1},
|
|
19
|
-
"blockType": {"type": "string", "minLength": 1},
|
|
20
|
-
"arguments": {
|
|
21
|
-
"type": "array",
|
|
22
|
-
"items": {
|
|
23
|
-
"type": "object",
|
|
24
|
-
"additionalProperties": false,
|
|
25
|
-
"required": ["id", "type"],
|
|
26
|
-
"properties": {
|
|
27
|
-
"id": {"type": "string", "minLength": 1},
|
|
28
|
-
"type": {"type": "string", "minLength": 1},
|
|
29
|
-
"menu": {"type": "string", "minLength": 1}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"menus": {
|
|
37
|
-
"type": "array",
|
|
38
|
-
"items": {
|
|
39
|
-
"type": "object",
|
|
40
|
-
"additionalProperties": false,
|
|
41
|
-
"required": ["id", "acceptReporters"],
|
|
42
|
-
"properties": {
|
|
43
|
-
"id": {"type": "string", "minLength": 1},
|
|
44
|
-
"acceptReporters": {"type": "boolean"}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type {Plugin} from 'vite';
|
|
2
|
-
|
|
3
|
-
export const EXTENSION_MANIFEST_FORMAT_VERSION = 1 as const;
|
|
4
|
-
|
|
5
|
-
export interface ExtensionManifestArgument {
|
|
6
|
-
id: string;
|
|
7
|
-
type: string;
|
|
8
|
-
menu?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ExtensionManifestBlock {
|
|
12
|
-
opcode: string;
|
|
13
|
-
blockType: string;
|
|
14
|
-
arguments: ExtensionManifestArgument[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ExtensionManifestMenu {
|
|
18
|
-
id: string;
|
|
19
|
-
acceptReporters: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ExtensionManifest {
|
|
23
|
-
formatVersion: typeof EXTENSION_MANIFEST_FORMAT_VERSION;
|
|
24
|
-
id: string;
|
|
25
|
-
blocks: ExtensionManifestBlock[];
|
|
26
|
-
menus: ExtensionManifestMenu[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ExtensionManifestPluginOptions {
|
|
30
|
-
id: string;
|
|
31
|
-
definitions: unknown;
|
|
32
|
-
fileName?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createExtensionManifest(id: string, definitions: unknown): ExtensionManifest {
|
|
36
|
-
if (!/^[a-z0-9]+$/.test(id)) {
|
|
37
|
-
throw new TypeError('Extension manifest ID must contain only lowercase letters and numbers.');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const source = requireRecord(definitions, 'Block definitions');
|
|
41
|
-
const sourceBlocks = source.blocks;
|
|
42
|
-
if (!Array.isArray(sourceBlocks)) {
|
|
43
|
-
throw new TypeError('Block definitions must contain a blocks array.');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const menus = normalizeMenus(source.menus);
|
|
47
|
-
const menuIds = new Set(menus.map((menu) => menu.id));
|
|
48
|
-
const seenOpcodes = new Set<string>();
|
|
49
|
-
const blocks = sourceBlocks.map((block, index) => {
|
|
50
|
-
const normalized = normalizeBlock(block, index, menuIds);
|
|
51
|
-
if (seenOpcodes.has(normalized.opcode)) {
|
|
52
|
-
throw new TypeError(`Duplicate block opcode: ${normalized.opcode}`);
|
|
53
|
-
}
|
|
54
|
-
seenOpcodes.add(normalized.opcode);
|
|
55
|
-
return normalized;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
formatVersion: EXTENSION_MANIFEST_FORMAT_VERSION,
|
|
60
|
-
id,
|
|
61
|
-
blocks: blocks.sort((left, right) => compareIds(left.opcode, right.opcode)),
|
|
62
|
-
menus
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function serializeExtensionManifest(id: string, definitions: unknown): string {
|
|
67
|
-
return `${JSON.stringify(createExtensionManifest(id, definitions), null, 2)}\n`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function extensionManifestPlugin(options: ExtensionManifestPluginOptions): Plugin {
|
|
71
|
-
return {
|
|
72
|
-
name: 'extension-api-manifest',
|
|
73
|
-
apply: 'build',
|
|
74
|
-
enforce: 'post',
|
|
75
|
-
generateBundle() {
|
|
76
|
-
this.emitFile({
|
|
77
|
-
type: 'asset',
|
|
78
|
-
fileName: options.fileName ?? 'extension-manifest.json',
|
|
79
|
-
source: serializeExtensionManifest(options.id, options.definitions)
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function normalizeBlock(
|
|
86
|
-
value: unknown,
|
|
87
|
-
index: number,
|
|
88
|
-
menuIds: ReadonlySet<string>
|
|
89
|
-
): ExtensionManifestBlock {
|
|
90
|
-
const block = requireRecord(value, `Block at index ${index}`);
|
|
91
|
-
const opcode = requireNonEmptyString(block.opcode, `Block at index ${index} opcode`);
|
|
92
|
-
const blockType = requireNonEmptyString(block.blockType, `Block ${opcode} blockType`);
|
|
93
|
-
const sourceArguments = block.arguments ?? {};
|
|
94
|
-
const argumentRecord = requireRecord(sourceArguments, `Block ${opcode} arguments`);
|
|
95
|
-
const argumentsList = Object.entries(argumentRecord).map(([argumentId, argument]) => {
|
|
96
|
-
requireNonEmptyString(argumentId, `Block ${opcode} argument ID`);
|
|
97
|
-
const definition = requireRecord(argument, `Block ${opcode} argument ${argumentId}`);
|
|
98
|
-
const type = requireNonEmptyString(
|
|
99
|
-
definition.type,
|
|
100
|
-
`Block ${opcode} argument ${argumentId} type`
|
|
101
|
-
);
|
|
102
|
-
const menu = definition.menu;
|
|
103
|
-
if (menu !== undefined && (typeof menu !== 'string' || !menuIds.has(menu))) {
|
|
104
|
-
throw new TypeError(`Block ${opcode} argument ${argumentId} references unknown menu: ${menu}`);
|
|
105
|
-
}
|
|
106
|
-
return menu === undefined ? {id: argumentId, type} : {id: argumentId, type, menu};
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
opcode,
|
|
111
|
-
blockType,
|
|
112
|
-
arguments: argumentsList.sort((left, right) => compareIds(left.id, right.id))
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function normalizeMenus(value: unknown): ExtensionManifestMenu[] {
|
|
117
|
-
const menuRecord = requireRecord(value ?? {}, 'Block definition menus');
|
|
118
|
-
return Object.entries(menuRecord)
|
|
119
|
-
.map(([id, menu]) => {
|
|
120
|
-
requireNonEmptyString(id, 'Menu ID');
|
|
121
|
-
const definition = requireRecord(menu, `Menu ${id}`);
|
|
122
|
-
const acceptReporters = definition.acceptReporters ?? false;
|
|
123
|
-
if (typeof acceptReporters !== 'boolean') {
|
|
124
|
-
throw new TypeError(`Menu ${id} acceptReporters must be a boolean.`);
|
|
125
|
-
}
|
|
126
|
-
return {id, acceptReporters};
|
|
127
|
-
})
|
|
128
|
-
.sort((left, right) => compareIds(left.id, right.id));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
|
132
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
133
|
-
throw new TypeError(`${label} must be an object.`);
|
|
134
|
-
}
|
|
135
|
-
return value as Record<string, unknown>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function requireNonEmptyString(value: unknown, label: string): string {
|
|
139
|
-
if (typeof value !== 'string' || value.length === 0) {
|
|
140
|
-
throw new TypeError(`${label} must be a non-empty string.`);
|
|
141
|
-
}
|
|
142
|
-
return value;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function compareIds(left: string, right: string): number {
|
|
146
|
-
if (left < right) return -1;
|
|
147
|
-
if (left > right) return 1;
|
|
148
|
-
return 0;
|
|
149
|
-
}
|