@rb-pulse/ui 1.2.24
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/index.ts +281 -0
- package/package.json +22 -0
package/index.ts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pulse/ui — Page, groupbox, and widget API for Pulse framework scripts.
|
|
3
|
+
*
|
|
4
|
+
* Use `definePage` to declare UI tabs and `groupbox` to arrange components
|
|
5
|
+
* into columns. Widget functions (`toggle`, `slider`, `button`, etc.) bind
|
|
6
|
+
* reactive signals from `@pulse/core` to UI controls.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { defineComponent, signal, on } from '@pulse/core'
|
|
11
|
+
* import { definePage, groupbox, toggle, slider } from '@pulse/ui'
|
|
12
|
+
* import { KillAura } from '../player/KillAura'
|
|
13
|
+
* import { ReachHack } from '../player/ReachHack'
|
|
14
|
+
*
|
|
15
|
+
* // pages/1_Combat.ts
|
|
16
|
+
* export default definePage('Combat', { icon: 'swords' }, () => [
|
|
17
|
+
* groupbox('left', 'Kill Aura', { icon: 'crosshair', mount: KillAura }),
|
|
18
|
+
* groupbox('right', 'Reach', { icon: 'ruler', mount: ReachHack }),
|
|
19
|
+
* ])
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { ComponentDefinition, Signal, WidgetDef } from '@rb-pulse/core'
|
|
24
|
+
|
|
25
|
+
// ── Page ───────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
/** Options for `definePage`. */
|
|
28
|
+
export interface PageOpts {
|
|
29
|
+
/**
|
|
30
|
+
* Icon name shown in the tab bar.
|
|
31
|
+
* Required — build will error if missing.
|
|
32
|
+
* @example 'swords' | 'crosshair' | 'eye' | 'gear'
|
|
33
|
+
*/
|
|
34
|
+
icon: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Opaque page definition handle returned by `definePage`. */
|
|
38
|
+
export interface PageDefinition {
|
|
39
|
+
readonly _name: string
|
|
40
|
+
readonly _type: 'page'
|
|
41
|
+
readonly _groupboxes: GroupboxDef[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Define a top-level tab in the script UI.
|
|
46
|
+
*
|
|
47
|
+
* Each exported `definePage` call maps to one tab in the Linoria / WindUI window.
|
|
48
|
+
* Pages are sorted by their filename prefix (e.g. `1_Combat.ts` before `2_Visuals.ts`).
|
|
49
|
+
* The factory is called once on initialisation.
|
|
50
|
+
*
|
|
51
|
+
* @param name Display name shown in the tab bar (e.g. `'Combat'`)
|
|
52
|
+
* @param opts `icon` is required; controls the tab icon
|
|
53
|
+
* @param factory Returns an array of groupbox definitions to lay out in the tab
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* export default definePage('Combat', { icon: 'swords' }, () => [
|
|
57
|
+
* groupbox('left', 'Kill Aura', { icon: 'crosshair', mount: KillAura }),
|
|
58
|
+
* groupbox('right', 'Reach', { icon: 'ruler', mount: ReachHack }),
|
|
59
|
+
* ])
|
|
60
|
+
*/
|
|
61
|
+
export declare function definePage(
|
|
62
|
+
name: string,
|
|
63
|
+
opts: PageOpts,
|
|
64
|
+
factory: () => GroupboxDef[],
|
|
65
|
+
): PageDefinition
|
|
66
|
+
|
|
67
|
+
// ── Groupbox ───────────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
/** Options for `groupbox`. */
|
|
70
|
+
export interface GroupboxOpts {
|
|
71
|
+
/**
|
|
72
|
+
* Icon name shown in the groupbox header.
|
|
73
|
+
* Required — build will error if missing.
|
|
74
|
+
*/
|
|
75
|
+
icon: string
|
|
76
|
+
/**
|
|
77
|
+
* Mount a component's widgets directly into this groupbox.
|
|
78
|
+
* Equivalent to calling all the component's `return [...]` widgets inline.
|
|
79
|
+
*/
|
|
80
|
+
mount?: ComponentDefinition<any>
|
|
81
|
+
/**
|
|
82
|
+
* Separator label rendered above this groupbox (decorative divider).
|
|
83
|
+
*/
|
|
84
|
+
separator?: string
|
|
85
|
+
/**
|
|
86
|
+
* Exclude this groupbox from compat builds.
|
|
87
|
+
* Useful for features that only work on certain executors.
|
|
88
|
+
*/
|
|
89
|
+
compatExclude?: boolean
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Opaque groupbox definition handle. */
|
|
93
|
+
export interface GroupboxDef {
|
|
94
|
+
readonly _side: 'left' | 'right'
|
|
95
|
+
readonly _name: string
|
|
96
|
+
readonly _type: 'groupbox'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Declare a groupbox in a page column.
|
|
101
|
+
*
|
|
102
|
+
* Groupboxes are arranged into two columns: `'left'` and `'right'`.
|
|
103
|
+
* Multiple groupboxes on the same side stack vertically.
|
|
104
|
+
* The `mount` option embeds a `defineComponent` return value.
|
|
105
|
+
*
|
|
106
|
+
* @param side Column placement: `'left'` or `'right'`
|
|
107
|
+
* @param name Display name shown as the groupbox header
|
|
108
|
+
* @param opts `icon` required; optional `mount`, `separator`, `compatExclude`
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* groupbox('left', 'Kill Aura', { icon: 'crosshair', mount: KillAura })
|
|
112
|
+
* groupbox('right', 'Aim', {
|
|
113
|
+
* icon: 'target',
|
|
114
|
+
* mount: AimAssist,
|
|
115
|
+
* separator: 'Aim Assistance',
|
|
116
|
+
* })
|
|
117
|
+
*/
|
|
118
|
+
export declare function groupbox(
|
|
119
|
+
side: 'left' | 'right',
|
|
120
|
+
name: string,
|
|
121
|
+
opts: GroupboxOpts,
|
|
122
|
+
): GroupboxDef
|
|
123
|
+
|
|
124
|
+
// ── Widgets ────────────────────────────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
/** Options for `toggle`. */
|
|
127
|
+
export interface ToggleOpts {
|
|
128
|
+
/** Default value shown before the user interacts. */
|
|
129
|
+
default?: boolean
|
|
130
|
+
/** Tooltip text shown on hover. */
|
|
131
|
+
tooltip?: string
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Toggle widget definition — checkbox bound to a `Signal<boolean>`. */
|
|
135
|
+
export interface ToggleDef extends WidgetDef {
|
|
136
|
+
bind(signal: Signal<boolean>): this
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Toggle widget — maps to a checkbox in Linoria / WindUI.
|
|
141
|
+
*
|
|
142
|
+
* Use `.bind(signal)` to connect it to a `Signal<boolean>` from `@pulse/core`.
|
|
143
|
+
* The widget reads the signal's current value as its initial state and
|
|
144
|
+
* writes back on every user interaction.
|
|
145
|
+
*
|
|
146
|
+
* @param label Text shown next to the checkbox
|
|
147
|
+
* @param opts Optional default value and tooltip
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* const enabled = signal(false)
|
|
151
|
+
* toggle('Kill Aura').bind(enabled)
|
|
152
|
+
* toggle('Silent Aim', { default: false, tooltip: 'Requires executor support' }).bind(silent)
|
|
153
|
+
*/
|
|
154
|
+
export declare function toggle(label: string, opts?: ToggleOpts): ToggleDef
|
|
155
|
+
|
|
156
|
+
/** Options for `slider`. */
|
|
157
|
+
export interface SliderOpts {
|
|
158
|
+
/** Minimum value (inclusive). */
|
|
159
|
+
min?: number
|
|
160
|
+
/** Maximum value (inclusive). */
|
|
161
|
+
max?: number
|
|
162
|
+
/** Step size between ticks. */
|
|
163
|
+
step?: number
|
|
164
|
+
/** Default numeric value. */
|
|
165
|
+
default?: number
|
|
166
|
+
/** Unit suffix appended to the displayed value (e.g. `' ms'`, `' studs/s'`). */
|
|
167
|
+
suffix?: string
|
|
168
|
+
/** Tooltip text shown on hover. */
|
|
169
|
+
tooltip?: string
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Slider widget definition — numeric range control bound to a `Signal<number>`. */
|
|
173
|
+
export interface SliderDef extends WidgetDef {
|
|
174
|
+
bind(signal: Signal<number>): this
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Slider widget — numeric range input.
|
|
179
|
+
*
|
|
180
|
+
* @param label Text label shown above the slider
|
|
181
|
+
* @param opts `min`, `max`, `step`, `default`, `suffix`, `tooltip`
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* const range = signal(50)
|
|
185
|
+
* slider('Range', { min: 1, max: 500, suffix: ' studs' }).bind(range)
|
|
186
|
+
*
|
|
187
|
+
* const delay = signal(200)
|
|
188
|
+
* slider('Delay', { min: 0, max: 1000, step: 10, suffix: ' ms' }).bind(delay)
|
|
189
|
+
*/
|
|
190
|
+
export declare function slider(label: string, opts?: SliderOpts): SliderDef
|
|
191
|
+
|
|
192
|
+
/** Options for `dropdown`. */
|
|
193
|
+
export interface DropdownOpts {
|
|
194
|
+
/** Available choices. */
|
|
195
|
+
options: string[]
|
|
196
|
+
/** Default selected option (must be in `options`). */
|
|
197
|
+
default?: string
|
|
198
|
+
/** Tooltip text shown on hover. */
|
|
199
|
+
tooltip?: string
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Dropdown widget definition — bound to a `Signal<string>`. */
|
|
203
|
+
export interface DropdownDef extends WidgetDef {
|
|
204
|
+
bind(signal: Signal<string>): this
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Dropdown widget — selectable list of options.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* const mode = signal('Distance')
|
|
212
|
+
* dropdown('Sort mode', {
|
|
213
|
+
* options: ['Distance', 'Health', 'Name'],
|
|
214
|
+
* default: 'Distance',
|
|
215
|
+
* }).bind(mode)
|
|
216
|
+
*/
|
|
217
|
+
export declare function dropdown(label: string, opts: DropdownOpts): DropdownDef
|
|
218
|
+
|
|
219
|
+
/** Options for `button`. */
|
|
220
|
+
export interface ButtonOpts {
|
|
221
|
+
/** Tooltip text shown on hover. */
|
|
222
|
+
tooltip?: string
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Button widget definition — fires `onClick` when clicked; no signal binding. */
|
|
226
|
+
export interface ButtonDef extends WidgetDef {
|
|
227
|
+
onClick(handler: () => void): this
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Button widget — triggers a callback on click.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* button('Teleport to waypoint').onClick(() => teleport(waypoint()))
|
|
235
|
+
* button('Reset config').onClick(() => { enabled.set(false); range.set(50) })
|
|
236
|
+
*/
|
|
237
|
+
export declare function button(label: string, opts?: ButtonOpts): ButtonDef
|
|
238
|
+
|
|
239
|
+
/** Options for `keybind`. */
|
|
240
|
+
export interface KeybindOpts {
|
|
241
|
+
/** Default key. Use Roblox `Enum.KeyCode` value name, e.g. `'X'`, `'F'`. */
|
|
242
|
+
default?: string
|
|
243
|
+
/** Tooltip text shown on hover. */
|
|
244
|
+
tooltip?: string
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Keybind widget definition — bound to a `Signal<string>`. */
|
|
248
|
+
export interface KeybindDef extends WidgetDef {
|
|
249
|
+
bind(signal: Signal<string>): this
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Keybind widget — lets the user rebind a hotkey.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* const key = signal('X')
|
|
257
|
+
* keybind('Toggle key', { default: 'X' }).bind(key)
|
|
258
|
+
*/
|
|
259
|
+
export declare function keybind(label: string, opts?: KeybindOpts): KeybindDef
|
|
260
|
+
|
|
261
|
+
/** Label widget — static non-interactive text displayed in the groupbox. */
|
|
262
|
+
export interface LabelDef extends WidgetDef {}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Label widget — displays static text. No signal binding.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* label('Requires executor with drawing API')
|
|
269
|
+
*/
|
|
270
|
+
export declare function label(text: string): LabelDef
|
|
271
|
+
|
|
272
|
+
/** Paragraph widget — static multi-line text block. */
|
|
273
|
+
export interface ParagraphDef extends WidgetDef {}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Paragraph widget — displays a titled text block. No signal binding.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* paragraph('How to use', 'Enable, then aim at a player and press the hotkey.')
|
|
280
|
+
*/
|
|
281
|
+
export declare function paragraph(title: string, body: string): ParagraphDef
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rb-pulse/ui",
|
|
3
|
+
"version": "1.2.24",
|
|
4
|
+
"description": "Pulse framework — page, groupbox, and widget TypeScript API",
|
|
5
|
+
"main": "./index.ts",
|
|
6
|
+
"types": "./index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.ts",
|
|
9
|
+
"*.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"roblox",
|
|
13
|
+
"pulse",
|
|
14
|
+
"lua",
|
|
15
|
+
"typescript-to-lua",
|
|
16
|
+
"ui"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@rb-pulse/core": "1.2.24"
|
|
21
|
+
}
|
|
22
|
+
}
|