@rbxts/centurion-ui 1.0.0-dev-dacc7af → 1.0.0-dev-a7b777e

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/centurion-app.d.ts +3 -0
  2. package/out/app/centurion-app.lua +92 -0
  3. package/out/app/index.d.ts +6 -1
  4. package/out/app/init.lua +57 -4
  5. package/out/components/history/history-line.d.ts +5 -5
  6. package/out/components/history/history-line.lua +51 -27
  7. package/out/components/history/history-list.d.ts +8 -12
  8. package/out/components/history/history-list.lua +41 -41
  9. package/out/components/index.d.ts +1 -0
  10. package/out/components/init.lua +3 -0
  11. package/out/components/suggestions/badge.d.ts +11 -11
  12. package/out/components/suggestions/badge.lua +14 -20
  13. package/out/components/suggestions/main-suggestion.d.ts +6 -8
  14. package/out/components/suggestions/main-suggestion.lua +153 -143
  15. package/out/components/suggestions/suggestion-list.d.ts +5 -5
  16. package/out/components/suggestions/suggestion-list.lua +70 -49
  17. package/out/components/suggestions/suggestions.d.ts +2 -1
  18. package/out/components/suggestions/suggestions.lua +41 -50
  19. package/out/components/suggestions/util.d.ts +2 -2
  20. package/out/components/suggestions/util.lua +1 -0
  21. package/out/components/terminal/index.d.ts +1 -0
  22. package/out/{store/history → components/terminal}/init.lua +1 -1
  23. package/out/components/terminal/terminal-text-field.d.ts +11 -0
  24. package/out/components/terminal/terminal-text-field.lua +319 -0
  25. package/out/components/terminal/terminal.d.ts +2 -0
  26. package/out/components/terminal/terminal.lua +240 -0
  27. package/out/components/ui/frame.d.ts +17 -18
  28. package/out/components/ui/frame.lua +8 -10
  29. package/out/components/ui/group.d.ts +13 -15
  30. package/out/components/ui/group.lua +6 -9
  31. package/out/components/ui/layer.d.ts +5 -5
  32. package/out/components/ui/layer.lua +3 -3
  33. package/out/components/ui/outline.d.ts +13 -12
  34. package/out/components/ui/outline.lua +64 -54
  35. package/out/components/ui/padding.d.ts +7 -7
  36. package/out/components/ui/padding.lua +2 -2
  37. package/out/components/ui/scrolling-frame.d.ts +11 -12
  38. package/out/components/ui/scrolling-frame.lua +4 -9
  39. package/out/components/ui/text-field.d.ts +10 -9
  40. package/out/components/ui/text-field.lua +15 -13
  41. package/out/components/ui/text.d.ts +16 -16
  42. package/out/components/ui/text.lua +39 -38
  43. package/out/hooks/use-api.d.ts +3 -0
  44. package/out/hooks/use-api.lua +18 -0
  45. package/out/hooks/use-atom.d.ts +2 -0
  46. package/out/hooks/use-atom.lua +17 -0
  47. package/out/hooks/use-debounce-source.d.ts +11 -0
  48. package/out/hooks/use-debounce-source.lua +27 -0
  49. package/out/hooks/use-event.d.ts +14 -0
  50. package/out/hooks/use-event.lua +58 -0
  51. package/out/hooks/use-history.d.ts +2 -0
  52. package/out/hooks/use-history.lua +56 -0
  53. package/out/hooks/use-motion.d.ts +4 -4
  54. package/out/hooks/use-motion.lua +10 -15
  55. package/out/hooks/use-px.d.ts +13 -1
  56. package/out/hooks/use-px.lua +52 -39
  57. package/out/store.d.ts +14 -0
  58. package/out/store.lua +44 -0
  59. package/out/types.d.ts +7 -4
  60. package/out/util/argument.d.ts +2 -1
  61. package/out/util/argument.lua +25 -0
  62. package/out/util/suggestion.d.ts +2 -2
  63. package/out/util/suggestion.lua +9 -14
  64. package/package.json +12 -13
  65. package/out/app/app.d.ts +0 -6
  66. package/out/app/app.lua +0 -83
  67. package/out/app/terminal-app.d.ts +0 -1
  68. package/out/app/terminal-app.lua +0 -61
  69. package/out/components/terminal-text-field.d.ts +0 -11
  70. package/out/components/terminal-text-field.lua +0 -289
  71. package/out/components/terminal-window.d.ts +0 -1
  72. package/out/components/terminal-window.lua +0 -265
  73. package/out/components/terminal.d.ts +0 -1
  74. package/out/components/terminal.lua +0 -26
  75. package/out/components/ui/shortcut-group.d.ts +0 -6
  76. package/out/components/ui/shortcut-group.lua +0 -100
  77. package/out/hooks/use-store.d.ts +0 -3
  78. package/out/hooks/use-store.lua +0 -7
  79. package/out/providers/api-provider.d.ts +0 -8
  80. package/out/providers/api-provider.lua +0 -17
  81. package/out/providers/options-provider.d.ts +0 -13
  82. package/out/providers/options-provider.lua +0 -39
  83. package/out/providers/root-provider.d.ts +0 -11
  84. package/out/providers/root-provider.lua +0 -24
  85. package/out/store/app/app-selectors.d.ts +0 -2
  86. package/out/store/app/app-selectors.lua +0 -7
  87. package/out/store/app/app-slice.d.ts +0 -8
  88. package/out/store/app/app-slice.lua +0 -17
  89. package/out/store/app/index.d.ts +0 -2
  90. package/out/store/app/init.lua +0 -10
  91. package/out/store/command/command-selectors.d.ts +0 -2
  92. package/out/store/command/command-selectors.lua +0 -7
  93. package/out/store/command/command-slice.d.ts +0 -15
  94. package/out/store/command/command-slice.lua +0 -21
  95. package/out/store/command/index.d.ts +0 -2
  96. package/out/store/command/init.lua +0 -10
  97. package/out/store/history/history-slice.d.ts +0 -11
  98. package/out/store/history/history-slice.lua +0 -52
  99. package/out/store/history/index.d.ts +0 -1
  100. package/out/store/index.d.ts +0 -46
  101. package/out/store/init.lua +0 -18
  102. package/out/store/suggestion/index.d.ts +0 -2
  103. package/out/store/suggestion/init.lua +0 -10
  104. package/out/store/suggestion/suggestion-selectors.d.ts +0 -2
  105. package/out/store/suggestion/suggestion-selectors.lua +0 -7
  106. package/out/store/suggestion/suggestion-slice.d.ts +0 -9
  107. package/out/store/suggestion/suggestion-slice.lua +0 -15
  108. package/out/store/text/index.d.ts +0 -2
  109. package/out/store/text/init.lua +0 -10
  110. package/out/store/text/text-selectors.d.ts +0 -3
  111. package/out/store/text/text-selectors.lua +0 -11
  112. package/out/store/text/text-slice.d.ts +0 -20
  113. package/out/store/text/text-slice.lua +0 -29
@@ -0,0 +1,14 @@
1
+ type EventLike<T extends Callback = Callback> = {
2
+ Connect(callback: T): ConnectionLike;
3
+ } | {
4
+ connect(callback: T): ConnectionLike;
5
+ } | {
6
+ subscribe(callback: T): ConnectionLike;
7
+ };
8
+ type ConnectionLike = {
9
+ Disconnect(): void;
10
+ } | {
11
+ disconnect(): void;
12
+ } | (() => void);
13
+ export declare function useEvent<T extends EventLike>(event: T, listener: T extends EventLike<infer U> ? U : never): void;
14
+ export {};
@@ -0,0 +1,58 @@
1
+ -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
+ local TS = _G[script]
3
+ local cleanup = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).cleanup
4
+ local connect = function(event, callback)
5
+ local _event = event
6
+ if typeof(_event) == "RBXScriptSignal" then
7
+ -- With deferred events, a "hard disconnect" is necessary to avoid causing
8
+ -- state updates after a component unmounts. Use 'Connected' to check if
9
+ -- the connection is still valid before invoking the callback.
10
+ -- https://devforum.roblox.com/t/deferred-engine-events/2276564/99
11
+ local connection
12
+ connection = event:Connect(function(...)
13
+ local args = { ... }
14
+ if connection.Connected then
15
+ return callback(unpack(args))
16
+ end
17
+ end)
18
+ return connection
19
+ end
20
+ if event.Connect ~= nil then
21
+ return event:Connect(callback)
22
+ end
23
+ if event.connect ~= nil then
24
+ return event:connect(callback)
25
+ end
26
+ if event.subscribe ~= nil then
27
+ return event:subscribe(callback)
28
+ end
29
+ error("Event-like object does not have a supported connect method.")
30
+ end
31
+ local disconnect = function(connection)
32
+ local _connection = connection
33
+ if type(_connection) == "function" then
34
+ connection()
35
+ else
36
+ local _connection_1 = connection
37
+ local _condition = typeof(_connection_1) == "RBXScriptConnection"
38
+ if not _condition then
39
+ _condition = connection.Disconnect ~= nil
40
+ end
41
+ if _condition then
42
+ connection:Disconnect()
43
+ elseif connection.disconnect ~= nil then
44
+ connection:disconnect()
45
+ else
46
+ error("Connection-like object does not have a supported disconnect method.")
47
+ end
48
+ end
49
+ end
50
+ local function useEvent(event, listener)
51
+ local connection = connect(event, listener)
52
+ cleanup(function()
53
+ disconnect(connection)
54
+ end)
55
+ end
56
+ return {
57
+ useEvent = useEvent,
58
+ }
@@ -0,0 +1,2 @@
1
+ import { HistoryData } from "../types";
2
+ export declare function useHistory(): () => HistoryData;
@@ -0,0 +1,56 @@
1
+ -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
+ local TS = _G[script]
3
+ local TextService = TS.import(script, TS.getModule(script, "@rbxts", "services")).TextService
4
+ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
+ local cleanup = _vide.cleanup
6
+ local derive = _vide.derive
7
+ local source = _vide.source
8
+ local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
9
+ local interfaceOptions = TS.import(script, script.Parent.Parent, "store").interfaceOptions
10
+ local getAPI = TS.import(script, script.Parent, "use-api").getAPI
11
+ local useAtom = TS.import(script, script.Parent, "use-atom").useAtom
12
+ local useEvent = TS.import(script, script.Parent, "use-event").useEvent
13
+ local px = TS.import(script, script.Parent, "use-px").px
14
+ local function useHistory()
15
+ local api = getAPI()
16
+ local options = useAtom(interfaceOptions)
17
+ local history = source(api.dispatcher:getHistory())
18
+ useEvent(api.dispatcher.historyUpdated, function(entries)
19
+ local _array = {}
20
+ local _length = #_array
21
+ table.move(entries, 1, #entries, _length + 1, _array)
22
+ return history(_array)
23
+ end)
24
+ local textBoundsParams = Instance.new("GetTextBoundsParams")
25
+ textBoundsParams.Width = math.huge
26
+ textBoundsParams.RichText = true
27
+ cleanup(function()
28
+ textBoundsParams:Destroy()
29
+ end)
30
+ return derive(function()
31
+ local entries = history()
32
+ local historySize = #entries
33
+ local totalHeight = if historySize > 0 then px(8) + (historySize - 1) * px(8) else 0
34
+ textBoundsParams.Size = HISTORY_TEXT_SIZE
35
+ textBoundsParams.Font = options().font.regular
36
+ local historyLines = {}
37
+ for _, entry in entries do
38
+ textBoundsParams.Text = entry.text
39
+ local textSize = TextService:GetTextBoundsAsync(textBoundsParams)
40
+ local lineHeight = px(textSize.Y + 4)
41
+ totalHeight += lineHeight
42
+ local _arg0 = {
43
+ entry = entry,
44
+ height = lineHeight,
45
+ }
46
+ table.insert(historyLines, _arg0)
47
+ end
48
+ return {
49
+ lines = historyLines,
50
+ height = totalHeight,
51
+ }
52
+ end)
53
+ end
54
+ return {
55
+ useHistory = useHistory,
56
+ }
@@ -1,4 +1,4 @@
1
- import { Binding } from "@rbxts/react";
2
- import { Motion, MotionGoal } from "@rbxts/ripple";
3
- export declare function useMotion(initialValue: number): LuaTuple<[Binding<number>, Motion]>;
4
- export declare function useMotion<T extends MotionGoal>(initialValue: T): LuaTuple<[Binding<T>, Motion<T>]>;
1
+ import { MotionGoal } from "@rbxts/ripple";
2
+ type NonStrict<T> = T extends number ? number : T;
3
+ export declare function useMotion<T extends MotionGoal>(initialValue: NonStrict<T>): LuaTuple<[import("@rbxts/vide").Source<NonStrict<T>>, import("@rbxts/ripple").Motion<NonStrict<T>>]>;
4
+ export {};
@@ -1,23 +1,18 @@
1
1
  -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
2
  local TS = _G[script]
3
- local useEventListener = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out).useEventListener
4
- local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
5
- local useBinding = _react.useBinding
6
- local useMemo = _react.useMemo
7
3
  local createMotion = TS.import(script, TS.getModule(script, "@rbxts", "ripple").src).createMotion
8
- local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
4
+ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
+ local cleanup = _vide.cleanup
6
+ local source = _vide.source
9
7
  local function useMotion(initialValue)
10
- local motion = useMemo(function()
11
- return createMotion(initialValue)
12
- end, {})
13
- local binding, setValue = useBinding(initialValue)
14
- useEventListener(RunService.Heartbeat, function(delta)
15
- local value = motion:step(delta)
16
- if value ~= binding:getValue() then
17
- setValue(value)
18
- end
8
+ local motion = createMotion(initialValue)
9
+ local state = source(initialValue)
10
+ motion:onStep(state)
11
+ motion:start()
12
+ cleanup(function()
13
+ motion:stop()
19
14
  end)
20
- return binding, motion
15
+ return state, motion
21
16
  end
22
17
  return {
23
18
  useMotion = useMotion,
@@ -20,5 +20,17 @@ interface ScaleFunction {
20
20
  */
21
21
  ceil: (pixels: number) => number;
22
22
  }
23
- export declare function usePx(): ScaleFunction;
23
+ /**
24
+ * Rounds and scales a number to the current `px` unit. Includes additional
25
+ * methods for edge cases.
26
+ *
27
+ * @param value The number to scale.
28
+ * @returns A number in scaled `px` units.
29
+ */
30
+ export declare const px: ScaleFunction;
31
+ /**
32
+ * Scales the current `px` unit based on the current viewport size. Should be
33
+ * called once in `Vide.mount`.
34
+ */
35
+ export declare function usePx(): void;
24
36
  export {};
@@ -1,56 +1,69 @@
1
1
  -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
2
  local TS = _G[script]
3
- local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
4
- local useCamera = _pretty_react_hooks.useCamera
5
- local useDebounceState = _pretty_react_hooks.useDebounceState
6
- local useEventListener = _pretty_react_hooks.useEventListener
7
- local useMemo = TS.import(script, TS.getModule(script, "@rbxts", "react")).useMemo
3
+ local Workspace = TS.import(script, TS.getModule(script, "@rbxts", "services")).Workspace
4
+ local debounce = TS.import(script, TS.getModule(script, "@rbxts", "set-timeout").out).debounce
5
+ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
6
+ local cleanup = _vide.cleanup
7
+ local source = _vide.source
8
+ local useEvent = TS.import(script, script.Parent, "use-event").useEvent
8
9
  local BASE_RESOLUTION = Vector2.new(1280, 832)
9
10
  local MIN_SCALE = 0.75
10
11
  local DOMINANT_AXIS = 0.5
12
+ local scale = source(1)
11
13
  --[[
12
14
  *
13
- * @see https://discord.com/channels/476080952636997633/476080952636997635/1146857136358432900
15
+ * Rounds and scales a number to the current `px` unit. Includes additional
16
+ * methods for edge cases.
17
+ *
18
+ * @param value The number to scale.
19
+ * @returns A number in scaled `px` units.
20
+
21
+ ]]
22
+ local px = setmetatable({
23
+ even = function(value)
24
+ return math.round(value * scale() * 0.5) * 2
25
+ end,
26
+ scale = function(value)
27
+ return value * scale()
28
+ end,
29
+ floor = function(value)
30
+ return math.floor(value * scale())
31
+ end,
32
+ ceil = function(value)
33
+ return math.ceil(value * scale())
34
+ end,
35
+ }, {
36
+ __call = function(_, value)
37
+ return math.round(value * scale())
38
+ end,
39
+ })
40
+ --[[
41
+ *
42
+ * Scales the current `px` unit based on the current viewport size. Should be
43
+ * called once in `Vide.mount`.
14
44
 
15
45
  ]]
16
- local function calculateScale(viewport)
17
- local width = math.log(viewport.X / BASE_RESOLUTION.X, 2)
18
- local height = math.log(viewport.Y / BASE_RESOLUTION.Y, 2)
19
- local centered = width + (height - width) * DOMINANT_AXIS
20
- return math.max(2 ^ centered, MIN_SCALE)
21
- end
22
46
  local function usePx()
23
- local camera = useCamera()
24
- local scale, setScale = useDebounceState(calculateScale(camera.ViewportSize), {
25
- wait = 0.2,
47
+ local camera = Workspace.CurrentCamera
48
+ assert(camera, "CurrentCamera is not set")
49
+ local updateScale = debounce(function()
50
+ local viewport = camera.ViewportSize
51
+ local width = math.log(viewport.X / BASE_RESOLUTION.X, 2)
52
+ local height = math.log(viewport.Y / BASE_RESOLUTION.Y, 2)
53
+ local centered = width + (height - width) * DOMINANT_AXIS
54
+ scale(math.max(2 ^ centered, MIN_SCALE))
55
+ end, 0.2, {
26
56
  leading = true,
27
57
  })
28
- useEventListener(camera:GetPropertyChangedSignal("ViewportSize"), function()
29
- setScale(calculateScale(camera.ViewportSize))
58
+ cleanup(function()
59
+ updateScale.cancel()
60
+ end)
61
+ useEvent(camera:GetPropertyChangedSignal("ViewportSize"), function()
62
+ updateScale()
30
63
  end)
31
- return useMemo(function()
32
- local api = {
33
- even = function(value)
34
- return math.round(value * scale * 0.5) * 2
35
- end,
36
- scale = function(value)
37
- return value * scale
38
- end,
39
- floor = function(value)
40
- return math.floor(value * scale)
41
- end,
42
- ceil = function(value)
43
- return math.ceil(value * scale)
44
- end,
45
- }
46
- setmetatable(api, {
47
- __call = function(_, value)
48
- return math.round(value * scale)
49
- end,
50
- })
51
- return api
52
- end, { scale })
64
+ updateScale()
53
65
  end
54
66
  return {
55
67
  usePx = usePx,
68
+ px = px,
56
69
  }
package/out/store.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { ImmutableRegistryPath } from "@rbxts/centurion";
2
+ import { InterfaceOptions, Suggestion } from "./types";
3
+ export declare const interfaceVisible: import("@rbxts/charm").Atom<boolean>;
4
+ export declare const interfaceOptions: import("@rbxts/charm").Atom<InterfaceOptions>;
5
+ export declare const mouseOverInterface: import("@rbxts/charm").Atom<boolean>;
6
+ export declare const currentCommandPath: import("@rbxts/charm").Atom<ImmutableRegistryPath | undefined>;
7
+ export declare const currentArgIndex: import("@rbxts/charm").Atom<number | undefined>;
8
+ export declare const commandHistory: import("@rbxts/charm").Atom<string[]>;
9
+ export declare const commandHistoryIndex: import("@rbxts/charm").Atom<number>;
10
+ export declare const currentSuggestion: import("@rbxts/charm").Atom<Suggestion | undefined>;
11
+ export declare const terminalText: import("@rbxts/charm").Atom<string>;
12
+ export declare const terminalTextParts: import("@rbxts/charm").Molecule<string[]>;
13
+ export declare const currentTextPart: import("@rbxts/charm").Molecule<string | undefined>;
14
+ export declare const terminalTextValid: import("@rbxts/charm").Atom<boolean>;
package/out/store.lua ADDED
@@ -0,0 +1,44 @@
1
+ -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
+ local TS = _G[script]
3
+ local splitString = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.string).splitString
4
+ local _charm = TS.import(script, TS.getModule(script, "@rbxts", "charm").src)
5
+ local atom = _charm.atom
6
+ local computed = _charm.computed
7
+ local DEFAULT_INTERFACE_OPTIONS = TS.import(script, script.Parent, "constants", "options").DEFAULT_INTERFACE_OPTIONS
8
+ local interfaceVisible = atom(false)
9
+ local interfaceOptions = atom(DEFAULT_INTERFACE_OPTIONS)
10
+ local mouseOverInterface = atom(false)
11
+ local currentCommandPath = atom(nil)
12
+ local currentArgIndex = atom(nil)
13
+ local commandHistory = atom({})
14
+ local commandHistoryIndex = atom(-1)
15
+ local currentSuggestion = atom(nil)
16
+ local terminalText = atom("")
17
+ local terminalTextParts = computed(function()
18
+ return splitString(terminalText(), " ")
19
+ end)
20
+ local currentTextPart = computed(function()
21
+ local text = terminalText()
22
+ local textParts = terminalTextParts()
23
+ local endsWithSpace = #textParts > 0 and #{ string.match(text, "%s$") } > 0
24
+ local index = if endsWithSpace then #textParts else #textParts - 1
25
+ if index == -1 or index >= #textParts then
26
+ return nil
27
+ end
28
+ return textParts[index + 1]
29
+ end)
30
+ local terminalTextValid = atom(false)
31
+ return {
32
+ interfaceVisible = interfaceVisible,
33
+ interfaceOptions = interfaceOptions,
34
+ mouseOverInterface = mouseOverInterface,
35
+ currentCommandPath = currentCommandPath,
36
+ currentArgIndex = currentArgIndex,
37
+ commandHistory = commandHistory,
38
+ commandHistoryIndex = commandHistoryIndex,
39
+ currentSuggestion = currentSuggestion,
40
+ terminalText = terminalText,
41
+ terminalTextParts = terminalTextParts,
42
+ currentTextPart = currentTextPart,
43
+ terminalTextValid = terminalTextValid,
44
+ }
package/out/types.d.ts CHANGED
@@ -20,21 +20,24 @@ export interface HistoryLineData {
20
20
  entry: HistoryEntry;
21
21
  height: number;
22
22
  }
23
+ export interface HistoryData {
24
+ lines: HistoryLineData[];
25
+ height: number;
26
+ }
23
27
  export interface CommandSuggestion {
24
28
  type: "command";
25
29
  title: string;
30
+ others: string[];
26
31
  description?: string;
27
32
  shortcuts?: CommandShortcut[];
28
33
  }
29
34
  export interface ArgumentSuggestion {
30
35
  type: "argument";
31
36
  title: string;
37
+ others: string[];
32
38
  description?: string;
33
39
  dataType: string;
34
40
  optional: boolean;
35
41
  error?: string;
36
42
  }
37
- export interface Suggestion {
38
- main: ArgumentSuggestion | CommandSuggestion;
39
- others: string[];
40
- }
43
+ export type Suggestion = CommandSuggestion | ArgumentSuggestion;
@@ -1,2 +1,3 @@
1
- import { BaseRegistry, RegistryPath } from "@rbxts/centurion";
1
+ import { BaseRegistry, ImmutableRegistryPath, RegistryPath } from "@rbxts/centurion";
2
2
  export declare function getArgumentNames(registry: BaseRegistry, path: RegistryPath): string[];
3
+ export declare function getMissingArgs(registry: BaseRegistry, path: ImmutableRegistryPath, text: string[]): string[];
@@ -21,6 +21,31 @@ local function getArgumentNames(registry, path)
21
21
  -- ▲ ReadonlyArray.map ▲
22
22
  return _newValue
23
23
  end
24
+ local function getMissingArgs(registry, path, text)
25
+ local _commandOptions = registry:getCommand(path)
26
+ if _commandOptions ~= nil then
27
+ _commandOptions = _commandOptions.options
28
+ end
29
+ local commandOptions = _commandOptions
30
+ if commandOptions == nil or commandOptions.arguments == nil or #commandOptions.arguments == 0 then
31
+ return {}
32
+ end
33
+ local lastPartIndex = #text - path:size() - 1
34
+ local missingArgs = {}
35
+ local index = 0
36
+ for _, arg in commandOptions.arguments do
37
+ if arg.optional then
38
+ break
39
+ end
40
+ if index > lastPartIndex then
41
+ local _name = arg.name
42
+ table.insert(missingArgs, _name)
43
+ end
44
+ index += 1
45
+ end
46
+ return missingArgs
47
+ end
24
48
  return {
25
49
  getArgumentNames = getArgumentNames,
50
+ getMissingArgs = getMissingArgs,
26
51
  }
@@ -1,4 +1,4 @@
1
1
  import { BaseRegistry, RegistryPath } from "@rbxts/centurion";
2
- import { Suggestion } from "../types";
3
- export declare function getArgumentSuggestion(registry: BaseRegistry, path: RegistryPath, index: number, text?: string): Suggestion | undefined;
2
+ import { ArgumentSuggestion, Suggestion } from "../types";
3
+ export declare function getArgumentSuggestion(registry: BaseRegistry, path: RegistryPath, index: number, text?: string): ArgumentSuggestion | undefined;
4
4
  export declare function getCommandSuggestion(registry: BaseRegistry, parentPath?: RegistryPath, text?: string): Suggestion | undefined;
@@ -120,23 +120,20 @@ local function getArgumentSuggestion(registry, path, index, text)
120
120
  end
121
121
  -- ▲ ReadonlyArray.map ▲
122
122
  local otherSuggestions = _newValue
123
- local _object = {}
124
- local _left = "main"
125
- local _object_1 = {
123
+ local _object = {
126
124
  type = "argument",
127
125
  title = arg.name,
126
+ others = otherSuggestions,
128
127
  description = arg.description,
129
128
  dataType = typeObject.name,
130
129
  }
131
- local _left_1 = "optional"
130
+ local _left = "optional"
132
131
  local _condition = arg.optional
133
132
  if _condition == nil then
134
133
  _condition = false
135
134
  end
136
- _object_1[_left_1] = _condition
137
- _object_1.error = errorText
138
- _object[_left] = _object_1
139
- _object.others = otherSuggestions
135
+ _object[_left] = _condition
136
+ _object.error = errorText
140
137
  return _object
141
138
  end
142
139
  local function getCommandSuggestion(registry, parentPath, text)
@@ -193,13 +190,11 @@ local function getCommandSuggestion(registry, parentPath, text)
193
190
  end
194
191
  local otherNames = _result_1
195
192
  return {
196
- main = {
197
- type = "command",
198
- title = firstPath:tail(),
199
- description = mainData.description,
200
- shortcuts = mainData.shortcuts,
201
- },
193
+ type = "command",
194
+ title = firstPath:tail(),
202
195
  others = otherNames,
196
+ description = mainData.description,
197
+ shortcuts = mainData.shortcuts,
203
198
  }
204
199
  end
205
200
  return {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rbxts/centurion-ui",
3
- "version": "1.0.0-dev-dacc7af",
3
+ "description": "Terminal UI for the Centurion command framework",
4
+ "version": "1.0.0-dev-a7b777e",
4
5
  "author": "paradoxuum",
5
6
  "license": "MIT",
6
7
  "main": "out/init.lua",
@@ -8,8 +9,7 @@
8
9
  "files": [
9
10
  "out",
10
11
  "!**/*.tsbuildinfo",
11
- "!**/__tests__",
12
- "!**/app/config*"
12
+ "!**/__tests__"
13
13
  ],
14
14
  "keywords": [
15
15
  "roblox",
@@ -28,28 +28,27 @@
28
28
  },
29
29
  "scripts": {
30
30
  "prepack": "yarn build",
31
- "build": "shx rm -rf out && rbxtsc --verbose"
31
+ "build": "shx rm -rf out && rbxtsc --verbose",
32
+ "dev": "shx rm -rf out && rbxtsc -w"
32
33
  },
33
34
  "devDependencies": {
34
- "@rbxts/centurion": "^1.0.0-dev-dacc7af",
35
+ "@rbxts/centurion": "^1.0.0-dev-a7b777e",
35
36
  "@rbxts/compiler-types": "2.3.0-types.1",
36
- "@rbxts/types": "^1.0.789",
37
+ "@rbxts/types": "^1.0.790",
37
38
  "roblox-ts": "2.3.0-dev-26ec859",
38
39
  "shx": "^0.3.4",
39
40
  "typescript": "~5.5.3"
40
41
  },
41
42
  "dependencies": {
42
43
  "@rbxts/beacon": "^2.1.1",
43
- "@rbxts/pretty-react-hooks": "^0.5.2",
44
- "@rbxts/react": "^0.4.0",
45
- "@rbxts/react-reflex": "^0.3.4",
46
- "@rbxts/react-roblox": "^0.4.0",
47
- "@rbxts/reflex": "^4.3.1",
44
+ "@rbxts/charm": "^0.5.2",
48
45
  "@rbxts/ripple": "^0.8.2",
49
- "@rbxts/services": "^1.5.4"
46
+ "@rbxts/services": "^1.5.4",
47
+ "@rbxts/set-timeout": "^1.1.2",
48
+ "@rbxts/vide": "^0.4.1"
50
49
  },
51
50
  "peerDependencies": {
52
- "@rbxts/centurion": "^1.0.0-dev-dacc7af"
51
+ "@rbxts/centurion": "^1.0.0-dev-a7b777e"
53
52
  },
54
53
  "stableVersion": "0.1.0"
55
54
  }
package/out/app/app.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { ClientAPI } from "@rbxts/centurion";
2
- import { InterfaceOptions } from "../types";
3
- export declare namespace CenturionUI {
4
- function updateOptions(options: Partial<InterfaceOptions>): void;
5
- function create(options?: Partial<InterfaceOptions>): (api: ClientAPI) => void;
6
- }
package/out/app/app.lua DELETED
@@ -1,83 +0,0 @@
1
- -- Compiled with roblox-ts v2.3.0-dev-26ec859
2
- local TS = _G[script]
3
- local _config = script.Parent
4
- if _config ~= nil then
5
- _config = _config:FindFirstChild("config")
6
- end
7
- local config = _config
8
- if config ~= nil and config.ClassName == "ModuleScript" then
9
- require(config)
10
- end
11
- local Signal = TS.import(script, TS.getModule(script, "@rbxts", "beacon").out).Signal
12
- local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
13
- local React = _react
14
- local StrictMode = _react.StrictMode
15
- local _react_roblox = TS.import(script, TS.getModule(script, "@rbxts", "react-roblox"))
16
- local createPortal = _react_roblox.createPortal
17
- local createRoot = _react_roblox.createRoot
18
- local _services = TS.import(script, TS.getModule(script, "@rbxts", "services"))
19
- local ContentProvider = _services.ContentProvider
20
- local Players = _services.Players
21
- local DEFAULT_INTERFACE_OPTIONS = TS.import(script, script.Parent.Parent, "constants", "options").DEFAULT_INTERFACE_OPTIONS
22
- local RootProvider = TS.import(script, script.Parent.Parent, "providers", "root-provider").RootProvider
23
- local TerminalApp = TS.import(script, script.Parent, "terminal-app").TerminalApp
24
- local CenturionUI = {}
25
- do
26
- local _container = CenturionUI
27
- local MAX_PRELOAD_ATTEMPTS = 3
28
- local PRELOAD_ATTEMPT_INTERVAL = 3
29
- local optionsChanged = Signal.new()
30
- local function updateOptions(options)
31
- optionsChanged:Fire(options)
32
- end
33
- _container.updateOptions = updateOptions
34
- local function create(options)
35
- if options == nil then
36
- options = {}
37
- end
38
- return function(api)
39
- local root = createRoot(Instance.new("Folder"))
40
- local target = Players.LocalPlayer:WaitForChild("PlayerGui")
41
- -- Attempt to preload font
42
- task.spawn(function()
43
- local _result = options.font
44
- if _result ~= nil then
45
- _result = _result.regular
46
- end
47
- local _condition = _result
48
- if _condition == nil then
49
- _condition = DEFAULT_INTERFACE_OPTIONS.font.regular
50
- end
51
- local fontFamily = _condition.Family
52
- local attempts = 0
53
- while attempts < MAX_PRELOAD_ATTEMPTS do
54
- ContentProvider:PreloadAsync({ fontFamily }, function(_, status)
55
- if status == Enum.AssetFetchStatus.Success then
56
- attempts = MAX_PRELOAD_ATTEMPTS
57
- end
58
- end)
59
- if attempts == MAX_PRELOAD_ATTEMPTS then
60
- break
61
- end
62
- task.wait(PRELOAD_ATTEMPT_INTERVAL)
63
- attempts += 1
64
- end
65
- end)
66
- local _attributes = {
67
- api = api,
68
- }
69
- local _object = table.clone(DEFAULT_INTERFACE_OPTIONS)
70
- setmetatable(_object, nil)
71
- for _k, _v in options do
72
- _object[_k] = _v
73
- end
74
- _attributes.options = _object
75
- _attributes.optionsChanged = optionsChanged
76
- root:render(createPortal(React.createElement(StrictMode, nil, React.createElement(RootProvider, _attributes, React.createElement(TerminalApp))), target))
77
- end
78
- end
79
- _container.create = create
80
- end
81
- return {
82
- CenturionUI = CenturionUI,
83
- }
@@ -1 +0,0 @@
1
- export declare function TerminalApp(): JSX.Element;