@rbxts/centurion-ui 1.0.2 → 1.0.3

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.
@@ -4,12 +4,12 @@ local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "servi
4
4
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
5
  local Vide = _vide
6
6
  local derive = _vide.derive
7
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
8
  local _components = TS.import(script, script.Parent.Parent, "components")
8
9
  local Suggestions = _components.Suggestions
9
10
  local Terminal = _components.Terminal
10
11
  local Group = TS.import(script, script.Parent.Parent, "components", "ui", "group").Group
11
12
  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
13
  local useClient = TS.import(script, script.Parent.Parent, "hooks", "use-client").useClient
14
14
  local useEvent = TS.import(script, script.Parent.Parent, "hooks", "use-event").useEvent
15
15
  local _use_px = TS.import(script, script.Parent.Parent, "hooks", "use-px")
@@ -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
@@ -16,14 +16,35 @@ 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
27
  return interfaceVisible()
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
  interfaceVisible(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
49
  interfaceOptions(function(prev)
29
50
  local _object = table.clone(DEFAULT_INTERFACE_OPTIONS)
@@ -38,6 +59,17 @@ do
38
59
  end)
39
60
  end
40
61
  _container.updateOptions = updateOptions
62
+ --[[
63
+ *
64
+ * Mounts the terminal UI.
65
+ *
66
+ * If `registerBuiltInCommands` is **true** (default), client commands
67
+ * will be registered.
68
+ *
69
+ * @param client The Centurion client.
70
+ * @param options The terminal UI options.
71
+
72
+ ]]
41
73
  local registerCommands
42
74
  local function start(client, options)
43
75
  if options == nil then
@@ -3,8 +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 derive = _vide.derive
6
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
6
7
  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
8
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
9
9
  local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
10
10
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
@@ -5,7 +5,7 @@ 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
8
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
9
9
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
10
10
  local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
11
11
  local ScrollingFrame = TS.import(script, script.Parent.Parent, "ui", "scrolling-frame").ScrollingFrame
@@ -1,7 +1,7 @@
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
4
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
5
5
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
6
6
  local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
7
7
  local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
@@ -4,10 +4,10 @@ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
4
  local Vide = _vide
5
5
  local read = _vide.read
6
6
  local spring = _vide.spring
7
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
8
  local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
8
9
  local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
9
10
  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
11
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
12
12
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
13
13
  local interfaceOptions = _store.interfaceOptions
@@ -6,8 +6,8 @@ local Vide = _vide
6
6
  local derive = _vide.derive
7
7
  local For = _vide.For
8
8
  local read = _vide.read
9
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
9
10
  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
11
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
12
12
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
13
13
  local interfaceOptions = _store.interfaceOptions
@@ -7,10 +7,10 @@ local cleanup = _vide.cleanup
7
7
  local derive = _vide.derive
8
8
  local source = _vide.source
9
9
  local spring = _vide.spring
10
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
10
11
  local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
11
12
  local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
12
13
  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
14
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
15
15
  local useTextBounds = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-text-bounds").useTextBounds
16
16
  local _store = TS.import(script, script.Parent.Parent.Parent, "store")
@@ -171,7 +171,7 @@ local function getCommandSuggestion(registry, parentPath, text)
171
171
  end
172
172
  local _object = {
173
173
  type = "command",
174
- title = firstPath:tail(),
174
+ title = mainData.name,
175
175
  }
176
176
  local _left = "others"
177
177
  -- ▼ ReadonlyArray.map ▼
@@ -1,12 +1,12 @@
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
3
+ local subscribe = TS.import(script, TS.getModule(script, "@rbxts", "Charm")).subscribe
4
4
  local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "services")).UserInputService
5
5
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
6
6
  local Vide = _vide
7
7
  local cleanup = _vide.cleanup
8
8
  local source = _vide.source
9
- local useAtom = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-atom").useAtom
9
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
10
10
  local useClient = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-client").useClient
11
11
  local useEvent = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-event").useEvent
12
12
  local px = TS.import(script, script.Parent.Parent.Parent.Parent, "hooks", "use-px").px
@@ -8,8 +8,8 @@ local Vide = _vide
8
8
  local derive = _vide.derive
9
9
  local source = _vide.source
10
10
  local spring = _vide.spring
11
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
11
12
  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
13
  local useClient = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-client").useClient
14
14
  local useHistory = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-history").useHistory
15
15
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
@@ -3,7 +3,7 @@ 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
6
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
7
  local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
8
8
  local function TextField(props)
9
9
  local options = useAtom(interfaceOptions)
@@ -3,7 +3,7 @@ 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
6
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
7
7
  local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
8
8
  local interfaceOptions = TS.import(script, script.Parent.Parent.Parent, "store").interfaceOptions
9
9
  local function Text(props)
@@ -5,9 +5,9 @@ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
5
  local cleanup = _vide.cleanup
6
6
  local derive = _vide.derive
7
7
  local source = _vide.source
8
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "VideCharm")).useAtom
8
9
  local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
9
10
  local interfaceOptions = TS.import(script, script.Parent.Parent, "store").interfaceOptions
10
- local useAtom = TS.import(script, script.Parent, "use-atom").useAtom
11
11
  local useClient = TS.import(script, script.Parent, "use-client").useClient
12
12
  local useEvent = TS.import(script, script.Parent, "use-event").useEvent
13
13
  local px = TS.import(script, script.Parent, "use-px").px
@@ -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 derive = _vide.derive
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
- return derive(function()
21
+ effect(function()
17
22
  local textValue = read(text)
18
23
  if textValue == nil then
19
- return Vector2.zero
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
- return TextService:GetTextBoundsAsync(params)
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
@@ -8,7 +8,7 @@ export declare const commandArgIndex: import("@rbxts/charm").Atom<number | undef
8
8
  export declare const terminalArgIndex: import("@rbxts/charm").Atom<number | undefined>;
9
9
  export declare const currentSuggestion: import("@rbxts/charm").Atom<Suggestion | undefined>;
10
10
  export declare const terminalText: import("@rbxts/charm").Atom<string>;
11
- export declare const terminalTextParts: import("@rbxts/charm").Molecule<string[]>;
12
- export declare const atNextPart: import("@rbxts/charm").Molecule<boolean>;
11
+ export declare const terminalTextParts: import("@rbxts/charm").Selector<string[]>;
12
+ export declare const atNextPart: import("@rbxts/charm").Selector<boolean>;
13
13
  export declare const terminalTextValid: import("@rbxts/charm").Atom<boolean>;
14
14
  export declare const currentTextPart: import("@rbxts/charm").Atom<string | undefined>;
package/out/store.luau CHANGED
@@ -1,7 +1,7 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
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)
4
+ local _charm = TS.import(script, TS.getModule(script, "@rbxts", "Charm"))
5
5
  local atom = _charm.atom
6
6
  local computed = _charm.computed
7
7
  local DEFAULT_INTERFACE_OPTIONS = TS.import(script, script.Parent, "constants", "options").DEFAULT_INTERFACE_OPTIONS
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.2",
4
+ "version": "1.0.3",
5
5
  "author": "paradoxuum",
6
6
  "license": "MIT",
7
7
  "main": "out/init.lua",
@@ -32,20 +32,21 @@
32
32
  "dev": "shx rm -rf out && rbxtsc -w"
33
33
  },
34
34
  "devDependencies": {
35
- "@rbxts/centurion": "^1.0.0",
35
+ "@rbxts/centurion": "^1.0.1",
36
36
  "@rbxts/compiler-types": "3.0.0-types.0",
37
- "@rbxts/types": "^1.0.809",
37
+ "@rbxts/types": "^1.0.813",
38
38
  "roblox-ts": "3.0.0",
39
39
  "shx": "^0.3.4",
40
- "typescript": "=5.5.3"
40
+ "typescript": "5.5.3"
41
41
  },
42
42
  "dependencies": {
43
- "@rbxts/charm": "^0.7.5",
43
+ "@rbxts/charm": "^0.8.1",
44
44
  "@rbxts/services": "^1.5.5",
45
45
  "@rbxts/set-timeout": "^1.1.2",
46
- "@rbxts/vide": "^0.4.6"
46
+ "@rbxts/vide": "^0.5.0",
47
+ "@rbxts/vide-charm": "^0.1.1"
47
48
  },
48
49
  "peerDependencies": {
49
- "@rbxts/centurion": "^1.0.0"
50
+ "@rbxts/centurion": "^1.0.1"
50
51
  }
51
52
  }
@@ -1,2 +0,0 @@
1
- import { Molecule } from "@rbxts/charm";
2
- export declare function useAtom<T>(atom: Molecule<T>): import("@rbxts/vide").Source<T>;
@@ -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
- }