@rbxts/centurion-ui 1.0.2 → 1.0.4
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/app/centurion-app.luau +4 -7
- package/out/app/index.d.ts +24 -0
- package/out/app/init.luau +45 -15
- package/out/components/history/history-line.luau +1 -3
- package/out/components/history/history-list.luau +1 -3
- package/out/components/suggestions/badge.luau +1 -3
- package/out/components/suggestions/main-suggestion.luau +1 -3
- package/out/components/suggestions/suggestion-list.luau +1 -3
- package/out/components/suggestions/suggestions.luau +14 -18
- package/out/components/terminal/suggestion.d.ts +1 -1
- package/out/components/terminal/suggestion.luau +5 -15
- package/out/components/terminal/terminal-text-field/suggestion.d.ts +2 -2
- package/out/components/terminal/terminal-text-field/suggestion.luau +4 -8
- package/out/components/terminal/terminal-text-field/terminal-text-field.d.ts +3 -1
- package/out/components/terminal/terminal-text-field/terminal-text-field.luau +11 -15
- package/out/components/terminal/terminal.luau +19 -6
- package/out/components/ui/text-field.luau +1 -3
- package/out/components/ui/text.luau +1 -3
- package/out/hooks/use-history.luau +1 -3
- package/out/hooks/use-text-bounds.luau +15 -4
- package/out/store.d.ts +10 -12
- package/out/store.luau +13 -33
- package/package.json +6 -7
- package/out/hooks/use-atom.d.ts +0 -2
- package/out/hooks/use-atom.luau +0 -17
|
@@ -9,16 +9,15 @@ local Suggestions = _components.Suggestions
|
|
|
9
9
|
local Terminal = _components.Terminal
|
|
10
10
|
local Group = TS.import(script, script.Parent.Parent, "components", "ui", "group").Group
|
|
11
11
|
local Layer = TS.import(script, script.Parent.Parent, "components", "ui", "layer").Layer
|
|
12
|
-
local useAtom = TS.import(script, script.Parent.Parent, "hooks", "use-atom").useAtom
|
|
13
12
|
local useClient = TS.import(script, script.Parent.Parent, "hooks", "use-client").useClient
|
|
14
13
|
local useEvent = TS.import(script, script.Parent.Parent, "hooks", "use-event").useEvent
|
|
15
14
|
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
|
-
|
|
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
|
-
|
|
55
|
+
visible(false)
|
|
59
56
|
end
|
|
60
57
|
end
|
|
61
58
|
end)
|
package/out/app/index.d.ts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import { CenturionClient } from "@rbxts/centurion";
|
|
2
2
|
import { InterfaceOptions } from "../types";
|
|
3
3
|
export declare namespace CenturionUI {
|
|
4
|
+
/**
|
|
5
|
+
* Returns whether the terminal UI is visible.
|
|
6
|
+
*
|
|
7
|
+
* @returns Whether the terminal UI is visible.
|
|
8
|
+
*/
|
|
4
9
|
function isVisible(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the visibility of the terminal UI.
|
|
12
|
+
*
|
|
13
|
+
* @param visible Whether the terminal UI should be visible.
|
|
14
|
+
*/
|
|
5
15
|
function setVisible(visible: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* Updates the terminal UI options.
|
|
18
|
+
*
|
|
19
|
+
* @param options The options to update.
|
|
20
|
+
*/
|
|
6
21
|
function updateOptions(options: Partial<InterfaceOptions>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Mounts the terminal UI.
|
|
24
|
+
*
|
|
25
|
+
* If `registerBuiltInCommands` is **true** (default), client commands
|
|
26
|
+
* will be registered.
|
|
27
|
+
*
|
|
28
|
+
* @param client The Centurion client.
|
|
29
|
+
* @param options The terminal UI options.
|
|
30
|
+
*/
|
|
7
31
|
function start(client: CenturionClient, options?: Partial<InterfaceOptions>): void;
|
|
8
32
|
}
|
package/out/app/init.luau
CHANGED
|
@@ -8,36 +8,66 @@ 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
|
|
12
|
-
local
|
|
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
|
|
16
16
|
local _container = CenturionUI
|
|
17
17
|
local MAX_PRELOAD_ATTEMPTS = 3
|
|
18
18
|
local PRELOAD_ATTEMPT_INTERVAL = 3
|
|
19
|
+
--[[
|
|
20
|
+
*
|
|
21
|
+
* Returns whether the terminal UI is visible.
|
|
22
|
+
*
|
|
23
|
+
* @returns Whether the terminal UI is visible.
|
|
24
|
+
|
|
25
|
+
]]
|
|
19
26
|
local function isVisible()
|
|
20
|
-
return
|
|
27
|
+
return uiVisible()
|
|
21
28
|
end
|
|
22
29
|
_container.isVisible = isVisible
|
|
30
|
+
--[[
|
|
31
|
+
*
|
|
32
|
+
* Sets the visibility of the terminal UI.
|
|
33
|
+
*
|
|
34
|
+
* @param visible Whether the terminal UI should be visible.
|
|
35
|
+
|
|
36
|
+
]]
|
|
23
37
|
local function setVisible(visible)
|
|
24
|
-
|
|
38
|
+
uiVisible(visible)
|
|
25
39
|
end
|
|
26
40
|
_container.setVisible = setVisible
|
|
41
|
+
--[[
|
|
42
|
+
*
|
|
43
|
+
* Updates the terminal UI options.
|
|
44
|
+
*
|
|
45
|
+
* @param options The options to update.
|
|
46
|
+
|
|
47
|
+
]]
|
|
27
48
|
local function updateOptions(options)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return _object
|
|
38
|
-
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)
|
|
39
58
|
end
|
|
40
59
|
_container.updateOptions = updateOptions
|
|
60
|
+
--[[
|
|
61
|
+
*
|
|
62
|
+
* Mounts the terminal UI.
|
|
63
|
+
*
|
|
64
|
+
* If `registerBuiltInCommands` is **true** (default), client commands
|
|
65
|
+
* will be registered.
|
|
66
|
+
*
|
|
67
|
+
* @param client The Centurion client.
|
|
68
|
+
* @param options The terminal UI options.
|
|
69
|
+
|
|
70
|
+
]]
|
|
41
71
|
local registerCommands
|
|
42
72
|
local function start(client, options)
|
|
43
73
|
if options == nil then
|
|
@@ -4,9 +4,8 @@ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
|
4
4
|
local Vide = _vide
|
|
5
5
|
local derive = _vide.derive
|
|
6
6
|
local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
|
|
7
|
-
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
8
7
|
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
9
|
-
local
|
|
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, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
9
8
|
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
10
|
-
local
|
|
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, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
5
4
|
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
6
|
-
local
|
|
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,
|
|
@@ -7,11 +7,10 @@ local spring = _vide.spring
|
|
|
7
7
|
local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
|
|
8
8
|
local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
|
|
9
9
|
local SUGGESTION_TITLE_TEXT_SIZE = _text.SUGGESTION_TITLE_TEXT_SIZE
|
|
10
|
-
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
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,
|
|
@@ -7,11 +7,10 @@ local derive = _vide.derive
|
|
|
7
7
|
local For = _vide.For
|
|
8
8
|
local read = _vide.read
|
|
9
9
|
local SUGGESTION_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").SUGGESTION_TEXT_SIZE
|
|
10
|
-
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
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
|
|
@@ -10,22 +10,18 @@ local spring = _vide.spring
|
|
|
10
10
|
local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
|
|
11
11
|
local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
|
|
12
12
|
local SUGGESTION_TITLE_TEXT_SIZE = _text.SUGGESTION_TITLE_TEXT_SIZE
|
|
13
|
-
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
14
13
|
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
15
14
|
local useTextBounds = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-text-bounds").useTextBounds
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
72
|
-
local _result =
|
|
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 =
|
|
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
|
|
95
|
-
local _result =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
158
|
-
currentText =
|
|
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 =
|
|
167
|
-
currentText =
|
|
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
|
|
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
|
-
|
|
83
|
+
local input = arg.input
|
|
84
|
+
if not arg.type.expensive and input ~= nil then
|
|
84
85
|
local success, err = pcall(function()
|
|
85
|
-
local
|
|
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
|
|
@@ -171,7 +161,7 @@ local function getCommandSuggestion(registry, parentPath, text)
|
|
|
171
161
|
end
|
|
172
162
|
local _object = {
|
|
173
163
|
type = "command",
|
|
174
|
-
title =
|
|
164
|
+
title = mainData.name,
|
|
175
165
|
}
|
|
176
166
|
local _left = "others"
|
|
177
167
|
-- ▼ ReadonlyArray.map ▼
|
|
@@ -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
|
-
|
|
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
|
|
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").src).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
|
|
6
|
+
local effect = _vide.effect
|
|
8
7
|
local source = _vide.source
|
|
9
|
-
local useAtom = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-atom").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
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
179
|
+
return if terminalTextValid() then options().palette.success else options().palette.error
|
|
184
180
|
end,
|
|
185
181
|
textXAlignment = "Left",
|
|
186
182
|
placeholderText = "Enter command...",
|
|
@@ -9,22 +9,22 @@ local derive = _vide.derive
|
|
|
9
9
|
local source = _vide.source
|
|
10
10
|
local spring = _vide.spring
|
|
11
11
|
local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
|
|
12
|
-
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
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
|
|
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, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
7
6
|
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
8
|
-
local
|
|
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
|
|
@@ -6,14 +6,12 @@ local cleanup = _vide.cleanup
|
|
|
6
6
|
local derive = _vide.derive
|
|
7
7
|
local source = _vide.source
|
|
8
8
|
local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
|
|
9
|
-
local
|
|
10
|
-
local useAtom = TS.import(script, script.Parent, "use-atom").useAtom
|
|
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 = {}
|
|
@@ -3,20 +3,26 @@ local TS = _G[script]
|
|
|
3
3
|
local TextService = TS.import(script, TS.getModule(script, "@rbxts", "services")).TextService
|
|
4
4
|
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
5
5
|
local cleanup = _vide.cleanup
|
|
6
|
-
local
|
|
6
|
+
local effect = _vide.effect
|
|
7
7
|
local read = _vide.read
|
|
8
|
+
local source = _vide.source
|
|
9
|
+
local getBounds = TS.Promise.promisify(function(params)
|
|
10
|
+
return TextService:GetTextBoundsAsync(params)
|
|
11
|
+
end)
|
|
8
12
|
local function useTextBounds(_param)
|
|
9
13
|
local text = _param.text
|
|
10
14
|
local font = _param.font
|
|
11
15
|
local size = _param.size
|
|
12
16
|
local width = _param.width
|
|
17
|
+
local bounds = source(Vector2.zero)
|
|
13
18
|
local params = Instance.new("GetTextBoundsParams")
|
|
14
19
|
params.RichText = true
|
|
15
20
|
cleanup(params)
|
|
16
|
-
|
|
21
|
+
effect(function()
|
|
17
22
|
local textValue = read(text)
|
|
18
23
|
if textValue == nil then
|
|
19
|
-
|
|
24
|
+
bounds(Vector2.zero)
|
|
25
|
+
return nil
|
|
20
26
|
end
|
|
21
27
|
params.Text = textValue
|
|
22
28
|
local fontValue = read(font)
|
|
@@ -31,8 +37,13 @@ local function useTextBounds(_param)
|
|
|
31
37
|
if widthValue ~= nil then
|
|
32
38
|
params.Width = widthValue
|
|
33
39
|
end
|
|
34
|
-
|
|
40
|
+
getBounds(params):andThen(function(value)
|
|
41
|
+
return bounds(value)
|
|
42
|
+
end):catch(function()
|
|
43
|
+
return bounds(Vector2.zero)
|
|
44
|
+
end)
|
|
35
45
|
end)
|
|
46
|
+
return bounds
|
|
36
47
|
end
|
|
37
48
|
return {
|
|
38
49
|
useTextBounds = useTextBounds,
|
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
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const mouseOverInterface: import("@rbxts/
|
|
6
|
-
export declare const currentCommandPath: import("@rbxts/
|
|
7
|
-
export declare const commandArgIndex: import("@rbxts/
|
|
8
|
-
export declare const terminalArgIndex: import("@rbxts/
|
|
9
|
-
export declare const currentSuggestion: import("@rbxts/
|
|
10
|
-
export declare const terminalText: import("@rbxts/
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
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
|
|
4
|
-
local _charm = TS.import(script, TS.getModule(script, "@rbxts", "charm").src)
|
|
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
|
|
9
|
-
local
|
|
10
|
-
local
|
|
11
|
-
local
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local
|
|
15
|
-
local
|
|
16
|
-
local
|
|
17
|
-
local
|
|
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
|
-
|
|
35
|
-
|
|
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.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"author": "paradoxuum",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "out/init.lua",
|
|
@@ -32,20 +32,19 @@
|
|
|
32
32
|
"dev": "shx rm -rf out && rbxtsc -w"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rbxts/centurion": "^1.0.
|
|
35
|
+
"@rbxts/centurion": "^1.0.1",
|
|
36
36
|
"@rbxts/compiler-types": "3.0.0-types.0",
|
|
37
|
-
"@rbxts/types": "^1.0.
|
|
37
|
+
"@rbxts/types": "^1.0.813",
|
|
38
38
|
"roblox-ts": "3.0.0",
|
|
39
39
|
"shx": "^0.3.4",
|
|
40
|
-
"typescript": "
|
|
40
|
+
"typescript": "5.5.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@rbxts/charm": "^0.7.5",
|
|
44
43
|
"@rbxts/services": "^1.5.5",
|
|
45
44
|
"@rbxts/set-timeout": "^1.1.2",
|
|
46
|
-
"@rbxts/vide": "^0.
|
|
45
|
+
"@rbxts/vide": "^0.5.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
49
|
-
"@rbxts/centurion": "^1.0.
|
|
48
|
+
"@rbxts/centurion": "^1.0.1"
|
|
50
49
|
}
|
|
51
50
|
}
|
package/out/hooks/use-atom.d.ts
DELETED
package/out/hooks/use-atom.luau
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local subscribe = TS.import(script, TS.getModule(script, "@rbxts", "charm").src).subscribe
|
|
4
|
-
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
5
|
-
local cleanup = _vide.cleanup
|
|
6
|
-
local source = _vide.source
|
|
7
|
-
local function useAtom(atom)
|
|
8
|
-
local state = source(atom())
|
|
9
|
-
local disconnect = subscribe(atom, state)
|
|
10
|
-
cleanup(function()
|
|
11
|
-
disconnect()
|
|
12
|
-
end)
|
|
13
|
-
return state
|
|
14
|
-
end
|
|
15
|
-
return {
|
|
16
|
-
useAtom = useAtom,
|
|
17
|
-
}
|