@rbxts/centurion-ui 1.0.0 → 1.0.2
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/out/components/terminal/suggestion.luau +26 -31
- package/out/components/terminal/terminal-text-field/suggestion.luau +4 -4
- package/out/components/terminal/terminal-text-field/terminal-text-field.luau +0 -1
- package/out/components/terminal/terminal.luau +24 -28
- package/out/store.d.ts +1 -0
- package/out/store.luau +13 -0
- package/out/utils/string.d.ts +5 -0
- package/out/utils/string.luau +25 -0
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local Players = TS.import(script, TS.getModule(script, "@rbxts", "services")).Players
|
|
4
|
-
local
|
|
5
|
-
local
|
|
6
|
-
|
|
7
|
-
end
|
|
4
|
+
local _string = TS.import(script, script.Parent.Parent.Parent, "utils", "string")
|
|
5
|
+
local containsSpace = _string.containsSpace
|
|
6
|
+
local getQuoteChar = _string.getQuoteChar
|
|
8
7
|
local function getMatches(strings, text)
|
|
9
8
|
if text == nil then
|
|
10
9
|
table.sort(strings)
|
|
11
10
|
-- ▼ ReadonlyArray.map ▼
|
|
12
11
|
local _newValue = table.create(#strings)
|
|
13
12
|
local _callback = function(str, i)
|
|
14
|
-
|
|
13
|
+
local formatted = if containsSpace(str) then `"{str}"` else str
|
|
14
|
+
return { i, formatted, #formatted }
|
|
15
15
|
end
|
|
16
16
|
for _k, _v in strings do
|
|
17
17
|
_newValue[_k] = _callback(_v, _k - 1, strings)
|
|
@@ -21,39 +21,35 @@ local function getMatches(strings, text)
|
|
|
21
21
|
end
|
|
22
22
|
local textLower = string.lower(text)
|
|
23
23
|
local textEndIndex = #text
|
|
24
|
-
|
|
25
|
-
local
|
|
26
|
-
local
|
|
24
|
+
local quoteChar = getQuoteChar(text)
|
|
25
|
+
local quoted = quoteChar ~= nil
|
|
26
|
+
local results = {}
|
|
27
|
+
for i = 0, #strings - 1 do
|
|
28
|
+
local str = strings[i + 1]
|
|
29
|
+
if quoted then
|
|
30
|
+
str = `{quoteChar}{str}{quoteChar}`
|
|
31
|
+
elseif containsSpace(str) then
|
|
32
|
+
str = `"{str}"`
|
|
33
|
+
end
|
|
27
34
|
local part = string.sub(string.lower(str), 0, textEndIndex)
|
|
28
35
|
if part == textLower then
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
local _length = 0
|
|
33
|
-
for _k, _v in strings do
|
|
34
|
-
local _result = _callback(_v, _k - 1, strings)
|
|
35
|
-
if _result ~= nil then
|
|
36
|
-
_length += 1
|
|
37
|
-
_newValue[_length] = _result
|
|
36
|
+
local _arg0 = { i, str, #str }
|
|
37
|
+
table.insert(results, _arg0)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
-
|
|
41
|
-
table.sort(_newValue, function(a, b)
|
|
40
|
+
table.sort(results, function(a, b)
|
|
42
41
|
return a[2] < b[2]
|
|
43
42
|
end)
|
|
44
|
-
return
|
|
43
|
+
return results
|
|
45
44
|
end
|
|
46
45
|
local function getArgumentSuggestion(arg, textPart)
|
|
47
46
|
local _result
|
|
48
47
|
if arg.options.suggestions ~= nil then
|
|
49
|
-
local
|
|
50
|
-
|
|
51
|
-
local
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
-- ▲ ReadonlyArray.map ▲
|
|
56
|
-
_result = _newValue
|
|
48
|
+
local _array = {}
|
|
49
|
+
local _length = #_array
|
|
50
|
+
local _array_1 = arg.options.suggestions
|
|
51
|
+
table.move(_array_1, 1, #_array_1, _length + 1, _array)
|
|
52
|
+
_result = _array
|
|
57
53
|
else
|
|
58
54
|
_result = {}
|
|
59
55
|
end
|
|
@@ -80,8 +76,7 @@ local function getArgumentSuggestion(arg, textPart)
|
|
|
80
76
|
local typeSuggestions = _result_1
|
|
81
77
|
if typeSuggestions ~= nil then
|
|
82
78
|
for _, text in typeSuggestions do
|
|
83
|
-
|
|
84
|
-
table.insert(suggestions, _arg0)
|
|
79
|
+
table.insert(suggestions, text)
|
|
85
80
|
end
|
|
86
81
|
end
|
|
87
82
|
local errorText
|
|
@@ -183,7 +178,7 @@ local function getCommandSuggestion(registry, parentPath, text)
|
|
|
183
178
|
local _newValue_1 = table.create(#sortedPaths)
|
|
184
179
|
local _callback_1 = function(_param)
|
|
185
180
|
local str = _param[2]
|
|
186
|
-
return
|
|
181
|
+
return str
|
|
187
182
|
end
|
|
188
183
|
for _k, _v in sortedPaths do
|
|
189
184
|
_newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths)
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
|
4
5
|
local commandArgIndex = _store.commandArgIndex
|
|
5
6
|
local currentCommandPath = _store.currentCommandPath
|
|
6
7
|
local currentTextPart = _store.currentTextPart
|
|
@@ -77,7 +78,7 @@ local function completeArgument(text, suggestion, commandArgCount)
|
|
|
77
78
|
end
|
|
78
79
|
local function getSuggestedText(registry, text, suggestion)
|
|
79
80
|
if suggestion == nil then
|
|
80
|
-
return
|
|
81
|
+
return ""
|
|
81
82
|
end
|
|
82
83
|
local suggestionText
|
|
83
84
|
local parts = terminalTextParts()
|
|
@@ -87,10 +88,9 @@ local function getSuggestedText(registry, text, suggestion)
|
|
|
87
88
|
local command = currentCommandPath()
|
|
88
89
|
local argIndex = terminalArgIndex()
|
|
89
90
|
if command == nil or argIndex == nil then
|
|
90
|
-
return
|
|
91
|
+
return ""
|
|
91
92
|
end
|
|
92
|
-
|
|
93
|
-
if atNextPart and argIndex == commandArgIndex() then
|
|
93
|
+
if atNextPart() and argIndex == commandArgIndex() then
|
|
94
94
|
suggestionText = suggestion.title
|
|
95
95
|
elseif not (#suggestion.others == 0) then
|
|
96
96
|
suggestionText = suggestion.others[1]
|
|
@@ -14,6 +14,7 @@ local useClient = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-c
|
|
|
14
14
|
local useHistory = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-history").useHistory
|
|
15
15
|
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
16
16
|
local _store = TS.import(script, script.Parent.Parent.Parent, "store")
|
|
17
|
+
local atNextPart = _store.atNextPart
|
|
17
18
|
local commandArgIndex = _store.commandArgIndex
|
|
18
19
|
local currentCommandPath = _store.currentCommandPath
|
|
19
20
|
local currentSuggestion = _store.currentSuggestion
|
|
@@ -36,7 +37,6 @@ local getCommandSuggestion = _suggestion.getCommandSuggestion
|
|
|
36
37
|
local TerminalTextField = TS.import(script, script.Parent, "terminal-text-field").TerminalTextField
|
|
37
38
|
local MAX_HEIGHT = HISTORY_TEXT_SIZE * 10
|
|
38
39
|
local TEXT_FIELD_HEIGHT = 40
|
|
39
|
-
local START_QUOTE_PATTERN = `^(['"])`
|
|
40
40
|
local TRAILING_SPACE_PATTERN = "(%s+)$"
|
|
41
41
|
local function Terminal()
|
|
42
42
|
local client = useClient()
|
|
@@ -116,7 +116,7 @@ local function Terminal()
|
|
|
116
116
|
end
|
|
117
117
|
-- If the text ends in a space, we want to count that as having traversed
|
|
118
118
|
-- to the next "part" of the text.
|
|
119
|
-
local
|
|
119
|
+
local endsInSpace = string.sub(text, -1) == " "
|
|
120
120
|
local path = getValidPath(client.registry, parts)
|
|
121
121
|
local command = if path ~= nil then client.registry:getCommand(path) else nil
|
|
122
122
|
if command ~= nil then
|
|
@@ -133,18 +133,14 @@ local function Terminal()
|
|
|
133
133
|
local noArgs = _condition
|
|
134
134
|
currentCommandPath(path)
|
|
135
135
|
missingArgs(missing)
|
|
136
|
-
terminalTextValid(noArgs or #missing == 0 or (
|
|
136
|
+
terminalTextValid(noArgs or #missing == 0 or (endsInSpace and #missing == 1))
|
|
137
137
|
else
|
|
138
138
|
currentCommandPath(nil)
|
|
139
139
|
terminalTextValid(false)
|
|
140
140
|
end
|
|
141
141
|
local textPart = parts[#parts]
|
|
142
|
-
local
|
|
143
|
-
if
|
|
144
|
-
_result = string.match(_result, START_QUOTE_PATTERN)
|
|
145
|
-
end
|
|
146
|
-
local quoted = _result ~= nil
|
|
147
|
-
if atNextPart and not quoted then
|
|
142
|
+
local atNext = atNextPart()
|
|
143
|
+
if atNext then
|
|
148
144
|
textPart = nil
|
|
149
145
|
elseif textPart ~= nil then
|
|
150
146
|
local _condition = (string.match(text, TRAILING_SPACE_PATTERN))
|
|
@@ -154,18 +150,18 @@ local function Terminal()
|
|
|
154
150
|
local spaces = _condition
|
|
155
151
|
textPart ..= tostring(spaces)
|
|
156
152
|
end
|
|
157
|
-
local argIndex = if path ~= nil then #parts - path:size() - (if
|
|
153
|
+
local argIndex = if path ~= nil then #parts - path:size() - (if atNext then 0 else 1) else -1
|
|
158
154
|
terminalArgIndex(argIndex)
|
|
159
155
|
if command == nil or argIndex == -1 then
|
|
160
156
|
-- Get command suggestions
|
|
161
|
-
local parentPath = if not (#parts == 0) then RegistryPath.new(ArrayUtil.slice(parts, 0, #parts - (if
|
|
157
|
+
local parentPath = if not (#parts == 0) then RegistryPath.new(ArrayUtil.slice(parts, 0, #parts - (if atNext then 0 else 1))) else nil
|
|
162
158
|
currentTextPart(textPart)
|
|
163
159
|
local _exp = client.registry
|
|
164
|
-
local
|
|
165
|
-
if
|
|
166
|
-
|
|
160
|
+
local _result = parentPath
|
|
161
|
+
if _result ~= nil then
|
|
162
|
+
_result = _result:isEmpty()
|
|
167
163
|
end
|
|
168
|
-
currentSuggestion(getCommandSuggestion(_exp, if not
|
|
164
|
+
currentSuggestion(getCommandSuggestion(_exp, if not _result then parentPath else nil, textPart))
|
|
169
165
|
return nil
|
|
170
166
|
end
|
|
171
167
|
-- Handle arguments
|
|
@@ -197,11 +193,11 @@ local function Terminal()
|
|
|
197
193
|
endIndex = if numArgs ~= "rest" then i + (numArgs - 1) else nil
|
|
198
194
|
end
|
|
199
195
|
local _registry = client.registry
|
|
200
|
-
local
|
|
201
|
-
if
|
|
202
|
-
|
|
196
|
+
local _result = currentArg
|
|
197
|
+
if _result ~= nil then
|
|
198
|
+
_result = _result.type
|
|
203
199
|
end
|
|
204
|
-
local _condition =
|
|
200
|
+
local _condition = _result
|
|
205
201
|
if _condition == nil then
|
|
206
202
|
_condition = ""
|
|
207
203
|
end
|
|
@@ -231,11 +227,11 @@ local function Terminal()
|
|
|
231
227
|
end
|
|
232
228
|
local textParts = splitString(_condition_1, ",", true)
|
|
233
229
|
local lastText = if not (#textParts == 0) then textParts[#textParts] else nil
|
|
234
|
-
local
|
|
235
|
-
if
|
|
236
|
-
|
|
230
|
+
local _result_1 = textPart
|
|
231
|
+
if _result_1 ~= nil then
|
|
232
|
+
_result_1 = string.sub(_result_1, -1)
|
|
237
233
|
end
|
|
238
|
-
argTextPart = if
|
|
234
|
+
argTextPart = if _result_1 ~= "," then lastText else nil
|
|
239
235
|
suggestion = getArgumentSuggestion({
|
|
240
236
|
kind = "list",
|
|
241
237
|
options = currentArg,
|
|
@@ -245,11 +241,11 @@ local function Terminal()
|
|
|
245
241
|
end
|
|
246
242
|
currentTextPart(argTextPart)
|
|
247
243
|
currentSuggestion(suggestion)
|
|
248
|
-
local
|
|
249
|
-
if
|
|
250
|
-
|
|
244
|
+
local _result_1 = suggestion
|
|
245
|
+
if _result_1 ~= nil then
|
|
246
|
+
_result_1 = _result_1.error
|
|
251
247
|
end
|
|
252
|
-
if
|
|
248
|
+
if _result_1 ~= nil then
|
|
253
249
|
terminalTextValid(false)
|
|
254
250
|
end
|
|
255
251
|
end,
|
|
@@ -273,7 +269,7 @@ local function Terminal()
|
|
|
273
269
|
})
|
|
274
270
|
return nil
|
|
275
271
|
end
|
|
276
|
-
local args = ArrayUtil.slice(
|
|
272
|
+
local args = ArrayUtil.slice(splitString(terminalText(), " "), commandPath:size())
|
|
277
273
|
client.dispatcher:run(commandPath, args)
|
|
278
274
|
end,
|
|
279
275
|
}))
|
package/out/store.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export declare const terminalArgIndex: import("@rbxts/charm").Atom<number | unde
|
|
|
9
9
|
export declare const currentSuggestion: import("@rbxts/charm").Atom<Suggestion | undefined>;
|
|
10
10
|
export declare const terminalText: import("@rbxts/charm").Atom<string>;
|
|
11
11
|
export declare const terminalTextParts: import("@rbxts/charm").Molecule<string[]>;
|
|
12
|
+
export declare const atNextPart: import("@rbxts/charm").Molecule<boolean>;
|
|
12
13
|
export declare const terminalTextValid: import("@rbxts/charm").Atom<boolean>;
|
|
13
14
|
export declare const currentTextPart: import("@rbxts/charm").Atom<string | undefined>;
|
package/out/store.luau
CHANGED
|
@@ -5,6 +5,9 @@ local _charm = TS.import(script, TS.getModule(script, "@rbxts", "charm").src)
|
|
|
5
5
|
local atom = _charm.atom
|
|
6
6
|
local computed = _charm.computed
|
|
7
7
|
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
|
|
8
11
|
local interfaceVisible = atom(false)
|
|
9
12
|
local interfaceOptions = atom(DEFAULT_INTERFACE_OPTIONS)
|
|
10
13
|
local mouseOverInterface = atom(false)
|
|
@@ -16,6 +19,15 @@ local terminalText = atom("")
|
|
|
16
19
|
local terminalTextParts = computed(function()
|
|
17
20
|
return splitString(terminalText(), " ", true)
|
|
18
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)
|
|
19
31
|
local terminalTextValid = atom(false)
|
|
20
32
|
local currentTextPart = atom(nil)
|
|
21
33
|
return {
|
|
@@ -28,6 +40,7 @@ return {
|
|
|
28
40
|
currentSuggestion = currentSuggestion,
|
|
29
41
|
terminalText = terminalText,
|
|
30
42
|
terminalTextParts = terminalTextParts,
|
|
43
|
+
atNextPart = atNextPart,
|
|
31
44
|
terminalTextValid = terminalTextValid,
|
|
32
45
|
currentTextPart = currentTextPart,
|
|
33
46
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function containsSpace(text: string): boolean;
|
|
2
|
+
export declare function stripQuotes(text: string): string;
|
|
3
|
+
export declare function getQuoteChar(text: string): string;
|
|
4
|
+
export declare function isQuoteStarted(text: string): boolean;
|
|
5
|
+
export declare function isQuoteEnded(text: string): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local START_QUOTE_PATTERN = `^(['"])`
|
|
3
|
+
local END_QUOTE_PATTERN = `(['"])%s*$`
|
|
4
|
+
local function containsSpace(text)
|
|
5
|
+
return not (#{ string.match(text, "%s") } == 0)
|
|
6
|
+
end
|
|
7
|
+
local function stripQuotes(text)
|
|
8
|
+
return (string.gsub((string.gsub(text, START_QUOTE_PATTERN, "")), END_QUOTE_PATTERN, ""))
|
|
9
|
+
end
|
|
10
|
+
local function getQuoteChar(text)
|
|
11
|
+
return (string.match(text, START_QUOTE_PATTERN))
|
|
12
|
+
end
|
|
13
|
+
local function isQuoteStarted(text)
|
|
14
|
+
return (string.match(text, START_QUOTE_PATTERN)) ~= nil
|
|
15
|
+
end
|
|
16
|
+
local function isQuoteEnded(text)
|
|
17
|
+
return (string.match(text, END_QUOTE_PATTERN)) ~= nil
|
|
18
|
+
end
|
|
19
|
+
return {
|
|
20
|
+
containsSpace = containsSpace,
|
|
21
|
+
stripQuotes = stripQuotes,
|
|
22
|
+
getQuoteChar = getQuoteChar,
|
|
23
|
+
isQuoteStarted = isQuoteStarted,
|
|
24
|
+
isQuoteEnded = isQuoteEnded,
|
|
25
|
+
}
|