@rbxts/centurion-ui 1.0.0-dev-284510d

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 (113) hide show
  1. package/out/app/app.d.ts +6 -0
  2. package/out/app/app.lua +83 -0
  3. package/out/app/index.d.ts +1 -0
  4. package/out/app/init.lua +7 -0
  5. package/out/app/terminal-app.d.ts +1 -0
  6. package/out/app/terminal-app.lua +61 -0
  7. package/out/components/history/history-line.d.ts +10 -0
  8. package/out/components/history/history-line.lua +63 -0
  9. package/out/components/history/history-list.d.ts +15 -0
  10. package/out/components/history/history-list.lua +62 -0
  11. package/out/components/history/index.d.ts +1 -0
  12. package/out/components/history/init.lua +7 -0
  13. package/out/components/index.d.ts +1 -0
  14. package/out/components/init.lua +7 -0
  15. package/out/components/suggestions/badge.d.ts +16 -0
  16. package/out/components/suggestions/badge.lua +52 -0
  17. package/out/components/suggestions/index.d.ts +1 -0
  18. package/out/components/suggestions/init.lua +7 -0
  19. package/out/components/suggestions/main-suggestion.d.ts +12 -0
  20. package/out/components/suggestions/main-suggestion.lua +180 -0
  21. package/out/components/suggestions/suggestion-list.d.ts +8 -0
  22. package/out/components/suggestions/suggestion-list.lua +70 -0
  23. package/out/components/suggestions/suggestions.d.ts +1 -0
  24. package/out/components/suggestions/suggestions.lua +117 -0
  25. package/out/components/suggestions/types.d.ts +6 -0
  26. package/out/components/suggestions/types.lua +2 -0
  27. package/out/components/suggestions/util.d.ts +4 -0
  28. package/out/components/suggestions/util.lua +72 -0
  29. package/out/components/terminal-text-field.d.ts +11 -0
  30. package/out/components/terminal-text-field.lua +289 -0
  31. package/out/components/terminal-window.d.ts +1 -0
  32. package/out/components/terminal-window.lua +265 -0
  33. package/out/components/terminal.d.ts +1 -0
  34. package/out/components/terminal.lua +26 -0
  35. package/out/components/ui/frame.d.ts +20 -0
  36. package/out/components/ui/frame.lua +29 -0
  37. package/out/components/ui/group.d.ts +17 -0
  38. package/out/components/ui/group.lua +24 -0
  39. package/out/components/ui/layer.d.ts +7 -0
  40. package/out/components/ui/layer.lua +23 -0
  41. package/out/components/ui/outline.d.ts +14 -0
  42. package/out/components/ui/outline.lua +106 -0
  43. package/out/components/ui/padding.d.ts +10 -0
  44. package/out/components/ui/padding.lua +19 -0
  45. package/out/components/ui/scrolling-frame.d.ts +15 -0
  46. package/out/components/ui/scrolling-frame.lua +42 -0
  47. package/out/components/ui/shortcut-group.d.ts +6 -0
  48. package/out/components/ui/shortcut-group.lua +100 -0
  49. package/out/components/ui/text-field.d.ts +13 -0
  50. package/out/components/ui/text-field.lua +53 -0
  51. package/out/components/ui/text.d.ts +20 -0
  52. package/out/components/ui/text.lua +55 -0
  53. package/out/constants/options.d.ts +2 -0
  54. package/out/constants/options.lua +19 -0
  55. package/out/constants/springs.d.ts +19 -0
  56. package/out/constants/springs.lua +20 -0
  57. package/out/constants/text.d.ts +3 -0
  58. package/out/constants/text.lua +9 -0
  59. package/out/constants/util.d.ts +1 -0
  60. package/out/constants/util.lua +7 -0
  61. package/out/hooks/use-motion.d.ts +4 -0
  62. package/out/hooks/use-motion.lua +24 -0
  63. package/out/hooks/use-px.d.ts +24 -0
  64. package/out/hooks/use-px.lua +56 -0
  65. package/out/hooks/use-store.d.ts +3 -0
  66. package/out/hooks/use-store.lua +7 -0
  67. package/out/index.d.ts +2 -0
  68. package/out/init.lua +10 -0
  69. package/out/palette.d.ts +56 -0
  70. package/out/palette.lua +51 -0
  71. package/out/providers/api-provider.d.ts +8 -0
  72. package/out/providers/api-provider.lua +17 -0
  73. package/out/providers/options-provider.d.ts +13 -0
  74. package/out/providers/options-provider.lua +39 -0
  75. package/out/providers/root-provider.d.ts +11 -0
  76. package/out/providers/root-provider.lua +24 -0
  77. package/out/store/app/app-selectors.d.ts +2 -0
  78. package/out/store/app/app-selectors.lua +7 -0
  79. package/out/store/app/app-slice.d.ts +8 -0
  80. package/out/store/app/app-slice.lua +17 -0
  81. package/out/store/app/index.d.ts +2 -0
  82. package/out/store/app/init.lua +10 -0
  83. package/out/store/command/command-selectors.d.ts +2 -0
  84. package/out/store/command/command-selectors.lua +7 -0
  85. package/out/store/command/command-slice.d.ts +15 -0
  86. package/out/store/command/command-slice.lua +21 -0
  87. package/out/store/command/index.d.ts +2 -0
  88. package/out/store/command/init.lua +10 -0
  89. package/out/store/history/history-slice.d.ts +11 -0
  90. package/out/store/history/history-slice.lua +52 -0
  91. package/out/store/history/index.d.ts +1 -0
  92. package/out/store/history/init.lua +7 -0
  93. package/out/store/index.d.ts +46 -0
  94. package/out/store/init.lua +18 -0
  95. package/out/store/suggestion/index.d.ts +2 -0
  96. package/out/store/suggestion/init.lua +10 -0
  97. package/out/store/suggestion/suggestion-selectors.d.ts +2 -0
  98. package/out/store/suggestion/suggestion-selectors.lua +7 -0
  99. package/out/store/suggestion/suggestion-slice.d.ts +9 -0
  100. package/out/store/suggestion/suggestion-slice.lua +15 -0
  101. package/out/store/text/index.d.ts +2 -0
  102. package/out/store/text/init.lua +10 -0
  103. package/out/store/text/text-selectors.d.ts +3 -0
  104. package/out/store/text/text-selectors.lua +11 -0
  105. package/out/store/text/text-slice.d.ts +20 -0
  106. package/out/store/text/text-slice.lua +29 -0
  107. package/out/types.d.ts +40 -0
  108. package/out/types.lua +2 -0
  109. package/out/util/argument.d.ts +2 -0
  110. package/out/util/argument.lua +26 -0
  111. package/out/util/suggestion.d.ts +4 -0
  112. package/out/util/suggestion.lua +208 -0
  113. package/package.json +54 -0
@@ -0,0 +1,208 @@
1
+ -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
+ local TS = _G[script]
3
+ local ArrayUtil = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.data).ArrayUtil
4
+ local Players = TS.import(script, TS.getModule(script, "@rbxts", "services")).Players
5
+ local MAX_OTHER_SUGGESTIONS = 3
6
+ local function getSortedIndices(max, strings, text)
7
+ -- If no text is provided, sort alphabetically
8
+ if text == nil then
9
+ local _array = {}
10
+ local _length = #_array
11
+ table.move(strings, 1, #strings, _length + 1, _array)
12
+ table.sort(_array)
13
+ -- ▼ ReadonlyArray.map ▼
14
+ local _newValue = table.create(#_array)
15
+ local _callback = function(_, index)
16
+ return index
17
+ end
18
+ for _k, _v in _array do
19
+ _newValue[_k] = _callback(_v, _k - 1, _array)
20
+ end
21
+ -- ▲ ReadonlyArray.map ▲
22
+ local sorted = _newValue
23
+ return ArrayUtil.slice(sorted, 0, math.min(#sorted, max))
24
+ end
25
+ -- Otherwise, sort by the closest match
26
+ local textLower = string.lower(text)
27
+ local textEndIndex = #text
28
+ local results = {}
29
+ for i = 0, #strings - 1 do
30
+ local part = string.sub(string.lower(strings[i + 1]), 0, textEndIndex)
31
+ if part == textLower then
32
+ local _arg0 = { #part, i }
33
+ table.insert(results, _arg0)
34
+ end
35
+ end
36
+ table.sort(results, function(a, b)
37
+ if a[1] == b[1] then
38
+ return strings[a[2] + 1] < strings[b[2] + 1]
39
+ end
40
+ return a[1] < b[1]
41
+ end)
42
+ local _exp = ArrayUtil.slice(results, 0, math.min(#results, max))
43
+ -- ▼ ReadonlyArray.map ▼
44
+ local _newValue = table.create(#_exp)
45
+ local _callback = function(val)
46
+ return val[2]
47
+ end
48
+ for _k, _v in _exp do
49
+ _newValue[_k] = _callback(_v, _k - 1, _exp)
50
+ end
51
+ -- ▲ ReadonlyArray.map ▲
52
+ return _newValue
53
+ end
54
+ local function getArgumentSuggestion(registry, path, index, text)
55
+ local command = registry:getCommand(path)
56
+ if command == nil then
57
+ return nil
58
+ end
59
+ local args = command.options.arguments
60
+ if args == nil or #args == 0 then
61
+ return nil
62
+ end
63
+ if index < 0 or index >= #args then
64
+ return nil
65
+ end
66
+ local arg = args[index + 1]
67
+ local typeObject = registry:getType(arg.type)
68
+ if typeObject == nil then
69
+ return nil
70
+ end
71
+ local _result
72
+ if arg.suggestions ~= nil then
73
+ local _array = {}
74
+ local _length = #_array
75
+ local _array_1 = arg.suggestions
76
+ table.move(_array_1, 1, #_array_1, _length + 1, _array)
77
+ _result = _array
78
+ else
79
+ _result = {}
80
+ end
81
+ local argSuggestions = _result
82
+ if typeObject.suggestions ~= nil then
83
+ local _condition = text
84
+ if _condition == nil then
85
+ _condition = ""
86
+ end
87
+ for _, suggestion in typeObject.suggestions(_condition, Players.LocalPlayer) do
88
+ table.insert(argSuggestions, suggestion)
89
+ end
90
+ end
91
+ -- If the type is not marked as "expensive", transform the text into the type
92
+ -- If the transformation fails, include the error message in the suggestion
93
+ local errorText
94
+ local success, err = pcall(function()
95
+ if typeObject.expensive then
96
+ return nil
97
+ end
98
+ local _condition = text
99
+ if _condition == nil then
100
+ _condition = ""
101
+ end
102
+ local transformResult = typeObject.transform(_condition, Players.LocalPlayer)
103
+ if transformResult.ok then
104
+ return nil
105
+ end
106
+ errorText = transformResult.value
107
+ end)
108
+ if not success then
109
+ errorText = "Failed to transform argument"
110
+ warn(err)
111
+ end
112
+ local _exp = getSortedIndices(MAX_OTHER_SUGGESTIONS, argSuggestions, text)
113
+ -- ▼ ReadonlyArray.map ▼
114
+ local _newValue = table.create(#_exp)
115
+ local _callback = function(index)
116
+ return argSuggestions[index + 1]
117
+ end
118
+ for _k, _v in _exp do
119
+ _newValue[_k] = _callback(_v, _k - 1, _exp)
120
+ end
121
+ -- ▲ ReadonlyArray.map ▲
122
+ local otherSuggestions = _newValue
123
+ local _object = {}
124
+ local _left = "main"
125
+ local _object_1 = {
126
+ type = "argument",
127
+ title = arg.name,
128
+ description = arg.description,
129
+ dataType = typeObject.name,
130
+ }
131
+ local _left_1 = "optional"
132
+ local _condition = arg.optional
133
+ if _condition == nil then
134
+ _condition = false
135
+ end
136
+ _object_1[_left_1] = _condition
137
+ _object_1.error = errorText
138
+ _object[_left] = _object_1
139
+ _object.others = otherSuggestions
140
+ return _object
141
+ end
142
+ local function getCommandSuggestion(registry, parentPath, text)
143
+ local paths = if parentPath ~= nil then registry:getChildPaths(parentPath) else registry:getRootPaths()
144
+ if #paths == 0 then
145
+ return nil
146
+ end
147
+ -- ▼ ReadonlyArray.map ▼
148
+ local _newValue = table.create(#paths)
149
+ local _callback = function(path)
150
+ return path:tail()
151
+ end
152
+ for _k, _v in paths do
153
+ _newValue[_k] = _callback(_v, _k - 1, paths)
154
+ end
155
+ -- ▲ ReadonlyArray.map ▲
156
+ local pathNames = _newValue
157
+ local sortedPaths = getSortedIndices(MAX_OTHER_SUGGESTIONS + 1, pathNames, text)
158
+ if #sortedPaths == 0 then
159
+ return nil
160
+ end
161
+ local firstPath = paths[sortedPaths[1] + 1]
162
+ local _result = registry:getCommand(firstPath)
163
+ if _result ~= nil then
164
+ _result = _result.options
165
+ end
166
+ local _condition = _result
167
+ if _condition == nil then
168
+ local _result_1 = registry:getGroup(firstPath)
169
+ if _result_1 ~= nil then
170
+ _result_1 = _result_1.options
171
+ end
172
+ _condition = _result_1
173
+ end
174
+ local mainData = _condition
175
+ if mainData == nil then
176
+ return nil
177
+ end
178
+ local _result_1
179
+ if #sortedPaths > 1 then
180
+ local _exp = ArrayUtil.slice(sortedPaths, 1)
181
+ -- ▼ ReadonlyArray.map ▼
182
+ local _newValue_1 = table.create(#_exp)
183
+ local _callback_1 = function(index)
184
+ return pathNames[index + 1]
185
+ end
186
+ for _k, _v in _exp do
187
+ _newValue_1[_k] = _callback_1(_v, _k - 1, _exp)
188
+ end
189
+ -- ▲ ReadonlyArray.map ▲
190
+ _result_1 = _newValue_1
191
+ else
192
+ _result_1 = {}
193
+ end
194
+ local otherNames = _result_1
195
+ return {
196
+ main = {
197
+ type = "command",
198
+ title = firstPath:tail(),
199
+ description = mainData.description,
200
+ shortcuts = mainData.shortcuts,
201
+ },
202
+ others = otherNames,
203
+ }
204
+ end
205
+ return {
206
+ getArgumentSuggestion = getArgumentSuggestion,
207
+ getCommandSuggestion = getCommandSuggestion,
208
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@rbxts/centurion-ui",
3
+ "version": "1.0.0-dev-284510d",
4
+ "author": "paradoxuum",
5
+ "license": "MIT",
6
+ "main": "out/init.lua",
7
+ "types": "out/index.d.ts",
8
+ "files": [
9
+ "out",
10
+ "!**/*.tsbuildinfo",
11
+ "!**/__tests__",
12
+ "!**/app/config*"
13
+ ],
14
+ "keywords": [
15
+ "roblox",
16
+ "roblox-ts",
17
+ "command"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/paradoxuum/centurion.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/paradoxuum/centurion/issues"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "rbxtsc --verbose"
31
+ },
32
+ "devDependencies": {
33
+ "@rbxts/centurion": "^1.0.0-dev-284510d",
34
+ "@rbxts/compiler-types": "2.3.0-types.1",
35
+ "@rbxts/types": "^1.0.789",
36
+ "rbxts-transformer-services": "^1.1.1",
37
+ "roblox-ts": "2.3.0-dev-26ec859",
38
+ "typescript": "~5.5.3"
39
+ },
40
+ "dependencies": {
41
+ "@rbxts/beacon": "^2.1.1",
42
+ "@rbxts/pretty-react-hooks": "^0.5.2",
43
+ "@rbxts/react": "^0.4.0",
44
+ "@rbxts/react-reflex": "^0.3.4",
45
+ "@rbxts/react-roblox": "^0.4.0",
46
+ "@rbxts/reflex": "^4.3.1",
47
+ "@rbxts/ripple": "^0.8.2",
48
+ "@rbxts/services": "^1.5.4"
49
+ },
50
+ "peerDependencies": {
51
+ "@rbxts/centurion": "^1.0.0-dev-284510d"
52
+ },
53
+ "stableVersion": "0.1.0"
54
+ }