@blastlauncher/client-core 0.0.0-stage → 3.0.0-alpha.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/LICENSE +7 -0
- package/README.md +4 -2
- package/dist/controller.d.ts +219 -0
- package/dist/controller.js +655 -0
- package/dist/dropdown.d.ts +27 -0
- package/dist/dropdown.js +62 -0
- package/dist/feedback.d.ts +50 -0
- package/dist/feedback.js +51 -0
- package/dist/form-view.d.ts +72 -0
- package/dist/form-view.js +236 -0
- package/dist/grid.d.ts +21 -0
- package/dist/grid.js +89 -0
- package/dist/hud.d.ts +2 -0
- package/dist/hud.js +2 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +409 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +17 -0
- package/dist/menu-bar.d.ts +59 -0
- package/dist/menu-bar.js +117 -0
- package/dist/nodes.d.ts +21 -0
- package/dist/nodes.js +41 -0
- package/dist/pagination.d.ts +15 -0
- package/dist/pagination.js +18 -0
- package/dist/rank.d.ts +46 -0
- package/dist/rank.js +126 -0
- package/dist/search.d.ts +15 -0
- package/dist/search.js +18 -0
- package/dist/shortcut.d.ts +13 -0
- package/dist/shortcut.js +148 -0
- package/dist/view.d.ts +56 -0
- package/dist/view.js +261 -0
- package/package.json +23 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2023 Yukai Huang
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @blastlauncher/client-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blast's client-core package.
|
|
4
|
+
Emitted ESM and TypeScript declarations for Node.js 24.20+.
|
|
5
|
+
See https://github.com/BlastLauncher/blast for documentation.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { SceneMessage } from "@blastlauncher/protocol";
|
|
2
|
+
import { type OutboundEvent } from "./nodes.js";
|
|
3
|
+
import { type FormInput, type FormFieldView } from "./form-view.js";
|
|
4
|
+
export type { FormFieldView } from "./form-view.js";
|
|
5
|
+
import { type KeyInput, type Platform } from "./shortcut.js";
|
|
6
|
+
export type ControllerInput = FormInput | {
|
|
7
|
+
type: "search";
|
|
8
|
+
text: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "move";
|
|
11
|
+
direction: "up" | "down" | "left" | "right";
|
|
12
|
+
}
|
|
13
|
+
/** Pointer selection of a list item or grid cell by its view id. */
|
|
14
|
+
| {
|
|
15
|
+
type: "select";
|
|
16
|
+
id: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "primary";
|
|
19
|
+
} | {
|
|
20
|
+
type: "openActions";
|
|
21
|
+
} | {
|
|
22
|
+
type: "closeActions";
|
|
23
|
+
} | {
|
|
24
|
+
type: "actionsQuery";
|
|
25
|
+
text: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "key";
|
|
28
|
+
key: KeyInput;
|
|
29
|
+
} | {
|
|
30
|
+
type: "back";
|
|
31
|
+
} | {
|
|
32
|
+
type: "openDropdown";
|
|
33
|
+
} | {
|
|
34
|
+
type: "dropdownQuery";
|
|
35
|
+
text: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "chooseDropdown";
|
|
38
|
+
} | {
|
|
39
|
+
type: "toastAction";
|
|
40
|
+
index: number;
|
|
41
|
+
} | {
|
|
42
|
+
type: "alert";
|
|
43
|
+
confirm: boolean;
|
|
44
|
+
remember?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type Effect = {
|
|
47
|
+
type: "quit";
|
|
48
|
+
} | {
|
|
49
|
+
type: "schedule";
|
|
50
|
+
ms: number;
|
|
51
|
+
token: string;
|
|
52
|
+
};
|
|
53
|
+
export type ControllerResult = {
|
|
54
|
+
events: OutboundEvent[];
|
|
55
|
+
effects: Effect[];
|
|
56
|
+
/** A `key` input matched a shortcut, so the embedder should not also treat the press as text. */
|
|
57
|
+
handled?: true;
|
|
58
|
+
};
|
|
59
|
+
export type ViewKind = "list" | "grid" | "detail" | "form" | "menu-bar" | "empty";
|
|
60
|
+
export type RowView = {
|
|
61
|
+
/** The selection id for items, the node id for section headers. */
|
|
62
|
+
id: string;
|
|
63
|
+
kind: "item" | "section" | "unsupported";
|
|
64
|
+
title: string;
|
|
65
|
+
subtitle: string;
|
|
66
|
+
accessories: string;
|
|
67
|
+
icon: boolean;
|
|
68
|
+
/** Items in a section header's section. */
|
|
69
|
+
count: number | null;
|
|
70
|
+
selected: boolean;
|
|
71
|
+
iconLabel: string;
|
|
72
|
+
iconTint?: string;
|
|
73
|
+
/** The row as one line, for clients that do not lay columns out. */
|
|
74
|
+
text: string;
|
|
75
|
+
};
|
|
76
|
+
export type GridCellView = {
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
subtitle: string;
|
|
80
|
+
/** The cell content as short text: image source name or color. */
|
|
81
|
+
content: string;
|
|
82
|
+
selected: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type GridRowView = {
|
|
85
|
+
id: string | null;
|
|
86
|
+
header: string;
|
|
87
|
+
cells: GridCellView[];
|
|
88
|
+
};
|
|
89
|
+
export type ActionRowView = {
|
|
90
|
+
id: string;
|
|
91
|
+
kind: "action" | "submenu" | "section";
|
|
92
|
+
title: string;
|
|
93
|
+
shortcut: string;
|
|
94
|
+
selected: boolean;
|
|
95
|
+
};
|
|
96
|
+
export type DropdownOptionView = {
|
|
97
|
+
value: string;
|
|
98
|
+
title: string;
|
|
99
|
+
section: string;
|
|
100
|
+
current: boolean;
|
|
101
|
+
selected: boolean;
|
|
102
|
+
};
|
|
103
|
+
export type MenuRowView = {
|
|
104
|
+
id: string;
|
|
105
|
+
kind: "item" | "submenu" | "section";
|
|
106
|
+
title: string;
|
|
107
|
+
subtitle: string;
|
|
108
|
+
shortcut: string;
|
|
109
|
+
disabled: boolean;
|
|
110
|
+
selected: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type ControllerView = {
|
|
113
|
+
kind: ViewKind;
|
|
114
|
+
title: string;
|
|
115
|
+
navigation: {
|
|
116
|
+
canGoBack: boolean;
|
|
117
|
+
};
|
|
118
|
+
loading: boolean;
|
|
119
|
+
search: {
|
|
120
|
+
text: string;
|
|
121
|
+
placeholder: string;
|
|
122
|
+
};
|
|
123
|
+
rows: RowView[];
|
|
124
|
+
grid: GridRowView[] | null;
|
|
125
|
+
selectedId: string | null;
|
|
126
|
+
emptyText: string;
|
|
127
|
+
empty: {
|
|
128
|
+
title: string;
|
|
129
|
+
description: string;
|
|
130
|
+
iconLabel: string;
|
|
131
|
+
iconTint?: string;
|
|
132
|
+
} | null;
|
|
133
|
+
detail: string;
|
|
134
|
+
primary: {
|
|
135
|
+
title: string;
|
|
136
|
+
shortcut: string;
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
};
|
|
139
|
+
actions: {
|
|
140
|
+
open: boolean;
|
|
141
|
+
title: string;
|
|
142
|
+
query: string;
|
|
143
|
+
/** Titles of the submenus entered so far. */
|
|
144
|
+
breadcrumb: string[];
|
|
145
|
+
rows: ActionRowView[];
|
|
146
|
+
/** Index among the selectable rows, -1 when there are none. */
|
|
147
|
+
selectedIndex: number;
|
|
148
|
+
};
|
|
149
|
+
dropdown: {
|
|
150
|
+
label: string;
|
|
151
|
+
tooltip: string;
|
|
152
|
+
open: boolean;
|
|
153
|
+
query: string;
|
|
154
|
+
options: DropdownOptionView[];
|
|
155
|
+
selectedIndex: number;
|
|
156
|
+
} | null;
|
|
157
|
+
feedback: {
|
|
158
|
+
toast: {
|
|
159
|
+
style: string;
|
|
160
|
+
title: string;
|
|
161
|
+
message: string;
|
|
162
|
+
actions: {
|
|
163
|
+
title: string;
|
|
164
|
+
shortcut: string;
|
|
165
|
+
}[];
|
|
166
|
+
} | null;
|
|
167
|
+
/** Only while the HUD window is open. */
|
|
168
|
+
hud: {
|
|
169
|
+
title: string;
|
|
170
|
+
} | null;
|
|
171
|
+
alert: {
|
|
172
|
+
title: string;
|
|
173
|
+
message: string;
|
|
174
|
+
rememberUserChoice: boolean;
|
|
175
|
+
remember: boolean;
|
|
176
|
+
primary: {
|
|
177
|
+
title: string;
|
|
178
|
+
style: string;
|
|
179
|
+
} | null;
|
|
180
|
+
dismiss: {
|
|
181
|
+
title: string;
|
|
182
|
+
style: string;
|
|
183
|
+
} | null;
|
|
184
|
+
} | null;
|
|
185
|
+
};
|
|
186
|
+
menuBar: {
|
|
187
|
+
title: string;
|
|
188
|
+
tooltip: string;
|
|
189
|
+
loading: boolean;
|
|
190
|
+
path: string[];
|
|
191
|
+
rows: MenuRowView[];
|
|
192
|
+
selectedId: string | null;
|
|
193
|
+
} | null;
|
|
194
|
+
form: {
|
|
195
|
+
fields: FormFieldView[];
|
|
196
|
+
focusId: string | null;
|
|
197
|
+
} | null;
|
|
198
|
+
requests: {
|
|
199
|
+
quit: boolean;
|
|
200
|
+
/** The last scene asked the client to clear the search bar. */
|
|
201
|
+
clearSearch: boolean;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
export type Controller = {
|
|
205
|
+
scene(message: SceneMessage | undefined): ControllerResult;
|
|
206
|
+
input(action: ControllerInput): ControllerResult;
|
|
207
|
+
/** A delay requested by a `schedule` effect has passed. Unknown tokens are ignored. */
|
|
208
|
+
tick(token: string): ControllerResult;
|
|
209
|
+
view(): ControllerView;
|
|
210
|
+
subscribe(listener: (view: ControllerView) => void): () => void;
|
|
211
|
+
};
|
|
212
|
+
export type ControllerOptions = {
|
|
213
|
+
platform: Platform;
|
|
214
|
+
/** Overrides how long a HUD stays visible. */
|
|
215
|
+
hudDurationMs?: number;
|
|
216
|
+
/** Overrides how long success and failure toasts stay visible. */
|
|
217
|
+
toastDurationMs?: number;
|
|
218
|
+
};
|
|
219
|
+
export declare function createController(options: ControllerOptions): Controller;
|