@rbxts/centurion-ui 1.0.0 → 1.0.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.
|
@@ -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
|
|
@@ -116,7 +117,7 @@ local function Terminal()
|
|
|
116
117
|
end
|
|
117
118
|
-- If the text ends in a space, we want to count that as having traversed
|
|
118
119
|
-- to the next "part" of the text.
|
|
119
|
-
local
|
|
120
|
+
local endsInSpace = string.sub(text, -1) == " "
|
|
120
121
|
local path = getValidPath(client.registry, parts)
|
|
121
122
|
local command = if path ~= nil then client.registry:getCommand(path) else nil
|
|
122
123
|
if command ~= nil then
|
|
@@ -133,18 +134,14 @@ local function Terminal()
|
|
|
133
134
|
local noArgs = _condition
|
|
134
135
|
currentCommandPath(path)
|
|
135
136
|
missingArgs(missing)
|
|
136
|
-
terminalTextValid(noArgs or #missing == 0 or (
|
|
137
|
+
terminalTextValid(noArgs or #missing == 0 or (endsInSpace and #missing == 1))
|
|
137
138
|
else
|
|
138
139
|
currentCommandPath(nil)
|
|
139
140
|
terminalTextValid(false)
|
|
140
141
|
end
|
|
141
142
|
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
|
|
143
|
+
local atNext = atNextPart()
|
|
144
|
+
if atNext then
|
|
148
145
|
textPart = nil
|
|
149
146
|
elseif textPart ~= nil then
|
|
150
147
|
local _condition = (string.match(text, TRAILING_SPACE_PATTERN))
|
|
@@ -154,18 +151,18 @@ local function Terminal()
|
|
|
154
151
|
local spaces = _condition
|
|
155
152
|
textPart ..= tostring(spaces)
|
|
156
153
|
end
|
|
157
|
-
local argIndex = if path ~= nil then #parts - path:size() - (if
|
|
154
|
+
local argIndex = if path ~= nil then #parts - path:size() - (if atNext then 0 else 1) else -1
|
|
158
155
|
terminalArgIndex(argIndex)
|
|
159
156
|
if command == nil or argIndex == -1 then
|
|
160
157
|
-- Get command suggestions
|
|
161
|
-
local parentPath = if not (#parts == 0) then RegistryPath.new(ArrayUtil.slice(parts, 0, #parts - (if
|
|
158
|
+
local parentPath = if not (#parts == 0) then RegistryPath.new(ArrayUtil.slice(parts, 0, #parts - (if atNext then 0 else 1))) else nil
|
|
162
159
|
currentTextPart(textPart)
|
|
163
160
|
local _exp = client.registry
|
|
164
|
-
local
|
|
165
|
-
if
|
|
166
|
-
|
|
161
|
+
local _result = parentPath
|
|
162
|
+
if _result ~= nil then
|
|
163
|
+
_result = _result:isEmpty()
|
|
167
164
|
end
|
|
168
|
-
currentSuggestion(getCommandSuggestion(_exp, if not
|
|
165
|
+
currentSuggestion(getCommandSuggestion(_exp, if not _result then parentPath else nil, textPart))
|
|
169
166
|
return nil
|
|
170
167
|
end
|
|
171
168
|
-- Handle arguments
|
|
@@ -197,11 +194,11 @@ local function Terminal()
|
|
|
197
194
|
endIndex = if numArgs ~= "rest" then i + (numArgs - 1) else nil
|
|
198
195
|
end
|
|
199
196
|
local _registry = client.registry
|
|
200
|
-
local
|
|
201
|
-
if
|
|
202
|
-
|
|
197
|
+
local _result = currentArg
|
|
198
|
+
if _result ~= nil then
|
|
199
|
+
_result = _result.type
|
|
203
200
|
end
|
|
204
|
-
local _condition =
|
|
201
|
+
local _condition = _result
|
|
205
202
|
if _condition == nil then
|
|
206
203
|
_condition = ""
|
|
207
204
|
end
|
|
@@ -231,11 +228,11 @@ local function Terminal()
|
|
|
231
228
|
end
|
|
232
229
|
local textParts = splitString(_condition_1, ",", true)
|
|
233
230
|
local lastText = if not (#textParts == 0) then textParts[#textParts] else nil
|
|
234
|
-
local
|
|
235
|
-
if
|
|
236
|
-
|
|
231
|
+
local _result_1 = textPart
|
|
232
|
+
if _result_1 ~= nil then
|
|
233
|
+
_result_1 = string.sub(_result_1, -1)
|
|
237
234
|
end
|
|
238
|
-
argTextPart = if
|
|
235
|
+
argTextPart = if _result_1 ~= "," then lastText else nil
|
|
239
236
|
suggestion = getArgumentSuggestion({
|
|
240
237
|
kind = "list",
|
|
241
238
|
options = currentArg,
|
|
@@ -245,11 +242,11 @@ local function Terminal()
|
|
|
245
242
|
end
|
|
246
243
|
currentTextPart(argTextPart)
|
|
247
244
|
currentSuggestion(suggestion)
|
|
248
|
-
local
|
|
249
|
-
if
|
|
250
|
-
|
|
245
|
+
local _result_1 = suggestion
|
|
246
|
+
if _result_1 ~= nil then
|
|
247
|
+
_result_1 = _result_1.error
|
|
251
248
|
end
|
|
252
|
-
if
|
|
249
|
+
if _result_1 ~= nil then
|
|
253
250
|
terminalTextValid(false)
|
|
254
251
|
end
|
|
255
252
|
end,
|
|
@@ -273,7 +270,7 @@ local function Terminal()
|
|
|
273
270
|
})
|
|
274
271
|
return nil
|
|
275
272
|
end
|
|
276
|
-
local args = ArrayUtil.slice(
|
|
273
|
+
local args = ArrayUtil.slice(splitString(terminalText(), " "), commandPath:size())
|
|
277
274
|
client.dispatcher:run(commandPath, args)
|
|
278
275
|
end,
|
|
279
276
|
}))
|
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
|
@@ -16,6 +16,24 @@ local terminalText = atom("")
|
|
|
16
16
|
local terminalTextParts = computed(function()
|
|
17
17
|
return splitString(terminalText(), " ", true)
|
|
18
18
|
end)
|
|
19
|
+
local atNextPart = computed(function()
|
|
20
|
+
local parts = terminalTextParts()
|
|
21
|
+
local textPart = parts[#parts]
|
|
22
|
+
local _startQuote = textPart
|
|
23
|
+
if _startQuote ~= nil then
|
|
24
|
+
local _arg0 = `^(['"])`
|
|
25
|
+
_startQuote = string.match(_startQuote, _arg0)
|
|
26
|
+
end
|
|
27
|
+
local startQuote = _startQuote
|
|
28
|
+
local _endQuote = textPart
|
|
29
|
+
if _endQuote ~= nil then
|
|
30
|
+
local _arg0 = `(['"])%s*$`
|
|
31
|
+
_endQuote = string.match(_endQuote, _arg0)
|
|
32
|
+
end
|
|
33
|
+
local endQuote = _endQuote
|
|
34
|
+
local quoted = startQuote ~= nil and endQuote == nil
|
|
35
|
+
return string.sub(terminalText(), -1) == " " and not quoted
|
|
36
|
+
end)
|
|
19
37
|
local terminalTextValid = atom(false)
|
|
20
38
|
local currentTextPart = atom(nil)
|
|
21
39
|
return {
|
|
@@ -28,6 +46,7 @@ return {
|
|
|
28
46
|
currentSuggestion = currentSuggestion,
|
|
29
47
|
terminalText = terminalText,
|
|
30
48
|
terminalTextParts = terminalTextParts,
|
|
49
|
+
atNextPart = atNextPart,
|
|
31
50
|
terminalTextValid = terminalTextValid,
|
|
32
51
|
currentTextPart = currentTextPart,
|
|
33
52
|
}
|