@rbxts/centurion-ui 1.0.7 → 2.0.0-rc.1
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.md +60 -15
- package/centurion.luau +10 -0
- package/package.json +13 -23
- package/src/analyse/cursor.luau +25 -0
- package/src/analyse/highlight.luau +91 -0
- package/src/analyse/init.luau +318 -0
- package/src/analyse/leventine.luau +298 -0
- package/src/analyse/match.luau +39 -0
- package/src/analyse/suggest.luau +41 -0
- package/src/app/header.luau +128 -0
- package/src/app/history.luau +258 -0
- package/src/app/init.luau +699 -0
- package/src/app/suggestions.luau +419 -0
- package/src/button.luau +13 -0
- package/src/components/background.luau +37 -0
- package/src/components/container.luau +33 -0
- package/src/components/corner.luau +11 -0
- package/src/components/divider.luau +28 -0
- package/src/components/flex.luau +108 -0
- package/src/components/gap.luau +25 -0
- package/src/components/image.luau +33 -0
- package/src/components/padding.luau +59 -0
- package/src/components/stroke.luau +20 -0
- package/src/components/text.luau +57 -0
- package/src/components/textbox.luau +186 -0
- package/src/fade.luau +23 -0
- package/src/init.luau +142 -0
- package/src/input.luau +16 -0
- package/src/px.luau +68 -0
- package/src/rich.luau +14 -0
- package/src/state.luau +33 -0
- package/src/theme.luau +70 -0
- package/src/ts/index.d.ts +60 -0
- package/src/ts/init.luau +5 -0
- package/src/types.luau +85 -0
- package/vide/init.luau +8 -0
- package/vide/src/action.luau +25 -0
- package/vide/src/apply.luau +162 -0
- package/vide/src/batch.luau +23 -0
- package/vide/src/branch.luau +40 -0
- package/vide/src/changed.luau +18 -0
- package/vide/src/cleanup.luau +43 -0
- package/vide/src/context.luau +74 -0
- package/vide/src/create.luau +107 -0
- package/vide/src/defaults.luau +113 -0
- package/vide/src/derive.luau +18 -0
- package/vide/src/effect.luau +12 -0
- package/vide/src/flags.luau +12 -0
- package/vide/src/graph.luau +321 -0
- package/vide/src/implicit_effect.luau +125 -0
- package/vide/src/indexes.luau +121 -0
- package/vide/src/init.luau +10 -0
- package/vide/src/lib.luau +120 -0
- package/vide/src/mount.luau +11 -0
- package/vide/src/read.luau +5 -0
- package/vide/src/root.luau +35 -0
- package/vide/src/show.luau +36 -0
- package/vide/src/source.luau +31 -0
- package/vide/src/spring.luau +328 -0
- package/vide/src/switch.luau +114 -0
- package/vide/src/timeout.luau +27 -0
- package/vide/src/untrack.luau +25 -0
- package/vide/src/values.luau +131 -0
- package/out/app/centurion-app.d.ts +0 -3
- package/out/app/centurion-app.luau +0 -86
- package/out/app/index.d.ts +0 -32
- package/out/app/init.luau +0 -105
- package/out/components/history/history-line.d.ts +0 -9
- package/out/components/history/history-line.luau +0 -88
- package/out/components/history/history-list.d.ts +0 -11
- package/out/components/history/history-list.luau +0 -67
- package/out/components/history/index.d.ts +0 -1
- package/out/components/history/init.luau +0 -7
- package/out/components/index.d.ts +0 -2
- package/out/components/init.luau +0 -10
- package/out/components/suggestions/badge.d.ts +0 -16
- package/out/components/suggestions/badge.luau +0 -40
- package/out/components/suggestions/index.d.ts +0 -1
- package/out/components/suggestions/init.luau +0 -7
- package/out/components/suggestions/main-suggestion.d.ts +0 -9
- package/out/components/suggestions/main-suggestion.luau +0 -232
- package/out/components/suggestions/suggestion-list.d.ts +0 -8
- package/out/components/suggestions/suggestion-list.luau +0 -96
- package/out/components/suggestions/suggestions.d.ts +0 -2
- package/out/components/suggestions/suggestions.luau +0 -64
- package/out/components/suggestions/types.d.ts +0 -6
- package/out/components/suggestions/types.luau +0 -2
- package/out/components/suggestions/util.d.ts +0 -1
- package/out/components/suggestions/util.luau +0 -22
- package/out/components/terminal/command.d.ts +0 -6
- package/out/components/terminal/command.luau +0 -74
- package/out/components/terminal/index.d.ts +0 -1
- package/out/components/terminal/init.luau +0 -7
- package/out/components/terminal/suggestion.d.ts +0 -26
- package/out/components/terminal/suggestion.luau +0 -205
- package/out/components/terminal/terminal-text-field/index.d.ts +0 -1
- package/out/components/terminal/terminal-text-field/init.luau +0 -7
- package/out/components/terminal/terminal-text-field/suggestion.d.ts +0 -5
- package/out/components/terminal/terminal-text-field/suggestion.luau +0 -124
- package/out/components/terminal/terminal-text-field/terminal-text-field.d.ts +0 -13
- package/out/components/terminal/terminal-text-field/terminal-text-field.luau +0 -273
- package/out/components/terminal/terminal.d.ts +0 -2
- package/out/components/terminal/terminal.luau +0 -304
- package/out/components/ui/frame.d.ts +0 -17
- package/out/components/ui/frame.luau +0 -32
- package/out/components/ui/group.d.ts +0 -15
- package/out/components/ui/group.luau +0 -29
- package/out/components/ui/layer.d.ts +0 -8
- package/out/components/ui/layer.luau +0 -26
- package/out/components/ui/outline.d.ts +0 -15
- package/out/components/ui/outline.luau +0 -116
- package/out/components/ui/padding.d.ts +0 -10
- package/out/components/ui/padding.luau +0 -19
- package/out/components/ui/scrolling-frame.d.ts +0 -14
- package/out/components/ui/scrolling-frame.luau +0 -44
- package/out/components/ui/text-field.d.ts +0 -12
- package/out/components/ui/text-field.luau +0 -60
- package/out/components/ui/text.d.ts +0 -17
- package/out/components/ui/text.luau +0 -61
- package/out/constants/options.d.ts +0 -2
- package/out/constants/options.luau +0 -27
- package/out/constants/text.d.ts +0 -3
- package/out/constants/text.luau +0 -9
- package/out/constants/util.d.ts +0 -1
- package/out/constants/util.luau +0 -7
- package/out/hooks/use-client.d.ts +0 -2
- package/out/hooks/use-client.luau +0 -17
- package/out/hooks/use-event.d.ts +0 -14
- package/out/hooks/use-event.luau +0 -58
- package/out/hooks/use-px.d.ts +0 -19
- package/out/hooks/use-px.luau +0 -78
- package/out/index.d.ts +0 -2
- package/out/init.luau +0 -10
- package/out/palette.d.ts +0 -47
- package/out/palette.luau +0 -42
- package/out/store.d.ts +0 -12
- package/out/store.luau +0 -26
- package/out/types.d.ts +0 -44
- package/out/types.luau +0 -2
- package/out/utils/string.d.ts +0 -5
- package/out/utils/string.luau +0 -25
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "services")).UserInputService
|
|
4
|
-
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
5
|
-
local Vide = _vide
|
|
6
|
-
local effect = _vide.effect
|
|
7
|
-
local source = _vide.source
|
|
8
|
-
local useClient = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-client").useClient
|
|
9
|
-
local useEvent = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-event").useEvent
|
|
10
|
-
local px = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-px").px
|
|
11
|
-
local _store = TS.import(script, script.Parent.Parent.Parent.Parent, "store")
|
|
12
|
-
local currentCommandPath = _store.currentCommandPath
|
|
13
|
-
local currentSuggestion = _store.currentSuggestion
|
|
14
|
-
local options = _store.options
|
|
15
|
-
local terminalTextValid = _store.terminalTextValid
|
|
16
|
-
local visible = _store.visible
|
|
17
|
-
local Frame = TS.import(script, script.Parent.Parent.Parent, "ui", "frame").Frame
|
|
18
|
-
local Padding = TS.import(script, script.Parent.Parent.Parent, "ui", "padding").Padding
|
|
19
|
-
local Text = TS.import(script, script.Parent.Parent.Parent, "ui", "text").Text
|
|
20
|
-
local TextField = TS.import(script, script.Parent.Parent.Parent, "ui", "text-field").TextField
|
|
21
|
-
local _suggestion = TS.import(script, script.Parent, "suggestion")
|
|
22
|
-
local completeArgument = _suggestion.completeArgument
|
|
23
|
-
local completeCommand = _suggestion.completeCommand
|
|
24
|
-
local getSuggestedText = _suggestion.getSuggestedText
|
|
25
|
-
local TEXT_SIZE = 22
|
|
26
|
-
local function TerminalTextField(_param)
|
|
27
|
-
local anchor = _param.anchor
|
|
28
|
-
local size = _param.size
|
|
29
|
-
local position = _param.position
|
|
30
|
-
local backgroundTransparency = _param.backgroundTransparency
|
|
31
|
-
local onTextChange = _param.onTextChange
|
|
32
|
-
local onSubmit = _param.onSubmit
|
|
33
|
-
local textParts = _param.textParts
|
|
34
|
-
local atNextPart = _param.atNextPart
|
|
35
|
-
local client = useClient()
|
|
36
|
-
local ref = source()
|
|
37
|
-
local commandHistory = source({})
|
|
38
|
-
local commandHistoryIndex = source(nil)
|
|
39
|
-
local suggestionText = source("")
|
|
40
|
-
local currentTextValue = ""
|
|
41
|
-
-- Focus text field when terminal becomes visible
|
|
42
|
-
effect(function()
|
|
43
|
-
if visible() then
|
|
44
|
-
local _result = ref()
|
|
45
|
-
if _result ~= nil then
|
|
46
|
-
_result:CaptureFocus()
|
|
47
|
-
end
|
|
48
|
-
else
|
|
49
|
-
local _result = ref()
|
|
50
|
-
if _result ~= nil then
|
|
51
|
-
_result:ReleaseFocus()
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end)
|
|
55
|
-
local setText = function(text)
|
|
56
|
-
local textBox = ref()
|
|
57
|
-
if textBox == nil then
|
|
58
|
-
return nil
|
|
59
|
-
end
|
|
60
|
-
textBox.Text = text
|
|
61
|
-
textBox.CursorPosition = #text + 1
|
|
62
|
-
end
|
|
63
|
-
local traverseHistory = function(up)
|
|
64
|
-
local history = commandHistory()
|
|
65
|
-
if #history == 0 then
|
|
66
|
-
return nil
|
|
67
|
-
end
|
|
68
|
-
local historyIndex = commandHistoryIndex()
|
|
69
|
-
if not up and historyIndex == nil then
|
|
70
|
-
return nil
|
|
71
|
-
end
|
|
72
|
-
local textBox = ref()
|
|
73
|
-
if textBox == nil then
|
|
74
|
-
return nil
|
|
75
|
-
end
|
|
76
|
-
local lastIndex = #history - 1
|
|
77
|
-
if not up and historyIndex == lastIndex then
|
|
78
|
-
setText("")
|
|
79
|
-
commandHistoryIndex(nil)
|
|
80
|
-
return nil
|
|
81
|
-
end
|
|
82
|
-
local _condition = historyIndex
|
|
83
|
-
if _condition == nil then
|
|
84
|
-
_condition = #history
|
|
85
|
-
end
|
|
86
|
-
local newIndex = math.clamp(_condition + (if up then -1 else 1), 0, lastIndex)
|
|
87
|
-
setText(history[newIndex + 1])
|
|
88
|
-
commandHistoryIndex(newIndex)
|
|
89
|
-
end
|
|
90
|
-
effect(function()
|
|
91
|
-
local _exp = client.registry
|
|
92
|
-
local _result = ref()
|
|
93
|
-
if _result ~= nil then
|
|
94
|
-
_result = _result.Text
|
|
95
|
-
end
|
|
96
|
-
local _condition = _result
|
|
97
|
-
if _condition == nil then
|
|
98
|
-
_condition = ""
|
|
99
|
-
end
|
|
100
|
-
suggestionText(getSuggestedText(_exp, _condition, textParts(), atNextPart(), currentSuggestion()))
|
|
101
|
-
end)
|
|
102
|
-
useEvent(UserInputService.InputBegan, function(input)
|
|
103
|
-
local textBox = ref()
|
|
104
|
-
local _condition = textBox == nil
|
|
105
|
-
if not _condition then
|
|
106
|
-
local _result = textBox
|
|
107
|
-
if _result ~= nil then
|
|
108
|
-
_result = _result:IsFocused()
|
|
109
|
-
end
|
|
110
|
-
_condition = not _result
|
|
111
|
-
end
|
|
112
|
-
if _condition then
|
|
113
|
-
return nil
|
|
114
|
-
end
|
|
115
|
-
-- Handle history traversal
|
|
116
|
-
if input.KeyCode == Enum.KeyCode.Up then
|
|
117
|
-
traverseHistory(true)
|
|
118
|
-
elseif input.KeyCode == Enum.KeyCode.Down then
|
|
119
|
-
traverseHistory(false)
|
|
120
|
-
end
|
|
121
|
-
if input.KeyCode ~= Enum.KeyCode.Tab then
|
|
122
|
-
return nil
|
|
123
|
-
end
|
|
124
|
-
-- Handle autocompletion
|
|
125
|
-
local commandPath = currentCommandPath()
|
|
126
|
-
local suggestion = currentSuggestion()
|
|
127
|
-
if suggestion == nil then
|
|
128
|
-
return nil
|
|
129
|
-
end
|
|
130
|
-
local currentText = textBox.Text
|
|
131
|
-
if commandPath == nil then
|
|
132
|
-
setText(completeCommand(client.registry, textBox.Text, textParts(), suggestion.title))
|
|
133
|
-
return nil
|
|
134
|
-
end
|
|
135
|
-
local _result = client.registry:getCommand(commandPath)
|
|
136
|
-
if _result ~= nil then
|
|
137
|
-
_result = _result.options.arguments
|
|
138
|
-
if _result ~= nil then
|
|
139
|
-
_result = #_result
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
local _condition_1 = _result
|
|
143
|
-
if _condition_1 == nil then
|
|
144
|
-
_condition_1 = 0
|
|
145
|
-
end
|
|
146
|
-
local argCount = _condition_1
|
|
147
|
-
if suggestion.type == "command" and argCount ~= 0 then
|
|
148
|
-
setText(`{currentText} `)
|
|
149
|
-
return nil
|
|
150
|
-
end
|
|
151
|
-
if #suggestion.others == 0 then
|
|
152
|
-
setText(currentText)
|
|
153
|
-
return nil
|
|
154
|
-
end
|
|
155
|
-
setText(completeArgument(currentText, suggestion.others[1], argCount))
|
|
156
|
-
end)
|
|
157
|
-
return Vide.jsx(Frame, {
|
|
158
|
-
anchor = anchor,
|
|
159
|
-
size = size,
|
|
160
|
-
position = position,
|
|
161
|
-
backgroundColor = function()
|
|
162
|
-
return options().palette.surface
|
|
163
|
-
end,
|
|
164
|
-
backgroundTransparency = backgroundTransparency,
|
|
165
|
-
cornerRadius = function()
|
|
166
|
-
return UDim.new(0, px(4))
|
|
167
|
-
end,
|
|
168
|
-
}, Vide.jsx(Padding, {
|
|
169
|
-
all = function()
|
|
170
|
-
return UDim.new(0, px(8))
|
|
171
|
-
end,
|
|
172
|
-
}), Vide.jsx(TextField, {
|
|
173
|
-
action = ref,
|
|
174
|
-
size = UDim2.fromScale(1, 1),
|
|
175
|
-
textSize = function()
|
|
176
|
-
return px(TEXT_SIZE)
|
|
177
|
-
end,
|
|
178
|
-
textColor = function()
|
|
179
|
-
return if terminalTextValid() then options().palette.success else options().palette.error
|
|
180
|
-
end,
|
|
181
|
-
textXAlignment = "Left",
|
|
182
|
-
placeholderText = "Enter command...",
|
|
183
|
-
placeholderColor = function()
|
|
184
|
-
return options().palette.subtext
|
|
185
|
-
end,
|
|
186
|
-
font = function()
|
|
187
|
-
return options().font.medium
|
|
188
|
-
end,
|
|
189
|
-
clearTextOnFocus = false,
|
|
190
|
-
native = {
|
|
191
|
-
FocusLost = function(enterPressed)
|
|
192
|
-
if not enterPressed then
|
|
193
|
-
return nil
|
|
194
|
-
end
|
|
195
|
-
local textBox = ref()
|
|
196
|
-
if textBox == nil then
|
|
197
|
-
return nil
|
|
198
|
-
end
|
|
199
|
-
local currentText = textBox.Text
|
|
200
|
-
local history = commandHistory()
|
|
201
|
-
if currentText ~= "" and (#history == 0 or history[#history] ~= currentText) then
|
|
202
|
-
local _array = {}
|
|
203
|
-
local _length = #_array
|
|
204
|
-
local _historyLength = #history
|
|
205
|
-
table.move(history, 1, _historyLength, _length + 1, _array)
|
|
206
|
-
_length += _historyLength
|
|
207
|
-
_array[_length + 1] = textBox.Text
|
|
208
|
-
commandHistory(_array)
|
|
209
|
-
end
|
|
210
|
-
commandHistoryIndex(nil)
|
|
211
|
-
local _result = onSubmit
|
|
212
|
-
if _result ~= nil then
|
|
213
|
-
_result(currentText)
|
|
214
|
-
end
|
|
215
|
-
textBox.Text = ""
|
|
216
|
-
textBox:CaptureFocus()
|
|
217
|
-
end,
|
|
218
|
-
TextChanged = function(currentText)
|
|
219
|
-
local textBox = ref()
|
|
220
|
-
if textBox == nil then
|
|
221
|
-
return nil
|
|
222
|
-
end
|
|
223
|
-
local historyIndex = commandHistoryIndex()
|
|
224
|
-
if historyIndex ~= nil and currentText ~= commandHistory()[historyIndex + 1] then
|
|
225
|
-
commandHistoryIndex(nil)
|
|
226
|
-
end
|
|
227
|
-
-- Remove line breaks
|
|
228
|
-
local value = currentText
|
|
229
|
-
if (string.match(value, "[\n\r]")) ~= nil then
|
|
230
|
-
value = (string.gsub(value, "[\n\r]", ""))
|
|
231
|
-
end
|
|
232
|
-
-- Remove all tabs from text input - we use these for autocompletion
|
|
233
|
-
if (string.match(value, "\t")) ~= nil then
|
|
234
|
-
value = (string.gsub(value, "\t", ""))
|
|
235
|
-
end
|
|
236
|
-
textBox.Text = value
|
|
237
|
-
if currentTextValue == value then
|
|
238
|
-
return nil
|
|
239
|
-
end
|
|
240
|
-
currentTextValue = value
|
|
241
|
-
local _result = onTextChange
|
|
242
|
-
if _result ~= nil then
|
|
243
|
-
_result(value)
|
|
244
|
-
end
|
|
245
|
-
end,
|
|
246
|
-
ReturnPressedFromOnScreenKeyboard = function()
|
|
247
|
-
local textBox = ref()
|
|
248
|
-
if textBox == nil then
|
|
249
|
-
return nil
|
|
250
|
-
end
|
|
251
|
-
task.wait()
|
|
252
|
-
textBox:ReleaseFocus(true)
|
|
253
|
-
end,
|
|
254
|
-
},
|
|
255
|
-
zIndex = 2,
|
|
256
|
-
}), Vide.jsx(Text, {
|
|
257
|
-
size = UDim2.fromScale(1, 1),
|
|
258
|
-
text = suggestionText,
|
|
259
|
-
textColor = function()
|
|
260
|
-
return options().palette.subtext
|
|
261
|
-
end,
|
|
262
|
-
textSize = function()
|
|
263
|
-
return px(TEXT_SIZE)
|
|
264
|
-
end,
|
|
265
|
-
textXAlignment = "Left",
|
|
266
|
-
font = function()
|
|
267
|
-
return options().font.medium
|
|
268
|
-
end,
|
|
269
|
-
}))
|
|
270
|
-
end
|
|
271
|
-
return {
|
|
272
|
-
TerminalTextField = TerminalTextField,
|
|
273
|
-
}
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local RegistryPath = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out).RegistryPath
|
|
4
|
-
local ArrayUtil = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.data).ArrayUtil
|
|
5
|
-
local splitString = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.string).splitString
|
|
6
|
-
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
7
|
-
local Vide = _vide
|
|
8
|
-
local derive = _vide.derive
|
|
9
|
-
local source = _vide.source
|
|
10
|
-
local spring = _vide.spring
|
|
11
|
-
local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
|
|
12
|
-
local useClient = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-client").useClient
|
|
13
|
-
local useEvent = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-event").useEvent
|
|
14
|
-
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
15
|
-
local _store = TS.import(script, script.Parent.Parent.Parent, "store")
|
|
16
|
-
local commandArgIndex = _store.commandArgIndex
|
|
17
|
-
local currentCommandPath = _store.currentCommandPath
|
|
18
|
-
local currentSuggestion = _store.currentSuggestion
|
|
19
|
-
local currentTextPart = _store.currentTextPart
|
|
20
|
-
local mouseOverInterface = _store.mouseOverInterface
|
|
21
|
-
local options = _store.options
|
|
22
|
-
local terminalArgIndex = _store.terminalArgIndex
|
|
23
|
-
local terminalText = _store.terminalText
|
|
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
|
-
local HistoryList = TS.import(script, script.Parent.Parent, "history").HistoryList
|
|
29
|
-
local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
|
|
30
|
-
local Padding = TS.import(script, script.Parent.Parent, "ui", "padding").Padding
|
|
31
|
-
local _command = TS.import(script, script.Parent, "command")
|
|
32
|
-
local getMissingArgs = _command.getMissingArgs
|
|
33
|
-
local getValidPath = _command.getValidPath
|
|
34
|
-
local _suggestion = TS.import(script, script.Parent, "suggestion")
|
|
35
|
-
local getArgumentSuggestion = _suggestion.getArgumentSuggestion
|
|
36
|
-
local getCommandSuggestion = _suggestion.getCommandSuggestion
|
|
37
|
-
local TerminalTextField = TS.import(script, script.Parent, "terminal-text-field").TerminalTextField
|
|
38
|
-
local MAX_HEIGHT = HISTORY_TEXT_SIZE * 10
|
|
39
|
-
local TEXT_FIELD_HEIGHT = 40
|
|
40
|
-
local TRAILING_SPACE_PATTERN = "(%s+)$"
|
|
41
|
-
local function Terminal()
|
|
42
|
-
local client = useClient()
|
|
43
|
-
local missingArgs = source({})
|
|
44
|
-
local history = source(client.dispatcher:getHistory())
|
|
45
|
-
local historyHeight = source(0)
|
|
46
|
-
useEvent(client.dispatcher.historyUpdated, function(entries)
|
|
47
|
-
local _array = {}
|
|
48
|
-
local _length = #_array
|
|
49
|
-
table.move(entries, 1, #entries, _length + 1, _array)
|
|
50
|
-
return history(_array)
|
|
51
|
-
end)
|
|
52
|
-
local maxHeight = derive(function()
|
|
53
|
-
return px(MAX_HEIGHT)
|
|
54
|
-
end)
|
|
55
|
-
local scrollingEnabled = derive(function()
|
|
56
|
-
return historyHeight() > maxHeight()
|
|
57
|
-
end)
|
|
58
|
-
local terminalTextParts = derive(function()
|
|
59
|
-
return splitString(terminalText(), " ", true)
|
|
60
|
-
end)
|
|
61
|
-
local atNextPart = derive(function()
|
|
62
|
-
local parts = terminalTextParts()
|
|
63
|
-
local textPart = parts[#parts]
|
|
64
|
-
local quoted = false
|
|
65
|
-
if textPart ~= nil then
|
|
66
|
-
quoted = isQuoteStarted(textPart) and not isQuoteEnded(textPart)
|
|
67
|
-
end
|
|
68
|
-
return string.sub(terminalText(), -1) == " " and not quoted
|
|
69
|
-
end)
|
|
70
|
-
local terminalHeight = derive(function()
|
|
71
|
-
local padding = px.ceil(TEXT_FIELD_HEIGHT + 16)
|
|
72
|
-
if #history() == 0 then
|
|
73
|
-
return padding
|
|
74
|
-
end
|
|
75
|
-
local clampedHeight = if scrollingEnabled() then maxHeight() else historyHeight()
|
|
76
|
-
return math.ceil(padding + clampedHeight + px(8))
|
|
77
|
-
end)
|
|
78
|
-
return Vide.jsx(Frame, {
|
|
79
|
-
size = spring(function()
|
|
80
|
-
return UDim2.new(1, 0, 0, terminalHeight())
|
|
81
|
-
end, 0.2),
|
|
82
|
-
backgroundColor = function()
|
|
83
|
-
return options().palette.background
|
|
84
|
-
end,
|
|
85
|
-
backgroundTransparency = function()
|
|
86
|
-
local _condition = options().backgroundTransparency
|
|
87
|
-
if _condition == nil then
|
|
88
|
-
_condition = 0
|
|
89
|
-
end
|
|
90
|
-
return _condition
|
|
91
|
-
end,
|
|
92
|
-
cornerRadius = function()
|
|
93
|
-
return UDim.new(0, px(8))
|
|
94
|
-
end,
|
|
95
|
-
native = {
|
|
96
|
-
MouseEnter = function()
|
|
97
|
-
return mouseOverInterface(true)
|
|
98
|
-
end,
|
|
99
|
-
MouseLeave = function()
|
|
100
|
-
return mouseOverInterface(false)
|
|
101
|
-
end,
|
|
102
|
-
},
|
|
103
|
-
}, Vide.jsx(Padding, {
|
|
104
|
-
all = function()
|
|
105
|
-
return UDim.new(0, px(8))
|
|
106
|
-
end,
|
|
107
|
-
}), Vide.jsx(HistoryList, {
|
|
108
|
-
size = function()
|
|
109
|
-
return UDim2.new(1, 0, 1, -px(TEXT_FIELD_HEIGHT + 8))
|
|
110
|
-
end,
|
|
111
|
-
entries = history,
|
|
112
|
-
scrollingEnabled = scrollingEnabled,
|
|
113
|
-
onContentSizeChanged = function(size)
|
|
114
|
-
historyHeight(size.Y)
|
|
115
|
-
end,
|
|
116
|
-
}), Vide.jsx(TerminalTextField, {
|
|
117
|
-
anchor = Vector2.new(0, 1),
|
|
118
|
-
size = function()
|
|
119
|
-
return UDim2.new(1, 0, 0, px(TEXT_FIELD_HEIGHT))
|
|
120
|
-
end,
|
|
121
|
-
position = UDim2.fromScale(0, 1),
|
|
122
|
-
backgroundTransparency = function()
|
|
123
|
-
local _condition = options().backgroundTransparency
|
|
124
|
-
if _condition == nil then
|
|
125
|
-
_condition = 0
|
|
126
|
-
end
|
|
127
|
-
return _condition
|
|
128
|
-
end,
|
|
129
|
-
textParts = terminalTextParts,
|
|
130
|
-
atNextPart = atNextPart,
|
|
131
|
-
onTextChange = function(text)
|
|
132
|
-
terminalText(text)
|
|
133
|
-
terminalTextValid(false)
|
|
134
|
-
missingArgs({})
|
|
135
|
-
local parts = terminalTextParts()
|
|
136
|
-
if #parts == 0 then
|
|
137
|
-
currentCommandPath(nil)
|
|
138
|
-
currentSuggestion(nil)
|
|
139
|
-
terminalArgIndex(nil)
|
|
140
|
-
return nil
|
|
141
|
-
end
|
|
142
|
-
-- If the text ends in a space, we want to count that as having traversed
|
|
143
|
-
-- to the next "part" of the text.
|
|
144
|
-
local endsInSpace = string.sub(text, -1) == " "
|
|
145
|
-
local path = getValidPath(client.registry, parts)
|
|
146
|
-
local command = if path ~= nil then client.registry:getCommand(path) else nil
|
|
147
|
-
if command ~= nil then
|
|
148
|
-
-- Check for missing arguments
|
|
149
|
-
local missing = getMissingArgs(command, parts)
|
|
150
|
-
local _result = command.options.arguments
|
|
151
|
-
if _result ~= nil then
|
|
152
|
-
_result = #_result == 0
|
|
153
|
-
end
|
|
154
|
-
local _condition = _result
|
|
155
|
-
if _condition == nil then
|
|
156
|
-
_condition = true
|
|
157
|
-
end
|
|
158
|
-
local noArgs = _condition
|
|
159
|
-
currentCommandPath(path)
|
|
160
|
-
missingArgs(missing)
|
|
161
|
-
terminalTextValid(noArgs or #missing == 0 or (endsInSpace and #missing == 1))
|
|
162
|
-
else
|
|
163
|
-
currentCommandPath(nil)
|
|
164
|
-
terminalTextValid(false)
|
|
165
|
-
end
|
|
166
|
-
local textPart = parts[#parts]
|
|
167
|
-
local atNext = atNextPart()
|
|
168
|
-
if atNext then
|
|
169
|
-
textPart = nil
|
|
170
|
-
elseif textPart ~= nil then
|
|
171
|
-
local _condition = (string.match(text, TRAILING_SPACE_PATTERN))
|
|
172
|
-
if _condition == nil then
|
|
173
|
-
_condition = ""
|
|
174
|
-
end
|
|
175
|
-
local spaces = _condition
|
|
176
|
-
textPart ..= tostring(spaces)
|
|
177
|
-
end
|
|
178
|
-
local argIndex = if path ~= nil then #parts - path:size() - (if atNext then 0 else 1) else -1
|
|
179
|
-
terminalArgIndex(argIndex)
|
|
180
|
-
if command == nil or argIndex == -1 then
|
|
181
|
-
-- Get command suggestions
|
|
182
|
-
local parentPath = if not (#parts == 0) then RegistryPath.new(ArrayUtil.slice(parts, 0, #parts - (if atNext then 0 else 1))) else nil
|
|
183
|
-
currentTextPart(textPart)
|
|
184
|
-
local _exp = client.registry
|
|
185
|
-
local _result = parentPath
|
|
186
|
-
if _result ~= nil then
|
|
187
|
-
_result = _result:isEmpty()
|
|
188
|
-
end
|
|
189
|
-
currentSuggestion(getCommandSuggestion(_exp, if not _result then parentPath else nil, textPart))
|
|
190
|
-
return nil
|
|
191
|
-
end
|
|
192
|
-
-- Handle arguments
|
|
193
|
-
local args = command.options.arguments
|
|
194
|
-
if args == nil then
|
|
195
|
-
currentTextPart(nil)
|
|
196
|
-
currentSuggestion(nil)
|
|
197
|
-
commandArgIndex(nil)
|
|
198
|
-
return nil
|
|
199
|
-
end
|
|
200
|
-
local index = -1
|
|
201
|
-
local currentArg
|
|
202
|
-
local endIndex = -1
|
|
203
|
-
for i = 0, argIndex do
|
|
204
|
-
if endIndex == nil or i <= endIndex then
|
|
205
|
-
continue
|
|
206
|
-
end
|
|
207
|
-
index += 1
|
|
208
|
-
if index >= #args then
|
|
209
|
-
currentArg = nil
|
|
210
|
-
break
|
|
211
|
-
end
|
|
212
|
-
currentArg = args[index + 1]
|
|
213
|
-
local _condition = currentArg.numArgs
|
|
214
|
-
if _condition == nil then
|
|
215
|
-
_condition = 1
|
|
216
|
-
end
|
|
217
|
-
local numArgs = _condition
|
|
218
|
-
endIndex = if numArgs ~= "rest" then i + (numArgs - 1) else nil
|
|
219
|
-
end
|
|
220
|
-
local _registry = client.registry
|
|
221
|
-
local _result = currentArg
|
|
222
|
-
if _result ~= nil then
|
|
223
|
-
_result = _result.type
|
|
224
|
-
end
|
|
225
|
-
local _condition = _result
|
|
226
|
-
if _condition == nil then
|
|
227
|
-
_condition = ""
|
|
228
|
-
end
|
|
229
|
-
local argType = _registry:getType(_condition)
|
|
230
|
-
if currentArg == nil or argType == nil then
|
|
231
|
-
currentSuggestion(nil)
|
|
232
|
-
currentTextPart(nil)
|
|
233
|
-
terminalArgIndex(nil)
|
|
234
|
-
commandArgIndex(nil)
|
|
235
|
-
return nil
|
|
236
|
-
end
|
|
237
|
-
commandArgIndex(index)
|
|
238
|
-
local argTextPart
|
|
239
|
-
local suggestion
|
|
240
|
-
if argType.kind == "single" then
|
|
241
|
-
argTextPart = textPart
|
|
242
|
-
suggestion = getArgumentSuggestion({
|
|
243
|
-
kind = "single",
|
|
244
|
-
options = currentArg,
|
|
245
|
-
type = argType,
|
|
246
|
-
input = argTextPart,
|
|
247
|
-
}, argTextPart)
|
|
248
|
-
else
|
|
249
|
-
local _condition_1 = textPart
|
|
250
|
-
if _condition_1 == nil then
|
|
251
|
-
_condition_1 = ""
|
|
252
|
-
end
|
|
253
|
-
local textParts = splitString(_condition_1, ",", true)
|
|
254
|
-
local lastText = if not (#textParts == 0) then textParts[#textParts] else nil
|
|
255
|
-
local _result_1 = textPart
|
|
256
|
-
if _result_1 ~= nil then
|
|
257
|
-
_result_1 = string.sub(_result_1, -1)
|
|
258
|
-
end
|
|
259
|
-
argTextPart = if _result_1 ~= "," then lastText else nil
|
|
260
|
-
suggestion = getArgumentSuggestion({
|
|
261
|
-
kind = "list",
|
|
262
|
-
options = currentArg,
|
|
263
|
-
type = argType,
|
|
264
|
-
input = if #textParts > 1 then textParts else nil,
|
|
265
|
-
}, argTextPart)
|
|
266
|
-
end
|
|
267
|
-
currentTextPart(argTextPart)
|
|
268
|
-
currentSuggestion(suggestion)
|
|
269
|
-
local _result_1 = suggestion
|
|
270
|
-
if _result_1 ~= nil then
|
|
271
|
-
_result_1 = _result_1.error
|
|
272
|
-
end
|
|
273
|
-
if _result_1 ~= nil then
|
|
274
|
-
terminalTextValid(false)
|
|
275
|
-
end
|
|
276
|
-
end,
|
|
277
|
-
onSubmit = function()
|
|
278
|
-
local commandPath = currentCommandPath()
|
|
279
|
-
local command = if commandPath ~= nil then client.registry:getCommand(commandPath) else nil
|
|
280
|
-
if commandPath == nil or command == nil then
|
|
281
|
-
client.dispatcher:addHistoryEntry({
|
|
282
|
-
success = false,
|
|
283
|
-
text = "Command not found.",
|
|
284
|
-
sentAt = os.time(),
|
|
285
|
-
})
|
|
286
|
-
return nil
|
|
287
|
-
end
|
|
288
|
-
local missing = missingArgs()
|
|
289
|
-
if not (#missing == 0) then
|
|
290
|
-
client.dispatcher:addHistoryEntry({
|
|
291
|
-
success = false,
|
|
292
|
-
text = `Missing arguments: {table.concat(missing, ", ")}`,
|
|
293
|
-
sentAt = os.time(),
|
|
294
|
-
})
|
|
295
|
-
return nil
|
|
296
|
-
end
|
|
297
|
-
local args = ArrayUtil.slice(splitString(terminalText(), " "), commandPath:size())
|
|
298
|
-
client.dispatcher:run(commandPath, args)
|
|
299
|
-
end,
|
|
300
|
-
}))
|
|
301
|
-
end
|
|
302
|
-
return {
|
|
303
|
-
Terminal = Terminal,
|
|
304
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Vide, { ActionAttributes, Derivable, InferEnumNames, InstanceAttributes } from "@rbxts/vide";
|
|
2
|
-
export interface FrameProps<T extends Instance = Frame> extends ActionAttributes<T> {
|
|
3
|
-
size?: Derivable<UDim2>;
|
|
4
|
-
position?: Derivable<UDim2>;
|
|
5
|
-
anchor?: Derivable<Vector2>;
|
|
6
|
-
rotation?: Derivable<number>;
|
|
7
|
-
backgroundColor?: Derivable<Color3>;
|
|
8
|
-
backgroundTransparency?: Derivable<number>;
|
|
9
|
-
clipsDescendants?: Derivable<boolean>;
|
|
10
|
-
visible?: Derivable<boolean>;
|
|
11
|
-
zIndex?: Derivable<number>;
|
|
12
|
-
layoutOrder?: Derivable<number>;
|
|
13
|
-
cornerRadius?: Derivable<UDim>;
|
|
14
|
-
automaticSize?: InferEnumNames<Enum.AutomaticSize>;
|
|
15
|
-
native?: InstanceAttributes<T>;
|
|
16
|
-
}
|
|
17
|
-
export declare function Frame(props: FrameProps): Vide.Node;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local Vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
4
|
-
local function Frame(props)
|
|
5
|
-
local _attributes = {
|
|
6
|
-
AutomaticSize = props.automaticSize,
|
|
7
|
-
Size = props.size,
|
|
8
|
-
Position = props.position,
|
|
9
|
-
AnchorPoint = props.anchor,
|
|
10
|
-
Rotation = props.rotation,
|
|
11
|
-
BackgroundColor3 = props.backgroundColor,
|
|
12
|
-
BackgroundTransparency = props.backgroundTransparency,
|
|
13
|
-
ClipsDescendants = props.clipsDescendants,
|
|
14
|
-
Visible = props.visible,
|
|
15
|
-
ZIndex = props.zIndex,
|
|
16
|
-
LayoutOrder = props.layoutOrder,
|
|
17
|
-
action = props.action,
|
|
18
|
-
BorderSizePixel = 0,
|
|
19
|
-
}
|
|
20
|
-
local _attribute = props.native
|
|
21
|
-
if _attribute then
|
|
22
|
-
for _k, _v in _attribute do
|
|
23
|
-
_attributes[_k] = _v
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
return Vide.jsx("frame", _attributes, props.cornerRadius and Vide.jsx("uicorner", {
|
|
27
|
-
CornerRadius = props.cornerRadius,
|
|
28
|
-
}), props.children)
|
|
29
|
-
end
|
|
30
|
-
return {
|
|
31
|
-
Frame = Frame,
|
|
32
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import Vide, { Derivable } from "@rbxts/vide";
|
|
2
|
-
import { FrameProps } from "./frame";
|
|
3
|
-
interface GroupProps extends Omit<FrameProps, "backgroundTransparency" | "backgroundColor"> {
|
|
4
|
-
name?: Derivable<string>;
|
|
5
|
-
anchor?: Derivable<Vector2>;
|
|
6
|
-
position?: Derivable<UDim2>;
|
|
7
|
-
size?: Derivable<UDim2>;
|
|
8
|
-
rotation?: Derivable<number>;
|
|
9
|
-
clipsDescendants?: Derivable<boolean>;
|
|
10
|
-
layoutOrder?: Derivable<number>;
|
|
11
|
-
visible?: Derivable<boolean>;
|
|
12
|
-
zIndex?: Derivable<number>;
|
|
13
|
-
}
|
|
14
|
-
export declare function Group(props: GroupProps): Vide.Node;
|
|
15
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local Vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
4
|
-
local function Group(props)
|
|
5
|
-
local _attributes = {
|
|
6
|
-
AutomaticSize = props.automaticSize,
|
|
7
|
-
AnchorPoint = props.anchor,
|
|
8
|
-
Position = props.position,
|
|
9
|
-
Size = props.size or UDim2.fromScale(1, 1),
|
|
10
|
-
Rotation = props.rotation,
|
|
11
|
-
BackgroundTransparency = 1,
|
|
12
|
-
ClipsDescendants = props.clipsDescendants,
|
|
13
|
-
Visible = props.visible,
|
|
14
|
-
ZIndex = props.zIndex,
|
|
15
|
-
LayoutOrder = props.layoutOrder,
|
|
16
|
-
action = props.action,
|
|
17
|
-
BorderSizePixel = 0,
|
|
18
|
-
}
|
|
19
|
-
local _attribute = props.native
|
|
20
|
-
if _attribute then
|
|
21
|
-
for _k, _v in _attribute do
|
|
22
|
-
_attributes[_k] = _v
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
return Vide.jsx("frame", _attributes, props.children)
|
|
26
|
-
end
|
|
27
|
-
return {
|
|
28
|
-
Group = Group,
|
|
29
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import Vide, { Derivable } from "@rbxts/vide";
|
|
2
|
-
interface LayerProps extends Vide.PropsWithChildren {
|
|
3
|
-
name?: Derivable<string>;
|
|
4
|
-
visible?: Derivable<boolean>;
|
|
5
|
-
displayOrder?: Derivable<number>;
|
|
6
|
-
}
|
|
7
|
-
export declare function Layer({ name, visible, displayOrder, children }: LayerProps): Vide.Node;
|
|
8
|
-
export {};
|