@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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
local branch = require "./branch"
|
|
2
|
+
local source = require "./source"
|
|
3
|
+
local effect = require "./effect"
|
|
4
|
+
local timeout = require "./timeout" ()
|
|
5
|
+
|
|
6
|
+
type Array<T> = { T }
|
|
7
|
+
type Map<K, V> = { [K]: V }
|
|
8
|
+
type Source<T> = () -> T
|
|
9
|
+
type Component<T> = (Source<boolean>) -> (T, ...number)
|
|
10
|
+
|
|
11
|
+
local function switch_map<K, Obj>(
|
|
12
|
+
input: Source<K>,
|
|
13
|
+
map: Map<K, Component<Obj>>
|
|
14
|
+
): Source<nil | Obj | Array<Obj>>
|
|
15
|
+
local scopes = {} :: Map<K, {
|
|
16
|
+
destroy: () -> (),
|
|
17
|
+
object: Obj,
|
|
18
|
+
delay: number,
|
|
19
|
+
present: (boolean?) -> boolean,
|
|
20
|
+
timeout: { cancel: boolean }?
|
|
21
|
+
}>
|
|
22
|
+
|
|
23
|
+
local output = source(nil :: nil | Obj | Array<Obj>)
|
|
24
|
+
local function update_output()
|
|
25
|
+
local objects = {}
|
|
26
|
+
|
|
27
|
+
for _, scope in scopes do
|
|
28
|
+
table.insert(objects, scope.object)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
output(
|
|
32
|
+
if objects[2] then objects
|
|
33
|
+
elseif objects[1] then objects[1]
|
|
34
|
+
else nil
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
effect(function()
|
|
39
|
+
local key: K? = input()
|
|
40
|
+
|
|
41
|
+
-- destroy (or queue destroy) all scopes not associated with the input key
|
|
42
|
+
for k, scope in scopes do
|
|
43
|
+
if k == key then continue end
|
|
44
|
+
|
|
45
|
+
scope.present(false)
|
|
46
|
+
|
|
47
|
+
if scope.delay == 0 then
|
|
48
|
+
scope.destroy()
|
|
49
|
+
scopes[k] = nil
|
|
50
|
+
else
|
|
51
|
+
if scope.timeout == nil then
|
|
52
|
+
scope.timeout = timeout(scope.delay, function()
|
|
53
|
+
scope.destroy()
|
|
54
|
+
scopes[k] = nil
|
|
55
|
+
update_output()
|
|
56
|
+
end)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
-- create new scope or abort destruction of existing scope if key exists
|
|
62
|
+
if key ~= nil then
|
|
63
|
+
local scope = scopes[key]
|
|
64
|
+
|
|
65
|
+
if scope then
|
|
66
|
+
scope.present(true)
|
|
67
|
+
|
|
68
|
+
if scope.timeout then
|
|
69
|
+
scope.timeout.cancel = true
|
|
70
|
+
scope.timeout = nil
|
|
71
|
+
end
|
|
72
|
+
else
|
|
73
|
+
local component = map[key]
|
|
74
|
+
|
|
75
|
+
if component ~= nil then
|
|
76
|
+
if type(component) ~= "function" then
|
|
77
|
+
error("map must map a value to a function", 0)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
local present = source(false)
|
|
81
|
+
|
|
82
|
+
local delay = nil :: number?
|
|
83
|
+
local destroy, object = branch(function()
|
|
84
|
+
local object, t = component(present)
|
|
85
|
+
delay = t
|
|
86
|
+
return object
|
|
87
|
+
end)
|
|
88
|
+
|
|
89
|
+
present(true)
|
|
90
|
+
|
|
91
|
+
scopes[key] = {
|
|
92
|
+
destroy = destroy,
|
|
93
|
+
object = object,
|
|
94
|
+
delay = delay or 0,
|
|
95
|
+
present = present,
|
|
96
|
+
timeout = nil
|
|
97
|
+
}
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
update_output()
|
|
103
|
+
end)
|
|
104
|
+
|
|
105
|
+
return output
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
local function switch<K, Obj>(input: Source<K>): (map: Map<K, Component<Obj>>) -> Source<nil | Obj | Array<Obj>>
|
|
109
|
+
return function(map)
|
|
110
|
+
return switch_map(input, map)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
return switch
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
local queue = {} :: {
|
|
2
|
+
{ t: number, fn: () -> (), cancel: boolean }
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
local function timeout(t: number, fn: () -> ())
|
|
6
|
+
local handle = { t = t, fn = fn, cancel = false }
|
|
7
|
+
table.insert(queue, handle)
|
|
8
|
+
return handle
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
local function update_timeouts(dt: number)
|
|
12
|
+
for i = #queue, 1, -1 do
|
|
13
|
+
local handle = queue[i]
|
|
14
|
+
handle.t -= dt
|
|
15
|
+
|
|
16
|
+
if handle.cancel or handle.t <= 0 then
|
|
17
|
+
queue[i] = queue[#queue]
|
|
18
|
+
queue[#queue] = nil
|
|
19
|
+
|
|
20
|
+
if not handle.cancel then
|
|
21
|
+
handle.fn()
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
return function() return timeout, update_timeouts end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
local graph = require "./graph"
|
|
2
|
+
type Node<T> = graph.Node<T>
|
|
3
|
+
local get_scope = graph.get_scope
|
|
4
|
+
|
|
5
|
+
local function untrack<T>(source: () -> T): T
|
|
6
|
+
local scope = get_scope()
|
|
7
|
+
|
|
8
|
+
if scope then
|
|
9
|
+
-- sources are only tracked if the node in scope has an effect
|
|
10
|
+
local effect = scope.effect
|
|
11
|
+
scope.effect = false
|
|
12
|
+
|
|
13
|
+
local ok, result = xpcall(source, debug.traceback)
|
|
14
|
+
|
|
15
|
+
scope.effect = effect :: () -> ()
|
|
16
|
+
|
|
17
|
+
if not ok then error(result, 0) end
|
|
18
|
+
|
|
19
|
+
return result :: T
|
|
20
|
+
else
|
|
21
|
+
return source()
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
return untrack :: ( <T>(fn: () -> T) -> T ) & ( (fn: () -> ()) -> () )
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
local flags = require "./flags"
|
|
2
|
+
local branch = require "./branch"
|
|
3
|
+
local source = require "./source"
|
|
4
|
+
local effect = require "./effect"
|
|
5
|
+
local timeout = require "./timeout" ()
|
|
6
|
+
|
|
7
|
+
type Array<T> = { T }
|
|
8
|
+
type Map<K, V> = { [K]: V }
|
|
9
|
+
type Source<T> = () -> T
|
|
10
|
+
|
|
11
|
+
local function values<K, V, Obj>(
|
|
12
|
+
input: Source<Map<K, V>>,
|
|
13
|
+
component: (V, Source<K>, Source<boolean>) -> (Obj, ...number)
|
|
14
|
+
): Source<Array<Obj>>
|
|
15
|
+
local update_count = 0
|
|
16
|
+
local scopes = {} :: Map<V, {
|
|
17
|
+
destroy: () -> (),
|
|
18
|
+
object: Obj,
|
|
19
|
+
index: K?,
|
|
20
|
+
index_source: (K?) -> K,
|
|
21
|
+
count: number,
|
|
22
|
+
delay: number,
|
|
23
|
+
present: (boolean?) -> boolean,
|
|
24
|
+
timeout: { cancel: boolean }?,
|
|
25
|
+
}>
|
|
26
|
+
|
|
27
|
+
local output = source({} :: Array<Obj>)
|
|
28
|
+
local function update_output()
|
|
29
|
+
local objects = table.create(4)
|
|
30
|
+
|
|
31
|
+
for _, scope in scopes do
|
|
32
|
+
table.insert(objects, scope.object)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
output(objects)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
effect(function()
|
|
39
|
+
local data = input()
|
|
40
|
+
|
|
41
|
+
local count = update_count
|
|
42
|
+
update_count += 1
|
|
43
|
+
|
|
44
|
+
local children_need_update = false -- set to true if a scope is created or destroyed
|
|
45
|
+
|
|
46
|
+
if flags.strict then -- check for duplicate values
|
|
47
|
+
local map = {}
|
|
48
|
+
for _, v in data do
|
|
49
|
+
if map[v] then
|
|
50
|
+
error("table source passed to `values()` contains duplicate values", 0)
|
|
51
|
+
end
|
|
52
|
+
map[v] = true
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
-- create or update scopes
|
|
57
|
+
for i, v in data do
|
|
58
|
+
local scope = scopes[v]
|
|
59
|
+
|
|
60
|
+
if scope == nil then -- create new scope and create component
|
|
61
|
+
local index_source = source(i)
|
|
62
|
+
local present = source(false)
|
|
63
|
+
|
|
64
|
+
local delay = nil :: number?
|
|
65
|
+
local destroy, object = branch(function()
|
|
66
|
+
local object, t = component(v, index_source, present)
|
|
67
|
+
delay = t
|
|
68
|
+
return object
|
|
69
|
+
end)
|
|
70
|
+
|
|
71
|
+
present(true)
|
|
72
|
+
|
|
73
|
+
children_need_update = true
|
|
74
|
+
|
|
75
|
+
scopes[v] = {
|
|
76
|
+
destroy = destroy,
|
|
77
|
+
object = object,
|
|
78
|
+
index = i,
|
|
79
|
+
index_source = index_source,
|
|
80
|
+
count = count,
|
|
81
|
+
delay = delay or 0,
|
|
82
|
+
present = present,
|
|
83
|
+
timeout = nil,
|
|
84
|
+
}
|
|
85
|
+
else -- update scope
|
|
86
|
+
scope.count = count
|
|
87
|
+
|
|
88
|
+
if scope.index ~= i then
|
|
89
|
+
if scope.timeout then -- value is in input table again; cancel destruction
|
|
90
|
+
scope.timeout.cancel = true
|
|
91
|
+
scope.timeout = nil
|
|
92
|
+
scope.present(true)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
scope.index = i
|
|
96
|
+
scope.index_source(i)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
-- destroy scopes
|
|
102
|
+
for v, scope in scopes do
|
|
103
|
+
if scope.count < count then -- if count is not latest then value is no longer in the input table
|
|
104
|
+
scope.present(false)
|
|
105
|
+
|
|
106
|
+
if scope.delay == 0 then
|
|
107
|
+
scope.destroy()
|
|
108
|
+
scopes[v] = nil
|
|
109
|
+
children_need_update = true
|
|
110
|
+
else
|
|
111
|
+
scope.index = nil -- set to nil for the `scope.index ~= i` check
|
|
112
|
+
if scope.timeout == nil then
|
|
113
|
+
scope.timeout = timeout(scope.delay, function() -- todo: possible redundant updates
|
|
114
|
+
scope.destroy()
|
|
115
|
+
scopes[v] = nil
|
|
116
|
+
update_output()
|
|
117
|
+
end)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if children_need_update then
|
|
124
|
+
update_output()
|
|
125
|
+
end
|
|
126
|
+
end)
|
|
127
|
+
|
|
128
|
+
return output
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
return values
|
|
@@ -1,86 +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 derive = _vide.derive
|
|
7
|
-
local _components = TS.import(script, script.Parent.Parent, "components")
|
|
8
|
-
local Suggestions = _components.Suggestions
|
|
9
|
-
local Terminal = _components.Terminal
|
|
10
|
-
local Group = TS.import(script, script.Parent.Parent, "components", "ui", "group").Group
|
|
11
|
-
local Layer = TS.import(script, script.Parent.Parent, "components", "ui", "layer").Layer
|
|
12
|
-
local useClient = TS.import(script, script.Parent.Parent, "hooks", "use-client").useClient
|
|
13
|
-
local useEvent = TS.import(script, script.Parent.Parent, "hooks", "use-event").useEvent
|
|
14
|
-
local _use_px = TS.import(script, script.Parent.Parent, "hooks", "use-px")
|
|
15
|
-
local px = _use_px.px
|
|
16
|
-
local usePx = _use_px.usePx
|
|
17
|
-
local _store = TS.import(script, script.Parent.Parent, "store")
|
|
18
|
-
local mouseOverInterface = _store.mouseOverInterface
|
|
19
|
-
local options = _store.options
|
|
20
|
-
local visible = _store.visible
|
|
21
|
-
local MOUSE_INPUT_TYPES = {
|
|
22
|
-
[Enum.UserInputType.MouseButton1] = true,
|
|
23
|
-
[Enum.UserInputType.MouseButton2] = true,
|
|
24
|
-
[Enum.UserInputType.Touch] = true,
|
|
25
|
-
}
|
|
26
|
-
local function CenturionApp(client)
|
|
27
|
-
useClient(client)
|
|
28
|
-
usePx()
|
|
29
|
-
local validKeys = derive(function()
|
|
30
|
-
local _set = {}
|
|
31
|
-
for _, _v in options().activationKeys do
|
|
32
|
-
_set[_v] = true
|
|
33
|
-
end
|
|
34
|
-
return _set
|
|
35
|
-
end)
|
|
36
|
-
useEvent(UserInputService.InputBegan, function(input, gameProcessed)
|
|
37
|
-
local _exp = validKeys()
|
|
38
|
-
local _keyCode = input.KeyCode
|
|
39
|
-
local _condition = _exp[_keyCode] ~= nil
|
|
40
|
-
if _condition then
|
|
41
|
-
_condition = not gameProcessed
|
|
42
|
-
end
|
|
43
|
-
if _condition then
|
|
44
|
-
visible(not visible())
|
|
45
|
-
else
|
|
46
|
-
local _condition_1 = options().hideOnLostFocus
|
|
47
|
-
if _condition_1 then
|
|
48
|
-
local _userInputType = input.UserInputType
|
|
49
|
-
_condition_1 = MOUSE_INPUT_TYPES[_userInputType] ~= nil
|
|
50
|
-
if _condition_1 then
|
|
51
|
-
_condition_1 = not mouseOverInterface()
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
if _condition_1 then
|
|
55
|
-
visible(false)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end)
|
|
59
|
-
return Vide.jsx(Layer, {
|
|
60
|
-
name = "Centurion",
|
|
61
|
-
displayOrder = function()
|
|
62
|
-
return options().displayOrder
|
|
63
|
-
end,
|
|
64
|
-
visible = visible,
|
|
65
|
-
}, Vide.jsx(Group, {
|
|
66
|
-
anchor = function()
|
|
67
|
-
return options().anchor
|
|
68
|
-
end,
|
|
69
|
-
size = function()
|
|
70
|
-
local size = options().size
|
|
71
|
-
return if typeof(size) == "UDim2" then size else size(px)
|
|
72
|
-
end,
|
|
73
|
-
position = function()
|
|
74
|
-
local position = options().position
|
|
75
|
-
return if typeof(position) == "UDim2" then position else position(px)
|
|
76
|
-
end,
|
|
77
|
-
}, Vide.jsx(Terminal), Vide.jsx(Suggestions), Vide.jsx("uilistlayout", {
|
|
78
|
-
Padding = function()
|
|
79
|
-
return UDim.new(0, px(8))
|
|
80
|
-
end,
|
|
81
|
-
SortOrder = "LayoutOrder",
|
|
82
|
-
})))
|
|
83
|
-
end
|
|
84
|
-
return {
|
|
85
|
-
CenturionApp = CenturionApp,
|
|
86
|
-
}
|
package/out/app/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { CenturionClient } from "@rbxts/centurion";
|
|
2
|
-
import { InterfaceOptions } from "../types";
|
|
3
|
-
export declare namespace CenturionUI {
|
|
4
|
-
/**
|
|
5
|
-
* Returns whether the terminal UI is visible.
|
|
6
|
-
*
|
|
7
|
-
* @returns Whether the terminal UI is visible.
|
|
8
|
-
*/
|
|
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
|
-
*/
|
|
15
|
-
function setVisible(visible: boolean): void;
|
|
16
|
-
/**
|
|
17
|
-
* Updates the terminal UI options.
|
|
18
|
-
*
|
|
19
|
-
* @param options The options to update.
|
|
20
|
-
*/
|
|
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
|
-
*/
|
|
31
|
-
function start(client: CenturionClient, options?: Partial<InterfaceOptions>): void;
|
|
32
|
-
}
|
package/out/app/init.luau
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local CenturionType = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out).CenturionType
|
|
4
|
-
local Players = TS.import(script, TS.getModule(script, "@rbxts", "services")).Players
|
|
5
|
-
local mount = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).mount
|
|
6
|
-
local DEFAULT_INTERFACE_OPTIONS = TS.import(script, script.Parent, "constants", "options").DEFAULT_INTERFACE_OPTIONS
|
|
7
|
-
local DefaultPalette = TS.import(script, script.Parent, "palette").DefaultPalette
|
|
8
|
-
local _store = TS.import(script, script.Parent, "store")
|
|
9
|
-
local uiOptions = _store.options
|
|
10
|
-
local uiVisible = _store.visible
|
|
11
|
-
local CenturionApp = TS.import(script, script, "centurion-app").CenturionApp
|
|
12
|
-
local CenturionUI = {}
|
|
13
|
-
do
|
|
14
|
-
local _container = CenturionUI
|
|
15
|
-
--[[
|
|
16
|
-
*
|
|
17
|
-
* Returns whether the terminal UI is visible.
|
|
18
|
-
*
|
|
19
|
-
* @returns Whether the terminal UI is visible.
|
|
20
|
-
|
|
21
|
-
]]
|
|
22
|
-
local function isVisible()
|
|
23
|
-
return uiVisible()
|
|
24
|
-
end
|
|
25
|
-
_container.isVisible = isVisible
|
|
26
|
-
--[[
|
|
27
|
-
*
|
|
28
|
-
* Sets the visibility of the terminal UI.
|
|
29
|
-
*
|
|
30
|
-
* @param visible Whether the terminal UI should be visible.
|
|
31
|
-
|
|
32
|
-
]]
|
|
33
|
-
local function setVisible(visible)
|
|
34
|
-
uiVisible(visible)
|
|
35
|
-
end
|
|
36
|
-
_container.setVisible = setVisible
|
|
37
|
-
--[[
|
|
38
|
-
*
|
|
39
|
-
* Updates the terminal UI options.
|
|
40
|
-
*
|
|
41
|
-
* @param options The options to update.
|
|
42
|
-
|
|
43
|
-
]]
|
|
44
|
-
local function updateOptions(options)
|
|
45
|
-
local _object = table.clone(DEFAULT_INTERFACE_OPTIONS)
|
|
46
|
-
setmetatable(_object, nil)
|
|
47
|
-
for _k, _v in uiOptions() do
|
|
48
|
-
_object[_k] = _v
|
|
49
|
-
end
|
|
50
|
-
for _k, _v in options do
|
|
51
|
-
_object[_k] = _v
|
|
52
|
-
end
|
|
53
|
-
uiOptions(_object)
|
|
54
|
-
end
|
|
55
|
-
_container.updateOptions = updateOptions
|
|
56
|
-
--[[
|
|
57
|
-
*
|
|
58
|
-
* Mounts the terminal UI.
|
|
59
|
-
*
|
|
60
|
-
* If `registerBuiltInCommands` is **true** (default), client commands
|
|
61
|
-
* will be registered.
|
|
62
|
-
*
|
|
63
|
-
* @param client The Centurion client.
|
|
64
|
-
* @param options The terminal UI options.
|
|
65
|
-
|
|
66
|
-
]]
|
|
67
|
-
local registerCommands
|
|
68
|
-
local function start(client, options)
|
|
69
|
-
if options == nil then
|
|
70
|
-
options = {}
|
|
71
|
-
end
|
|
72
|
-
if client.config.registerBuiltInCommands then
|
|
73
|
-
registerCommands(client.registry)
|
|
74
|
-
end
|
|
75
|
-
updateOptions(options)
|
|
76
|
-
mount(function()
|
|
77
|
-
return CenturionApp(client)
|
|
78
|
-
end, Players.LocalPlayer:WaitForChild("PlayerGui"))
|
|
79
|
-
end
|
|
80
|
-
_container.start = start
|
|
81
|
-
function registerCommands(registry)
|
|
82
|
-
registry:registerCommand({
|
|
83
|
-
name = "theme",
|
|
84
|
-
description = "Change the terminal's theme",
|
|
85
|
-
arguments = { {
|
|
86
|
-
name = "name",
|
|
87
|
-
description = "The name of the theme",
|
|
88
|
-
type = CenturionType.String,
|
|
89
|
-
suggestions = { "mocha", "macchiato", "frappe", "latte" },
|
|
90
|
-
} },
|
|
91
|
-
}, function(ctx, theme)
|
|
92
|
-
if not (DefaultPalette[theme] ~= nil) then
|
|
93
|
-
ctx:error("Invalid theme")
|
|
94
|
-
return nil
|
|
95
|
-
end
|
|
96
|
-
updateOptions({
|
|
97
|
-
palette = DefaultPalette[theme],
|
|
98
|
-
})
|
|
99
|
-
ctx:reply(`Set theme to '{theme}'`)
|
|
100
|
-
end, { "centurion" })
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
return {
|
|
104
|
-
CenturionUI = CenturionUI,
|
|
105
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { HistoryEntry } from "@rbxts/centurion";
|
|
2
|
-
import Vide, { Derivable } from "@rbxts/vide";
|
|
3
|
-
interface HistoryLineProps {
|
|
4
|
-
data: HistoryEntry;
|
|
5
|
-
position?: Derivable<UDim2>;
|
|
6
|
-
order?: Derivable<number>;
|
|
7
|
-
}
|
|
8
|
-
export declare function HistoryLine({ data, position, order }: HistoryLineProps): Vide.Node;
|
|
9
|
-
export {};
|
|
@@ -1,88 +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 Vide = _vide
|
|
5
|
-
local derive = _vide.derive
|
|
6
|
-
local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
|
|
7
|
-
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
8
|
-
local options = TS.import(script, script.Parent.Parent.Parent, "store").options
|
|
9
|
-
local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
|
|
10
|
-
local Group = TS.import(script, script.Parent.Parent, "ui", "group").Group
|
|
11
|
-
local Outline = TS.import(script, script.Parent.Parent, "ui", "outline").Outline
|
|
12
|
-
local Text = TS.import(script, script.Parent.Parent, "ui", "text").Text
|
|
13
|
-
local TextField = TS.import(script, script.Parent.Parent, "ui", "text-field").TextField
|
|
14
|
-
local function HistoryLine(_param)
|
|
15
|
-
local data = _param.data
|
|
16
|
-
local position = _param.position
|
|
17
|
-
local order = _param.order
|
|
18
|
-
local date = derive(function()
|
|
19
|
-
local dateTime = DateTime.fromUnixTimestamp(data.sentAt):FormatLocalTime("LT", "en-us")
|
|
20
|
-
local dateParts = string.split(dateTime, " ")
|
|
21
|
-
return `<b>{dateParts[1]}</b> {dateParts[2]}`
|
|
22
|
-
end)
|
|
23
|
-
return Vide.jsx(Group, {
|
|
24
|
-
automaticSize = "Y",
|
|
25
|
-
size = UDim2.fromScale(1, 0),
|
|
26
|
-
position = position,
|
|
27
|
-
layoutOrder = order,
|
|
28
|
-
}, Vide.jsx(Frame, {
|
|
29
|
-
backgroundColor = function()
|
|
30
|
-
return options().palette.surface
|
|
31
|
-
end,
|
|
32
|
-
size = function()
|
|
33
|
-
return UDim2.fromOffset(px(76), px(HISTORY_TEXT_SIZE + 4))
|
|
34
|
-
end,
|
|
35
|
-
cornerRadius = function()
|
|
36
|
-
return UDim.new(0, px(4))
|
|
37
|
-
end,
|
|
38
|
-
}, Vide.jsx(Text, {
|
|
39
|
-
size = UDim2.fromScale(1, 1),
|
|
40
|
-
text = date,
|
|
41
|
-
textColor = function()
|
|
42
|
-
return options().palette.text
|
|
43
|
-
end,
|
|
44
|
-
textSize = function()
|
|
45
|
-
return px(HISTORY_TEXT_SIZE)
|
|
46
|
-
end,
|
|
47
|
-
richText = true,
|
|
48
|
-
}), Vide.jsx(Outline, {
|
|
49
|
-
innerThickness = function()
|
|
50
|
-
return px(1)
|
|
51
|
-
end,
|
|
52
|
-
innerTransparency = 0.25,
|
|
53
|
-
innerColor = function()
|
|
54
|
-
return if data.success then options().palette.success else options().palette.error
|
|
55
|
-
end,
|
|
56
|
-
outerThickness = 0,
|
|
57
|
-
cornerRadius = function()
|
|
58
|
-
return UDim.new(0, px(4))
|
|
59
|
-
end,
|
|
60
|
-
})), Vide.jsx(TextField, {
|
|
61
|
-
automaticSize = "Y",
|
|
62
|
-
anchor = Vector2.new(1, 0),
|
|
63
|
-
size = function()
|
|
64
|
-
return UDim2.new(1, -px(84), 0, 0)
|
|
65
|
-
end,
|
|
66
|
-
position = function()
|
|
67
|
-
return UDim2.new(1, 0, 0, px(2))
|
|
68
|
-
end,
|
|
69
|
-
text = data.text,
|
|
70
|
-
textSize = function()
|
|
71
|
-
return px(HISTORY_TEXT_SIZE)
|
|
72
|
-
end,
|
|
73
|
-
textColor = function()
|
|
74
|
-
local palette = options().palette
|
|
75
|
-
return if data.success then palette.text else palette.error
|
|
76
|
-
end,
|
|
77
|
-
textEditable = false,
|
|
78
|
-
textXAlignment = "Left",
|
|
79
|
-
clearTextOnFocus = false,
|
|
80
|
-
font = function()
|
|
81
|
-
return options().font.medium
|
|
82
|
-
end,
|
|
83
|
-
richText = true,
|
|
84
|
-
}))
|
|
85
|
-
end
|
|
86
|
-
return {
|
|
87
|
-
HistoryLine = HistoryLine,
|
|
88
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HistoryEntry } from "@rbxts/centurion";
|
|
2
|
-
import Vide, { Derivable } from "@rbxts/vide";
|
|
3
|
-
interface HistoryListProps {
|
|
4
|
-
entries: Derivable<HistoryEntry[]>;
|
|
5
|
-
size?: Derivable<UDim2>;
|
|
6
|
-
position?: Derivable<UDim2>;
|
|
7
|
-
scrollingEnabled?: Derivable<boolean>;
|
|
8
|
-
onContentSizeChanged?: (size: Vector2) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function HistoryList({ entries, size, position, scrollingEnabled, onContentSizeChanged, }: HistoryListProps): Vide.Node;
|
|
11
|
-
export {};
|