@rbxts/centurion-ui 1.0.3 → 1.0.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.
@@ -4,7 +4,6 @@ local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "servi
4
4
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
5
  local Vide = _vide
6
6
  local derive = _vide.derive
7
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
8
7
  local _components = TS.import(script, script.Parent.Parent, "components")
9
8
  local Suggestions = _components.Suggestions
10
9
  local Terminal = _components.Terminal
@@ -16,9 +15,9 @@ local _use_px = TS.import(script, script.Parent.Parent, "hooks", "use-px")
16
15
  local px = _use_px.px
17
16
  local usePx = _use_px.usePx
18
17
  local _store = TS.import(script, script.Parent.Parent, "store")
19
- local interfaceOptions = _store.interfaceOptions
20
- local interfaceVisible = _store.interfaceVisible
21
18
  local mouseOverInterface = _store.mouseOverInterface
19
+ local options = _store.options
20
+ local visible = _store.visible
22
21
  local MOUSE_INPUT_TYPES = {
23
22
  [Enum.UserInputType.MouseButton1] = true,
24
23
  [Enum.UserInputType.MouseButton2] = true,
@@ -27,8 +26,6 @@ local MOUSE_INPUT_TYPES = {
27
26
  local function CenturionApp(client)
28
27
  useClient(client)
29
28
  usePx()
30
- local options = useAtom(interfaceOptions)
31
- local visible = useAtom(interfaceVisible)
32
29
  local validKeys = derive(function()
33
30
  local _set = {}
34
31
  for _, _v in options().activationKeys do
@@ -44,7 +41,7 @@ local function CenturionApp(client)
44
41
  _condition = not gameProcessed
45
42
  end
46
43
  if _condition then
47
- interfaceVisible(not visible())
44
+ visible(not visible())
48
45
  else
49
46
  local _condition_1 = options().hideOnLostFocus
50
47
  if _condition_1 then
@@ -55,7 +52,7 @@ local function CenturionApp(client)
55
52
  end
56
53
  end
57
54
  if _condition_1 then
58
- interfaceVisible(false)
55
+ visible(false)
59
56
  end
60
57
  end
61
58
  end)
package/out/app/init.luau CHANGED
@@ -8,8 +8,8 @@ local mount = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).moun
8
8
  local DEFAULT_INTERFACE_OPTIONS = TS.import(script, script.Parent, "constants", "options").DEFAULT_INTERFACE_OPTIONS
9
9
  local DefaultPalette = TS.import(script, script.Parent, "palette").DefaultPalette
10
10
  local _store = TS.import(script, script.Parent, "store")
11
- local interfaceOptions = _store.interfaceOptions
12
- local interfaceVisible = _store.interfaceVisible
11
+ local uiOptions = _store.options
12
+ local uiVisible = _store.visible
13
13
  local CenturionApp = TS.import(script, script, "centurion-app").CenturionApp
14
14
  local CenturionUI = {}
15
15
  do
@@ -24,7 +24,7 @@ do
24
24
 
25
25
  ]]
26
26
  local function isVisible()
27
- return interfaceVisible()
27
+ return uiVisible()
28
28
  end
29
29
  _container.isVisible = isVisible
30
30
  --[[
@@ -35,7 +35,7 @@ do
35
35
 
36
36
  ]]
37
37
  local function setVisible(visible)
38
- interfaceVisible(visible)
38
+ uiVisible(visible)
39
39
  end
40
40
  _container.setVisible = setVisible
41
41
  --[[
@@ -46,17 +46,15 @@ do
46
46
 
47
47
  ]]
48
48
  local function updateOptions(options)
49
- interfaceOptions(function(prev)
50
- local _object = table.clone(DEFAULT_INTERFACE_OPTIONS)
51
- setmetatable(_object, nil)
52
- for _k, _v in prev do
53
- _object[_k] = _v
54
- end
55
- for _k, _v in options do
56
- _object[_k] = _v
57
- end
58
- return _object
59
- end)
49
+ local _object = table.clone(DEFAULT_INTERFACE_OPTIONS)
50
+ setmetatable(_object, nil)
51
+ for _k, _v in uiOptions() do
52
+ _object[_k] = _v
53
+ end
54
+ for _k, _v in options do
55
+ _object[_k] = _v
56
+ end
57
+ uiOptions(_object)
60
58
  end
61
59
  _container.updateOptions = updateOptions
62
60
  --[[
@@ -3,10 +3,9 @@ local TS = _G[script]
3
3
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
4
  local Vide = _vide
5
5
  local derive = _vide.derive
6
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
6
  local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
8
7
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
9
- local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
8
+ local options = TS.import(script, script.Parent.Parent.Parent, "store").options
10
9
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
11
10
  local Group = TS.import(script, script.Parent.Parent, "ui", "group").Group
12
11
  local Outline = TS.import(script, script.Parent.Parent, "ui", "outline").Outline
@@ -17,7 +16,6 @@ local function HistoryLine(_param)
17
16
  local size = _param.size
18
17
  local position = _param.position
19
18
  local order = _param.order
20
- local options = useAtom(interfaceOptions)
21
19
  local date = derive(function()
22
20
  local dateTime = DateTime.fromUnixTimestamp(data.sentAt):FormatLocalTime("LT", "en-us")
23
21
  local dateParts = string.split(dateTime, " ")
@@ -5,9 +5,8 @@ local Vide = _vide
5
5
  local derive = _vide.derive
6
6
  local For = _vide.For
7
7
  local read = _vide.read
8
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
9
8
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
10
- local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
9
+ local options = TS.import(script, script.Parent.Parent.Parent, "store").options
11
10
  local ScrollingFrame = TS.import(script, script.Parent.Parent, "ui", "scrolling-frame").ScrollingFrame
12
11
  local HistoryLine = TS.import(script, script.Parent, "history-line").HistoryLine
13
12
  local function HistoryList(_param)
@@ -15,7 +14,6 @@ local function HistoryList(_param)
15
14
  local size = _param.size
16
15
  local position = _param.position
17
16
  local maxHeight = _param.maxHeight
18
- local options = useAtom(interfaceOptions)
19
17
  local height = derive(function()
20
18
  return read(data).height - px(8)
21
19
  end)
@@ -1,13 +1,11 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
3
  local Vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
5
4
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
6
- local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
5
+ local options = TS.import(script, script.Parent.Parent.Parent, "store").options
7
6
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
8
7
  local Text = TS.import(script, script.Parent.Parent, "ui", "text").Text
9
8
  local function Badge(props)
10
- local options = useAtom(interfaceOptions)
11
9
  local _attributes = {
12
10
  text = props.text,
13
11
  textColor = props.textColor,
@@ -4,14 +4,13 @@ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
4
  local Vide = _vide
5
5
  local read = _vide.read
6
6
  local spring = _vide.spring
7
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
8
7
  local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
9
8
  local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
10
9
  local SUGGESTION_TITLE_TEXT_SIZE = _text.SUGGESTION_TITLE_TEXT_SIZE
11
10
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
12
11
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
13
- local interfaceOptions = _store.interfaceOptions
14
12
  local mouseOverInterface = _store.mouseOverInterface
13
+ local options = _store.options
15
14
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
16
15
  local Padding = TS.import(script, script.Parent.Parent, "ui", "padding").Padding
17
16
  local Text = TS.import(script, script.Parent.Parent, "ui", "text").Text
@@ -26,7 +25,6 @@ local function MainSuggestion(_param)
26
25
  local badgeSize = _param.badgeSize
27
26
  local errorSize = _param.errorSize
28
27
  local action = _param.action
29
- local options = useAtom(interfaceOptions)
30
28
  return Vide.jsx(Frame, {
31
29
  action = action,
32
30
  size = size,
@@ -6,12 +6,11 @@ local Vide = _vide
6
6
  local derive = _vide.derive
7
7
  local For = _vide.For
8
8
  local read = _vide.read
9
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
10
9
  local SUGGESTION_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").SUGGESTION_TEXT_SIZE
11
10
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
12
11
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
13
- local interfaceOptions = _store.interfaceOptions
14
12
  local mouseOverInterface = _store.mouseOverInterface
13
+ local options = _store.options
15
14
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
16
15
  local Group = TS.import(script, script.Parent.Parent, "ui", "group").Group
17
16
  local Padding = TS.import(script, script.Parent.Parent, "ui", "padding").Padding
@@ -22,7 +21,6 @@ local function SuggestionList(_param)
22
21
  local suggestion = _param.suggestion
23
22
  local currentText = _param.currentText
24
23
  local size = _param.size
25
- local options = useAtom(interfaceOptions)
26
24
  local suggestions = derive(function()
27
25
  local _result = read(suggestion)
28
26
  if _result ~= nil then
@@ -7,7 +7,6 @@ local cleanup = _vide.cleanup
7
7
  local derive = _vide.derive
8
8
  local source = _vide.source
9
9
  local spring = _vide.spring
10
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
11
10
  local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
12
11
  local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
13
12
  local SUGGESTION_TITLE_TEXT_SIZE = _text.SUGGESTION_TITLE_TEXT_SIZE
@@ -16,16 +15,13 @@ local useTextBounds = TS.import(script, script.Parent.Parent.Parent, "hooks", "u
16
15
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
17
16
  local currentSuggestion = _store.currentSuggestion
18
17
  local currentTextPart = _store.currentTextPart
19
- local interfaceOptions = _store.interfaceOptions
18
+ local options = _store.options
20
19
  local Group = TS.import(script, script.Parent.Parent, "ui", "group").Group
21
20
  local MainSuggestion = TS.import(script, script.Parent, "main-suggestion").MainSuggestion
22
21
  local SuggestionList = TS.import(script, script.Parent, "suggestion-list").SuggestionList
23
22
  local MAX_SUGGESTION_WIDTH = 180
24
23
  local PADDING = 8
25
24
  local function Suggestions()
26
- local options = useAtom(interfaceOptions)
27
- local textPart = useAtom(currentTextPart)
28
- local suggestion = useAtom(currentSuggestion)
29
25
  local suggestionRef = source()
30
26
  local offset = function(boundsState)
31
27
  return function()
@@ -35,7 +31,7 @@ local function Suggestions()
35
31
  end
36
32
  local titleBounds = useTextBounds({
37
33
  text = function()
38
- local _result = suggestion()
34
+ local _result = currentSuggestion()
39
35
  if _result ~= nil then
40
36
  _result = _result.title
41
37
  end
@@ -50,7 +46,7 @@ local function Suggestions()
50
46
  })
51
47
  local descriptionBounds = useTextBounds({
52
48
  text = function()
53
- local _result = suggestion()
49
+ local _result = currentSuggestion()
54
50
  if _result ~= nil then
55
51
  _result = _result.description
56
52
  end
@@ -68,15 +64,15 @@ local function Suggestions()
68
64
  })
69
65
  local typeBadgeBounds = useTextBounds({
70
66
  text = function()
71
- local currentSuggestion = suggestion()
72
- local _result = currentSuggestion
67
+ local suggestion = currentSuggestion()
68
+ local _result = suggestion
73
69
  if _result ~= nil then
74
70
  _result = _result.type
75
71
  end
76
72
  if _result == "command" then
77
73
  return nil
78
74
  end
79
- local _result_1 = currentSuggestion
75
+ local _result_1 = suggestion
80
76
  if _result_1 ~= nil then
81
77
  _result_1 = _result_1.dataType
82
78
  end
@@ -91,15 +87,15 @@ local function Suggestions()
91
87
  })
92
88
  local errorBounds = useTextBounds({
93
89
  text = function()
94
- local current = suggestion()
95
- local _result = current
90
+ local suggestion = currentSuggestion()
91
+ local _result = suggestion
96
92
  if _result ~= nil then
97
93
  _result = _result.type
98
94
  end
99
95
  if _result == "command" then
100
96
  return nil
101
97
  end
102
- local _result_1 = current
98
+ local _result_1 = suggestion
103
99
  if _result_1 ~= nil then
104
100
  _result_1 = _result_1.error
105
101
  end
@@ -117,7 +113,7 @@ local function Suggestions()
117
113
  cleanup(listBoundsParams)
118
114
  local listBounds = derive(function()
119
115
  local width = 0
120
- local _result = suggestion()
116
+ local _result = currentSuggestion()
121
117
  if _result ~= nil then
122
118
  _result = _result.others
123
119
  end
@@ -154,8 +150,8 @@ local function Suggestions()
154
150
  return Vide.jsx(Group, {
155
151
  size = UDim2.fromScale(1, 1),
156
152
  }, Vide.jsx(MainSuggestion, {
157
- suggestion = suggestion,
158
- currentText = textPart,
153
+ suggestion = currentSuggestion,
154
+ currentText = currentTextPart,
159
155
  size = spring(windowSize, 0.2),
160
156
  titleSize = offset(titleBounds),
161
157
  descriptionSize = offset(descriptionBounds),
@@ -163,8 +159,8 @@ local function Suggestions()
163
159
  errorSize = offset(errorBounds),
164
160
  action = suggestionRef,
165
161
  }), Vide.jsx(SuggestionList, {
166
- suggestion = suggestion,
167
- currentText = textPart,
162
+ suggestion = currentSuggestion,
163
+ currentText = currentTextPart,
168
164
  size = spring(function()
169
165
  return UDim2.fromOffset(windowSize().X.Offset, listBounds().Y)
170
166
  end, 0.3),
@@ -11,7 +11,7 @@ export interface ListArgument {
11
11
  kind: "list";
12
12
  options: ReadonlyDeep<ArgumentOptions>;
13
13
  type: ListArgumentType<unknown>;
14
- input: string[];
14
+ input?: string[];
15
15
  }
16
16
  export type Argument = SingleArgument | ListArgument;
17
17
  export declare function getArgumentSuggestion(arg: Argument, textPart?: string): {
@@ -69,7 +69,7 @@ local function getArgumentSuggestion(arg, textPart)
69
69
  else
70
70
  local _result_2 = arg.type.suggestions
71
71
  if _result_2 ~= nil then
72
- _result_2 = _result_2(arg.input, Players.LocalPlayer)
72
+ _result_2 = _result_2(arg.input or {}, Players.LocalPlayer)
73
73
  end
74
74
  _result_1 = _result_2
75
75
  end
@@ -80,20 +80,10 @@ local function getArgumentSuggestion(arg, textPart)
80
80
  end
81
81
  end
82
82
  local errorText
83
- if not arg.type.expensive then
83
+ local input = arg.input
84
+ if not arg.type.expensive and input ~= nil then
84
85
  local success, err = pcall(function()
85
- local _result_2
86
- if singleArg then
87
- local _type = arg.type
88
- local _condition = arg.input
89
- if _condition == nil then
90
- _condition = ""
91
- end
92
- _result_2 = _type.transform(_condition, Players.LocalPlayer)
93
- else
94
- _result_2 = arg.type.transform(arg.input, Players.LocalPlayer)
95
- end
96
- local transformResult = _result_2
86
+ local transformResult = if singleArg then arg.type.transform(input, Players.LocalPlayer) else arg.type.transform(input, Players.LocalPlayer)
97
87
  if transformResult.ok then
98
88
  return nil
99
89
  end
@@ -132,6 +122,7 @@ local function getArgumentSuggestion(arg, textPart)
132
122
  _object.error = errorText
133
123
  return _object
134
124
  end
125
+ local getCommandName
135
126
  local function getCommandSuggestion(registry, parentPath, text)
136
127
  local paths = if parentPath ~= nil then registry:getChildPaths(parentPath) else registry:getRootPaths()
137
128
  if #paths == 0 then
@@ -153,41 +144,60 @@ local function getCommandSuggestion(registry, parentPath, text)
153
144
  return nil
154
145
  end
155
146
  local firstPath = paths[firstMatch[1] + 1]
156
- local _result = registry:getCommand(firstPath)
157
- if _result ~= nil then
158
- _result = _result.options
159
- end
160
- local _condition = _result
161
- if _condition == nil then
162
- local _result_1 = registry:getGroup(firstPath)
163
- if _result_1 ~= nil then
164
- _result_1 = _result_1.options
147
+ local command = registry:getCommand(firstPath)
148
+ if command ~= nil then
149
+ local _object = {
150
+ type = "command",
151
+ title = getCommandName(command.options, firstPath:tail()),
152
+ description = command.options.description,
153
+ }
154
+ local _left = "others"
155
+ -- ▼ ReadonlyArray.map ▼
156
+ local _newValue_1 = table.create(#sortedPaths)
157
+ local _callback_1 = function(_param)
158
+ local str = _param[2]
159
+ return str
165
160
  end
166
- _condition = _result_1
167
- end
168
- local mainData = _condition
169
- if mainData == nil then
170
- return nil
161
+ for _k, _v in sortedPaths do
162
+ _newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths)
163
+ end
164
+ -- ▲ ReadonlyArray.map ▲
165
+ _object[_left] = _newValue_1
166
+ _object.shortcuts = (command.options).shortcuts
167
+ return _object
168
+ end
169
+ local group = registry:getGroup(firstPath)
170
+ if group ~= nil then
171
+ local _object = {
172
+ type = "command",
173
+ title = group.options.name,
174
+ description = group.options.description,
175
+ }
176
+ local _left = "others"
177
+ -- ▼ ReadonlyArray.map ▼
178
+ local _newValue_1 = table.create(#sortedPaths)
179
+ local _callback_1 = function(_param)
180
+ local str = _param[2]
181
+ return str
182
+ end
183
+ for _k, _v in sortedPaths do
184
+ _newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths)
185
+ end
186
+ -- ▲ ReadonlyArray.map ▲
187
+ _object[_left] = _newValue_1
188
+ return _object
171
189
  end
172
- local _object = {
173
- type = "command",
174
- title = mainData.name,
175
- }
176
- local _left = "others"
177
- -- ▼ ReadonlyArray.map ▼
178
- local _newValue_1 = table.create(#sortedPaths)
179
- local _callback_1 = function(_param)
180
- local str = _param[2]
181
- return str
190
+ end
191
+ function getCommandName(options, input)
192
+ if input == string.lower(options.name) then
193
+ return options.name
182
194
  end
183
- for _k, _v in sortedPaths do
184
- _newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths)
195
+ for _, alias in options.aliases or {} do
196
+ if input == string.lower(alias) then
197
+ return alias
198
+ end
185
199
  end
186
- -- ▲ ReadonlyArray.map ▲
187
- _object[_left] = _newValue_1
188
- _object.description = mainData.description
189
- _object.shortcuts = mainData.shortcuts
190
- return _object
200
+ return input
191
201
  end
192
202
  return {
193
203
  getArgumentSuggestion = getArgumentSuggestion,
@@ -1,5 +1,5 @@
1
1
  import { BaseRegistry } from "@rbxts/centurion";
2
2
  import { Suggestion } from "../../../types";
3
- export declare function completeCommand(registry: BaseRegistry, text: string, suggestion: string): string;
3
+ export declare function completeCommand(registry: BaseRegistry, text: string, textParts: string[], suggestion: string): string;
4
4
  export declare function completeArgument(text: string, suggestion: string, commandArgCount: number): string;
5
- export declare function getSuggestedText(registry: BaseRegistry, text: string, suggestion?: Suggestion): string;
5
+ export declare function getSuggestedText(registry: BaseRegistry, text: string, textParts: string[], atNextPart: boolean, suggestion?: Suggestion): string;
@@ -1,12 +1,10 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
3
  local _store = TS.import(script, script.Parent.Parent.Parent.Parent, "store")
4
- local atNextPart = _store.atNextPart
5
4
  local commandArgIndex = _store.commandArgIndex
6
5
  local currentCommandPath = _store.currentCommandPath
7
6
  local currentTextPart = _store.currentTextPart
8
7
  local terminalArgIndex = _store.terminalArgIndex
9
- local terminalTextParts = _store.terminalTextParts
10
8
  local _command = TS.import(script, script.Parent.Parent, "command")
11
9
  local formatPartsAsPath = _command.formatPartsAsPath
12
10
  local getArgumentNames = _command.getArgumentNames
@@ -28,8 +26,7 @@ local function replaceTextPart(text, ...)
28
26
  result ..= table.concat(suggestions, " ")
29
27
  return result
30
28
  end
31
- local function completeCommand(registry, text, suggestion)
32
- local textParts = terminalTextParts()
29
+ local function completeCommand(registry, text, textParts, suggestion)
33
30
  local atNextPart = string.sub(text, -1) == " "
34
31
  local _array = {}
35
32
  local _length = #_array
@@ -76,13 +73,12 @@ local function completeArgument(text, suggestion, commandArgCount)
76
73
  end
77
74
  return result
78
75
  end
79
- local function getSuggestedText(registry, text, suggestion)
76
+ local function getSuggestedText(registry, text, textParts, atNextPart, suggestion)
80
77
  if suggestion == nil then
81
78
  return ""
82
79
  end
83
80
  local suggestionText
84
- local parts = terminalTextParts()
85
- if #parts == 0 or suggestion.type == "command" then
81
+ if #textParts == 0 or suggestion.type == "command" then
86
82
  suggestionText = suggestion.title
87
83
  else
88
84
  local command = currentCommandPath()
@@ -90,7 +86,7 @@ local function getSuggestedText(registry, text, suggestion)
90
86
  if command == nil or argIndex == nil then
91
87
  return ""
92
88
  end
93
- if atNextPart() and argIndex == commandArgIndex() then
89
+ if atNextPart and argIndex == commandArgIndex() then
94
90
  suggestionText = suggestion.title
95
91
  elseif not (#suggestion.others == 0) then
96
92
  suggestionText = suggestion.others[1]
@@ -6,6 +6,8 @@ interface TerminalTextFieldProps {
6
6
  backgroundTransparency?: Derivable<number>;
7
7
  onTextChange?: (text: string) => void;
8
8
  onSubmit?: (text: string) => void;
9
+ textParts: () => string[];
10
+ atNextPart: () => boolean;
9
11
  }
10
- export declare function TerminalTextField({ anchor, size, position, backgroundTransparency, onTextChange, onSubmit, }: TerminalTextFieldProps): Vide.Node;
12
+ export declare function TerminalTextField({ anchor, size, position, backgroundTransparency, onTextChange, onSubmit, textParts, atNextPart, }: TerminalTextFieldProps): Vide.Node;
11
13
  export {};
@@ -1,21 +1,19 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
- local subscribe = TS.import(script, TS.getModule(script, "@rbxts", "Charm")).subscribe
4
3
  local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "services")).UserInputService
5
4
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
6
5
  local Vide = _vide
7
- local cleanup = _vide.cleanup
6
+ local effect = _vide.effect
8
7
  local source = _vide.source
9
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
10
8
  local useClient = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-client").useClient
11
9
  local useEvent = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-event").useEvent
12
10
  local px = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-px").px
13
11
  local _store = TS.import(script, script.Parent.Parent.Parent.Parent, "store")
14
12
  local currentCommandPath = _store.currentCommandPath
15
13
  local currentSuggestion = _store.currentSuggestion
16
- local interfaceOptions = _store.interfaceOptions
17
- local interfaceVisible = _store.interfaceVisible
14
+ local options = _store.options
18
15
  local terminalTextValid = _store.terminalTextValid
16
+ local visible = _store.visible
19
17
  local Frame = TS.import(script, script.Parent.Parent.Parent, "ui", "frame").Frame
20
18
  local Padding = TS.import(script, script.Parent.Parent.Parent, "ui", "padding").Padding
21
19
  local Text = TS.import(script, script.Parent.Parent.Parent, "ui", "text").Text
@@ -32,17 +30,17 @@ local function TerminalTextField(_param)
32
30
  local backgroundTransparency = _param.backgroundTransparency
33
31
  local onTextChange = _param.onTextChange
34
32
  local onSubmit = _param.onSubmit
33
+ local textParts = _param.textParts
34
+ local atNextPart = _param.atNextPart
35
35
  local client = useClient()
36
- local options = useAtom(interfaceOptions)
37
- local valid = useAtom(terminalTextValid)
38
36
  local ref = source()
39
37
  local commandHistory = source({})
40
38
  local commandHistoryIndex = source(nil)
41
39
  local suggestionText = source("")
42
40
  local currentTextValue = ""
43
41
  -- Focus text field when terminal becomes visible
44
- local visibleConnection = subscribe(interfaceVisible, function(visible)
45
- if visible then
42
+ effect(function()
43
+ if visible() then
46
44
  local _result = ref()
47
45
  if _result ~= nil then
48
46
  _result:CaptureFocus()
@@ -54,7 +52,6 @@ local function TerminalTextField(_param)
54
52
  end
55
53
  end
56
54
  end)
57
- cleanup(visibleConnection)
58
55
  local setText = function(text)
59
56
  local textBox = ref()
60
57
  if textBox == nil then
@@ -90,7 +87,7 @@ local function TerminalTextField(_param)
90
87
  setText(history[newIndex + 1])
91
88
  commandHistoryIndex(newIndex)
92
89
  end
93
- local suggestionConnection = subscribe(currentSuggestion, function(suggestion)
90
+ effect(function()
94
91
  local _exp = client.registry
95
92
  local _result = ref()
96
93
  if _result ~= nil then
@@ -100,9 +97,8 @@ local function TerminalTextField(_param)
100
97
  if _condition == nil then
101
98
  _condition = ""
102
99
  end
103
- suggestionText(getSuggestedText(_exp, _condition, suggestion))
100
+ suggestionText(getSuggestedText(_exp, _condition, textParts(), atNextPart(), currentSuggestion()))
104
101
  end)
105
- cleanup(suggestionConnection)
106
102
  useEvent(UserInputService.InputBegan, function(input)
107
103
  local textBox = ref()
108
104
  local _condition = textBox == nil
@@ -133,7 +129,7 @@ local function TerminalTextField(_param)
133
129
  end
134
130
  local currentText = textBox.Text
135
131
  if commandPath == nil then
136
- setText(completeCommand(client.registry, textBox.Text, suggestion.title))
132
+ setText(completeCommand(client.registry, textBox.Text, textParts(), suggestion.title))
137
133
  return nil
138
134
  end
139
135
  local _result = client.registry:getCommand(commandPath)
@@ -180,7 +176,7 @@ local function TerminalTextField(_param)
180
176
  return px(TEXT_SIZE)
181
177
  end,
182
178
  textColor = function()
183
- return if valid() then options().palette.success else options().palette.error
179
+ return if terminalTextValid() then options().palette.success else options().palette.error
184
180
  end,
185
181
  textXAlignment = "Left",
186
182
  placeholderText = "Enter command...",
@@ -8,23 +8,23 @@ local Vide = _vide
8
8
  local derive = _vide.derive
9
9
  local source = _vide.source
10
10
  local spring = _vide.spring
11
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
12
11
  local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
13
12
  local useClient = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-client").useClient
14
13
  local useHistory = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-history").useHistory
15
14
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
16
15
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
17
- local atNextPart = _store.atNextPart
18
16
  local commandArgIndex = _store.commandArgIndex
19
17
  local currentCommandPath = _store.currentCommandPath
20
18
  local currentSuggestion = _store.currentSuggestion
21
19
  local currentTextPart = _store.currentTextPart
22
- local interfaceOptions = _store.interfaceOptions
23
20
  local mouseOverInterface = _store.mouseOverInterface
21
+ local options = _store.options
24
22
  local terminalArgIndex = _store.terminalArgIndex
25
23
  local terminalText = _store.terminalText
26
- local terminalTextParts = _store.terminalTextParts
27
24
  local terminalTextValid = _store.terminalTextValid
25
+ local _string = TS.import(script, script.Parent.Parent.Parent, "utils", "string")
26
+ local isQuoteEnded = _string.isQuoteEnded
27
+ local isQuoteStarted = _string.isQuoteStarted
28
28
  local HistoryList = TS.import(script, script.Parent.Parent, "history").HistoryList
29
29
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
30
30
  local Padding = TS.import(script, script.Parent.Parent, "ui", "padding").Padding
@@ -40,9 +40,20 @@ local TEXT_FIELD_HEIGHT = 40
40
40
  local TRAILING_SPACE_PATTERN = "(%s+)$"
41
41
  local function Terminal()
42
42
  local client = useClient()
43
- local options = useAtom(interfaceOptions)
44
43
  local missingArgs = source({})
45
44
  local history = useHistory()
45
+ local terminalTextParts = derive(function()
46
+ return splitString(terminalText(), " ", true)
47
+ end)
48
+ local atNextPart = derive(function()
49
+ local parts = terminalTextParts()
50
+ local textPart = parts[#parts]
51
+ local quoted = false
52
+ if textPart ~= nil then
53
+ quoted = isQuoteStarted(textPart) and not isQuoteEnded(textPart)
54
+ end
55
+ return string.sub(terminalText(), -1) == " " and not quoted
56
+ end)
46
57
  local terminalHeight = derive(function()
47
58
  local padding = px.ceil(TEXT_FIELD_HEIGHT + 16)
48
59
  if #history().lines == 0 then
@@ -103,6 +114,8 @@ local function Terminal()
103
114
  end
104
115
  return _condition
105
116
  end,
117
+ textParts = terminalTextParts,
118
+ atNextPart = atNextPart,
106
119
  onTextChange = function(text)
107
120
  terminalText(text)
108
121
  terminalTextValid(false)
@@ -236,7 +249,7 @@ local function Terminal()
236
249
  kind = "list",
237
250
  options = currentArg,
238
251
  type = argType,
239
- input = textParts,
252
+ input = if #textParts > 1 then textParts else nil,
240
253
  }, argTextPart)
241
254
  end
242
255
  currentTextPart(argTextPart)
@@ -3,10 +3,8 @@ local TS = _G[script]
3
3
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
4
  local Vide = _vide
5
5
  local read = _vide.read
6
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
- local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
6
+ local options = TS.import(script, script.Parent.Parent.Parent, "store").options
8
7
  local function TextField(props)
9
- local options = useAtom(interfaceOptions)
10
8
  local _attributes = {
11
9
  PlaceholderText = props.placeholderText,
12
10
  PlaceholderColor3 = props.placeholderColor,
@@ -3,11 +3,9 @@ local TS = _G[script]
3
3
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
4
  local Vide = _vide
5
5
  local read = _vide.read
6
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
6
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
8
- local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
7
+ local options = TS.import(script, script.Parent.Parent.Parent, "store").options
9
8
  local function Text(props)
10
- local options = useAtom(interfaceOptions)
11
9
  local _attributes = {
12
10
  FontFace = function()
13
11
  return read(props.font) or options().font.regular
@@ -5,15 +5,13 @@ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
5
  local cleanup = _vide.cleanup
6
6
  local derive = _vide.derive
7
7
  local source = _vide.source
8
- local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
9
8
  local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
10
- local interfaceOptions = TS.import(script, script.Parent.Parent, "store").interfaceOptions
9
+ local options = TS.import(script, script.Parent.Parent, "store").options
11
10
  local useClient = TS.import(script, script.Parent, "use-client").useClient
12
11
  local useEvent = TS.import(script, script.Parent, "use-event").useEvent
13
12
  local px = TS.import(script, script.Parent, "use-px").px
14
13
  local function useHistory()
15
14
  local client = useClient()
16
- local options = useAtom(interfaceOptions)
17
15
  local history = source(client.dispatcher:getHistory())
18
16
  useEvent(client.dispatcher.historyUpdated, function(entries)
19
17
  local _array = {}
package/out/store.d.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import { ImmutableRegistryPath } from "@rbxts/centurion";
2
2
  import { Suggestion } from "./types";
3
- export declare const interfaceVisible: import("@rbxts/charm").Atom<boolean>;
4
- export declare const interfaceOptions: import("@rbxts/charm").Atom<import("./types").InterfaceOptions>;
5
- export declare const mouseOverInterface: import("@rbxts/charm").Atom<boolean>;
6
- export declare const currentCommandPath: import("@rbxts/charm").Atom<ImmutableRegistryPath | undefined>;
7
- export declare const commandArgIndex: import("@rbxts/charm").Atom<number | undefined>;
8
- export declare const terminalArgIndex: import("@rbxts/charm").Atom<number | undefined>;
9
- export declare const currentSuggestion: import("@rbxts/charm").Atom<Suggestion | undefined>;
10
- export declare const terminalText: import("@rbxts/charm").Atom<string>;
11
- export declare const terminalTextParts: import("@rbxts/charm").Selector<string[]>;
12
- export declare const atNextPart: import("@rbxts/charm").Selector<boolean>;
13
- export declare const terminalTextValid: import("@rbxts/charm").Atom<boolean>;
14
- export declare const currentTextPart: import("@rbxts/charm").Atom<string | undefined>;
3
+ export declare const visible: import("@rbxts/vide").Source<boolean>;
4
+ export declare const options: import("@rbxts/vide").Source<import("./types").InterfaceOptions>;
5
+ export declare const mouseOverInterface: import("@rbxts/vide").Source<boolean>;
6
+ export declare const currentCommandPath: import("@rbxts/vide").Source<ImmutableRegistryPath | undefined>;
7
+ export declare const commandArgIndex: import("@rbxts/vide").Source<number | undefined>;
8
+ export declare const terminalArgIndex: import("@rbxts/vide").Source<number | undefined>;
9
+ export declare const currentSuggestion: import("@rbxts/vide").Source<Suggestion | undefined>;
10
+ export declare const terminalText: import("@rbxts/vide").Source<string>;
11
+ export declare const terminalTextValid: import("@rbxts/vide").Source<boolean>;
12
+ export declare const currentTextPart: import("@rbxts/vide").Source<string | undefined>;
package/out/store.luau CHANGED
@@ -1,46 +1,26 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
- local splitString = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.string).splitString
4
- local _charm = TS.import(script, TS.getModule(script, "@rbxts", "Charm"))
5
- local atom = _charm.atom
6
- local computed = _charm.computed
3
+ local source = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).source
7
4
  local DEFAULT_INTERFACE_OPTIONS = TS.import(script, script.Parent, "constants", "options").DEFAULT_INTERFACE_OPTIONS
8
- local _string = TS.import(script, script.Parent, "utils", "string")
9
- local isQuoteEnded = _string.isQuoteEnded
10
- local isQuoteStarted = _string.isQuoteStarted
11
- local interfaceVisible = atom(false)
12
- local interfaceOptions = atom(DEFAULT_INTERFACE_OPTIONS)
13
- local mouseOverInterface = atom(false)
14
- local currentCommandPath = atom(nil)
15
- local commandArgIndex = atom(nil)
16
- local terminalArgIndex = atom(nil)
17
- local currentSuggestion = atom(nil)
18
- local terminalText = atom("")
19
- local terminalTextParts = computed(function()
20
- return splitString(terminalText(), " ", true)
21
- end)
22
- local atNextPart = computed(function()
23
- local parts = terminalTextParts()
24
- local textPart = parts[#parts]
25
- local quoted = false
26
- if textPart ~= nil then
27
- quoted = isQuoteStarted(textPart) and not isQuoteEnded(textPart)
28
- end
29
- return string.sub(terminalText(), -1) == " " and not quoted
30
- end)
31
- local terminalTextValid = atom(false)
32
- local currentTextPart = atom(nil)
5
+ local visible = source(false)
6
+ local options = source(DEFAULT_INTERFACE_OPTIONS)
7
+ local mouseOverInterface = source(false)
8
+ local currentCommandPath = source(nil)
9
+ local commandArgIndex = source(nil)
10
+ local terminalArgIndex = source(nil)
11
+ local currentSuggestion = source(nil)
12
+ local terminalText = source("")
13
+ local terminalTextValid = source(false)
14
+ local currentTextPart = source(nil)
33
15
  return {
34
- interfaceVisible = interfaceVisible,
35
- interfaceOptions = interfaceOptions,
16
+ visible = visible,
17
+ options = options,
36
18
  mouseOverInterface = mouseOverInterface,
37
19
  currentCommandPath = currentCommandPath,
38
20
  commandArgIndex = commandArgIndex,
39
21
  terminalArgIndex = terminalArgIndex,
40
22
  currentSuggestion = currentSuggestion,
41
23
  terminalText = terminalText,
42
- terminalTextParts = terminalTextParts,
43
- atNextPart = atNextPart,
44
24
  terminalTextValid = terminalTextValid,
45
25
  currentTextPart = currentTextPart,
46
26
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rbxts/centurion-ui",
3
3
  "description": "Terminal UI for the Centurion command framework",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "author": "paradoxuum",
6
6
  "license": "MIT",
7
7
  "main": "out/init.lua",
@@ -40,11 +40,9 @@
40
40
  "typescript": "5.5.3"
41
41
  },
42
42
  "dependencies": {
43
- "@rbxts/charm": "^0.8.1",
44
43
  "@rbxts/services": "^1.5.5",
45
44
  "@rbxts/set-timeout": "^1.1.2",
46
- "@rbxts/vide": "^0.5.0",
47
- "@rbxts/vide-charm": "^0.1.1"
45
+ "@rbxts/vide": "^0.5.0"
48
46
  },
49
47
  "peerDependencies": {
50
48
  "@rbxts/centurion": "^1.0.1"