@rbxts/centurion-ui 1.0.8 → 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.
Files changed (141) hide show
  1. package/README.md +60 -15
  2. package/centurion.luau +10 -0
  3. package/package.json +13 -23
  4. package/src/analyse/cursor.luau +25 -0
  5. package/src/analyse/highlight.luau +91 -0
  6. package/src/analyse/init.luau +318 -0
  7. package/src/analyse/leventine.luau +298 -0
  8. package/src/analyse/match.luau +39 -0
  9. package/src/analyse/suggest.luau +41 -0
  10. package/src/app/header.luau +128 -0
  11. package/src/app/history.luau +258 -0
  12. package/src/app/init.luau +699 -0
  13. package/src/app/suggestions.luau +419 -0
  14. package/src/button.luau +13 -0
  15. package/src/components/background.luau +37 -0
  16. package/src/components/container.luau +33 -0
  17. package/src/components/corner.luau +11 -0
  18. package/src/components/divider.luau +28 -0
  19. package/src/components/flex.luau +108 -0
  20. package/src/components/gap.luau +25 -0
  21. package/src/components/image.luau +33 -0
  22. package/src/components/padding.luau +59 -0
  23. package/src/components/stroke.luau +20 -0
  24. package/src/components/text.luau +57 -0
  25. package/src/components/textbox.luau +186 -0
  26. package/src/fade.luau +23 -0
  27. package/src/init.luau +142 -0
  28. package/src/input.luau +16 -0
  29. package/src/px.luau +68 -0
  30. package/src/rich.luau +14 -0
  31. package/src/state.luau +33 -0
  32. package/src/theme.luau +70 -0
  33. package/src/ts/index.d.ts +60 -0
  34. package/src/ts/init.luau +5 -0
  35. package/src/types.luau +85 -0
  36. package/vide/init.luau +8 -0
  37. package/vide/src/action.luau +25 -0
  38. package/vide/src/apply.luau +162 -0
  39. package/vide/src/batch.luau +23 -0
  40. package/vide/src/branch.luau +40 -0
  41. package/vide/src/changed.luau +18 -0
  42. package/vide/src/cleanup.luau +43 -0
  43. package/vide/src/context.luau +74 -0
  44. package/vide/src/create.luau +107 -0
  45. package/vide/src/defaults.luau +113 -0
  46. package/vide/src/derive.luau +18 -0
  47. package/vide/src/effect.luau +12 -0
  48. package/vide/src/flags.luau +12 -0
  49. package/vide/src/graph.luau +321 -0
  50. package/vide/src/implicit_effect.luau +125 -0
  51. package/vide/src/indexes.luau +121 -0
  52. package/vide/src/init.luau +10 -0
  53. package/vide/src/lib.luau +120 -0
  54. package/vide/src/mount.luau +11 -0
  55. package/vide/src/read.luau +5 -0
  56. package/vide/src/root.luau +35 -0
  57. package/vide/src/show.luau +36 -0
  58. package/vide/src/source.luau +31 -0
  59. package/vide/src/spring.luau +328 -0
  60. package/vide/src/switch.luau +114 -0
  61. package/vide/src/timeout.luau +27 -0
  62. package/vide/src/untrack.luau +25 -0
  63. package/vide/src/values.luau +131 -0
  64. package/out/app/centurion-app.d.ts +0 -3
  65. package/out/app/centurion-app.luau +0 -86
  66. package/out/app/index.d.ts +0 -32
  67. package/out/app/init.luau +0 -105
  68. package/out/components/history/history-line.d.ts +0 -9
  69. package/out/components/history/history-line.luau +0 -88
  70. package/out/components/history/history-list.d.ts +0 -11
  71. package/out/components/history/history-list.luau +0 -67
  72. package/out/components/history/index.d.ts +0 -1
  73. package/out/components/history/init.luau +0 -7
  74. package/out/components/index.d.ts +0 -2
  75. package/out/components/init.luau +0 -10
  76. package/out/components/suggestions/badge.d.ts +0 -16
  77. package/out/components/suggestions/badge.luau +0 -40
  78. package/out/components/suggestions/index.d.ts +0 -1
  79. package/out/components/suggestions/init.luau +0 -7
  80. package/out/components/suggestions/main-suggestion.d.ts +0 -9
  81. package/out/components/suggestions/main-suggestion.luau +0 -232
  82. package/out/components/suggestions/suggestion-list.d.ts +0 -8
  83. package/out/components/suggestions/suggestion-list.luau +0 -96
  84. package/out/components/suggestions/suggestions.d.ts +0 -2
  85. package/out/components/suggestions/suggestions.luau +0 -64
  86. package/out/components/suggestions/types.d.ts +0 -6
  87. package/out/components/suggestions/types.luau +0 -2
  88. package/out/components/suggestions/util.d.ts +0 -1
  89. package/out/components/suggestions/util.luau +0 -22
  90. package/out/components/terminal/command.d.ts +0 -6
  91. package/out/components/terminal/command.luau +0 -74
  92. package/out/components/terminal/index.d.ts +0 -1
  93. package/out/components/terminal/init.luau +0 -7
  94. package/out/components/terminal/suggestion.d.ts +0 -26
  95. package/out/components/terminal/suggestion.luau +0 -205
  96. package/out/components/terminal/terminal-text-field/index.d.ts +0 -1
  97. package/out/components/terminal/terminal-text-field/init.luau +0 -7
  98. package/out/components/terminal/terminal-text-field/suggestion.d.ts +0 -5
  99. package/out/components/terminal/terminal-text-field/suggestion.luau +0 -124
  100. package/out/components/terminal/terminal-text-field/terminal-text-field.d.ts +0 -13
  101. package/out/components/terminal/terminal-text-field/terminal-text-field.luau +0 -278
  102. package/out/components/terminal/terminal.d.ts +0 -2
  103. package/out/components/terminal/terminal.luau +0 -304
  104. package/out/components/ui/frame.d.ts +0 -17
  105. package/out/components/ui/frame.luau +0 -32
  106. package/out/components/ui/group.d.ts +0 -15
  107. package/out/components/ui/group.luau +0 -29
  108. package/out/components/ui/layer.d.ts +0 -8
  109. package/out/components/ui/layer.luau +0 -26
  110. package/out/components/ui/outline.d.ts +0 -15
  111. package/out/components/ui/outline.luau +0 -116
  112. package/out/components/ui/padding.d.ts +0 -10
  113. package/out/components/ui/padding.luau +0 -19
  114. package/out/components/ui/scrolling-frame.d.ts +0 -14
  115. package/out/components/ui/scrolling-frame.luau +0 -44
  116. package/out/components/ui/text-field.d.ts +0 -12
  117. package/out/components/ui/text-field.luau +0 -60
  118. package/out/components/ui/text.d.ts +0 -17
  119. package/out/components/ui/text.luau +0 -61
  120. package/out/constants/options.d.ts +0 -2
  121. package/out/constants/options.luau +0 -27
  122. package/out/constants/text.d.ts +0 -3
  123. package/out/constants/text.luau +0 -9
  124. package/out/constants/util.d.ts +0 -1
  125. package/out/constants/util.luau +0 -7
  126. package/out/hooks/use-client.d.ts +0 -2
  127. package/out/hooks/use-client.luau +0 -17
  128. package/out/hooks/use-event.d.ts +0 -14
  129. package/out/hooks/use-event.luau +0 -58
  130. package/out/hooks/use-px.d.ts +0 -19
  131. package/out/hooks/use-px.luau +0 -78
  132. package/out/index.d.ts +0 -2
  133. package/out/init.luau +0 -10
  134. package/out/palette.d.ts +0 -47
  135. package/out/palette.luau +0 -42
  136. package/out/store.d.ts +0 -12
  137. package/out/store.luau +0 -26
  138. package/out/types.d.ts +0 -44
  139. package/out/types.luau +0 -2
  140. package/out/utils/string.d.ts +0 -5
  141. package/out/utils/string.luau +0 -25
@@ -0,0 +1,258 @@
1
+ local background = require("../components/background")
2
+ local container = require("../components/container")
3
+ local corner = require("../components/corner")
4
+ local fade = require("../fade")
5
+ local flex = require("../components/flex")
6
+ local padding = require("../components/padding")
7
+ local px = require("../px")
8
+ local state = require("../state")
9
+ local text = require("../components/text")
10
+ local textbox = require("../components/textbox")
11
+ local types = require("../types")
12
+ local vide = require("../../vide")
13
+
14
+ local action = vide.action
15
+ local create = vide.create
16
+ local changed = vide.changed
17
+ local cleanup = vide.cleanup
18
+ local effect = vide.effect
19
+ local indexes = vide.indexes
20
+ local read = vide.read
21
+ local source = vide.source
22
+ local spring = vide.spring
23
+
24
+ type History = {
25
+ read max_lines: number | () -> number,
26
+ read on_select: (command: string) -> (),
27
+ read order: number?,
28
+ }
29
+
30
+ local line_height = 35
31
+ -- width of the status glyph column, which the message is indented by
32
+ local gutter = 18
33
+
34
+ local function entry(value: () -> types.Log, i: number, on_select: (command: string) -> ())
35
+ local hovered = source(false)
36
+
37
+ -- 1 = hidden, 0 = shown
38
+ local enter = spring(function()
39
+ return 0
40
+ end, 0.3)
41
+
42
+ -- the first index always holds the newest log, so animate it whenever it changes
43
+ if i == 1 then
44
+ effect(function()
45
+ value()
46
+ enter(1)
47
+ end)
48
+ end
49
+
50
+ local function success()
51
+ return value().response.success
52
+ end
53
+
54
+ return background {
55
+ auto = "Y",
56
+ size = UDim2.fromScale(1, 0),
57
+ order = function()
58
+ return #state.logs() - i + 1
59
+ end,
60
+ -- failed commands get a faint tint so they stand out when scrolling
61
+ color = function()
62
+ return state.theme().error
63
+ end,
64
+ transparency = function()
65
+ return if success() then 1 else 0.88 + 0.12 * enter()
66
+ end,
67
+
68
+ corner(px(6)),
69
+ padding {
70
+ left = px(function()
71
+ return 8 + 16 * enter()
72
+ end),
73
+ right = px(8),
74
+ y = px(6),
75
+ },
76
+ flex():row():fill("horizontal"):gap(2),
77
+
78
+ -- clicking the header puts the command back into the input
79
+ create "TextButton" {
80
+ AutomaticSize = Enum.AutomaticSize.Y,
81
+ Size = UDim2.fromScale(1, 0),
82
+ AutoButtonColor = false,
83
+ BackgroundTransparency = 1,
84
+ LayoutOrder = 1,
85
+ Text = "",
86
+
87
+ Activated = function()
88
+ on_select(value().command)
89
+ end,
90
+ MouseEnter = function()
91
+ hovered(true)
92
+ end,
93
+ MouseLeave = function()
94
+ hovered(false)
95
+ end,
96
+
97
+ flex():column():vertical("center"):between("horizontal"),
98
+
99
+ container {
100
+ auto = "XY",
101
+ order = 1,
102
+
103
+ flex():column():vertical("center"),
104
+
105
+ text {
106
+ size = px(UDim2.fromOffset(gutter, 0)),
107
+ auto = "Y",
108
+ order = 1,
109
+ text = ">",
110
+ text_style = function()
111
+ return if success() then "highlight" else "error"
112
+ end,
113
+ weight = Enum.FontWeight.Bold,
114
+ xalignment = Enum.TextXAlignment.Left,
115
+ transparency = enter,
116
+ },
117
+
118
+ text {
119
+ auto = "XY",
120
+ order = 2,
121
+ text = function()
122
+ return value().command
123
+ end,
124
+ text_style = function()
125
+ return if hovered() then "highlight" else "normal"
126
+ end,
127
+ weight = Enum.FontWeight.Bold,
128
+ xalignment = Enum.TextXAlignment.Left,
129
+ transparency = enter,
130
+ },
131
+ },
132
+
133
+ text {
134
+ auto = "XY",
135
+ order = 2,
136
+ text = function()
137
+ return state.format_date()(value()) or ""
138
+ end,
139
+ text_size = px(state.subtext_size),
140
+ text_style = "subtext",
141
+ rich_text = true,
142
+ transparency = function()
143
+ -- dimmed until the entry is hovered
144
+ return enter() + (1 - enter()) * (if hovered() then 0 else 0.4)
145
+ end,
146
+ },
147
+ },
148
+
149
+ container {
150
+ auto = "Y",
151
+ size = UDim2.fromScale(1, 0),
152
+ order = 2,
153
+
154
+ padding { left = px(gutter) },
155
+
156
+ textbox {
157
+ text = function()
158
+ return value().response.message or "N/A"
159
+ end,
160
+ text_style = function()
161
+ return if success() then "normal" else "error"
162
+ end,
163
+ rich_text = true,
164
+ editable = false,
165
+ xalignment = Enum.TextXAlignment.Left,
166
+ wrapped = true,
167
+ transparency = enter,
168
+
169
+ -- fill the width so long messages wrap instead of overflowing
170
+ {
171
+ AutomaticSize = Enum.AutomaticSize.Y,
172
+ Size = UDim2.fromScale(1, 0),
173
+ ClearTextOnFocus = false,
174
+ },
175
+ },
176
+ },
177
+ }
178
+ end
179
+
180
+ local function history(props: History)
181
+ local content_height = source(0)
182
+ local hovered = source(false)
183
+ local max_height = px(function()
184
+ return line_height * (read(props.max_lines) :: number)
185
+ end)
186
+
187
+ return create "ScrollingFrame" {
188
+ AutomaticCanvasSize = Enum.AutomaticSize.Y,
189
+ BackgroundTransparency = 1,
190
+ BorderSizePixel = 0,
191
+ CanvasSize = UDim2.new(1, 0, 0, 0),
192
+ ScrollingDirection = Enum.ScrollingDirection.Y,
193
+ LayoutOrder = props.order,
194
+ Size = spring(function()
195
+ return UDim2.fromOffset(0, math.min(content_height(), max_height()))
196
+ end, 0.1),
197
+
198
+ ScrollBarThickness = px(4),
199
+ ScrollBarImageColor3 = function()
200
+ return state.theme().subtext
201
+ end,
202
+ ScrollBarImageTransparency = fade.fade(spring(function()
203
+ return if hovered() then 0 else 0.6
204
+ end, 0.2)),
205
+ VerticalScrollBarInset = Enum.ScrollBarInset.ScrollBar,
206
+
207
+ MouseEnter = function()
208
+ hovered(true)
209
+ end,
210
+ MouseLeave = function()
211
+ hovered(false)
212
+ end,
213
+
214
+ padding { x = px(4) },
215
+
216
+ create "UIListLayout" {
217
+ HorizontalFlex = Enum.UIFlexAlignment.Fill,
218
+ SortOrder = Enum.SortOrder.LayoutOrder,
219
+ Padding = px(UDim.new(0, 2)),
220
+
221
+ changed("AbsoluteContentSize", function(size: Vector2)
222
+ content_height(size.Y)
223
+ end),
224
+ },
225
+
226
+ -- follow new output, unless the user has scrolled up to read something
227
+ action(function(instance: ScrollingFrame)
228
+ local stick = true
229
+
230
+ local function bottom()
231
+ return math.max(instance.AbsoluteCanvasSize.Y - instance.AbsoluteWindowSize.Y, 0)
232
+ end
233
+
234
+ cleanup(instance:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
235
+ stick = instance.CanvasPosition.Y >= bottom() - 2
236
+ end))
237
+
238
+ cleanup(instance:GetPropertyChangedSignal("AbsoluteCanvasSize"):Connect(function()
239
+ if stick then
240
+ instance.CanvasPosition = Vector2.new(0, bottom())
241
+ end
242
+ end))
243
+
244
+ -- a new entry always scrolls back down
245
+ effect(function()
246
+ state.logs()
247
+ stick = true
248
+ instance.CanvasPosition = Vector2.new(0, bottom())
249
+ end)
250
+ end),
251
+
252
+ indexes(state.logs, function(value: () -> types.Log, i: number)
253
+ return entry(value, i, props.on_select)
254
+ end),
255
+ }
256
+ end
257
+
258
+ return history