@rbxts/app-forge 0.4.3 → 0.4.4

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.
@@ -3,9 +3,8 @@ local TS = _G[script]
3
3
  -- Services
4
4
  local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
5
5
  -- Packages
6
- local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
7
- local React = _react
8
- local useBinding = _react.useBinding
6
+ local atom = TS.import(script, TS.getModule(script, "@rbxts", "charm")).atom
7
+ local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
9
8
  -- Types
10
9
  -- Components
11
10
  local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
@@ -19,11 +18,11 @@ local function createBinding(name, manager)
19
18
  if _condition == nil then
20
19
  _condition = false
21
20
  end
22
- local binding = { useBinding(_condition) }
23
- local _binds = manager.binds
21
+ local binding = atom(_condition)
22
+ local _atoms = manager.atoms
24
23
  local _name_1 = name
25
- _binds[_name_1] = binding
26
- return unpack(binding)
24
+ _atoms[_name_1] = binding
25
+ return binding
27
26
  end
28
27
  local function createInstance(props)
29
28
  local _binding = props
@@ -1,4 +1,4 @@
1
- import React from "@rbxts/react";
1
+ import type { Atom } from "@rbxts/charm";
2
2
  import type Types from "./types";
3
3
  import type AppForge from ".";
4
4
  export declare const AppRegistry: Map<string, Types.AppRegistry>;
@@ -7,8 +7,7 @@ export declare abstract class Args {
7
7
  readonly forge: AppForge;
8
8
  readonly props: Types.ClassProps;
9
9
  readonly name: AppNames[number];
10
- readonly bind: React.Binding<boolean>;
11
- readonly state: Boolean;
10
+ readonly atom: Atom<boolean>;
12
11
  constructor(props: Types.NameProps & Types.MainProps);
13
12
  abstract render(): JSX.Element;
14
13
  }
@@ -4,6 +4,7 @@ local TS = _G[script]
4
4
  local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
5
5
  -- Packages
6
6
  local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
7
+ local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "react-charm")).useAtom
7
8
  -- Types
8
9
  local AppRegistry = {}
9
10
  local function App(props)
@@ -33,9 +34,9 @@ do
33
34
  if not (name ~= "" and name) then
34
35
  error("App name is required in Args constructor")
35
36
  end
36
- local bind = forge:getBind(name)
37
- if not bind and RunService:IsRunning() then
38
- error("FAILED TO GET BIND FOR APP!")
37
+ local atom = forge:getAtom(name)
38
+ if not atom and RunService:IsRunning() then
39
+ error("FAILED TO GET ATOM FOR APP!")
39
40
  end
40
41
  local px = usePx(target)
41
42
  self.forge = forge
@@ -44,8 +45,9 @@ do
44
45
  _object.px = px
45
46
  self.props = _object
46
47
  self.name = name
47
- self.bind = bind
48
- self.state = if self.bind then self.bind:getValue() else nil
48
+ self.atom = useAtom(function()
49
+ return atom
50
+ end)
49
51
  end
50
52
  end
51
53
  return {
package/out/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import React from "@rbxts/react";
2
+ import type { Atom } from "@rbxts/charm";
2
3
  import type Types from "./types";
3
4
  import { Args, App } from "./decorator";
4
5
  export default class AppForge {
5
- binds: Map<string, [React.Binding<boolean>, (T: boolean) => void]>;
6
+ atoms: Map<string, Atom<boolean>>;
6
7
  loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
7
8
  private rulesManager;
8
- getBind(name: AppNames[number]): React.Binding<boolean> | undefined;
9
- getState(name: AppNames[number]): boolean | undefined;
9
+ getAtom(name: AppNames[number]): Atom<boolean> | undefined;
10
+ getState(name: AppNames[number]): Atom<boolean>;
10
11
  set(name: AppNames[number], value: boolean): void;
11
12
  open(name: AppNames[number]): void;
12
13
  close(name: AppNames[number]): void;
package/out/init.luau CHANGED
@@ -26,49 +26,43 @@ do
26
26
  return self:constructor(...) or self
27
27
  end
28
28
  function AppForge:constructor()
29
- self.binds = {}
29
+ self.atoms = {}
30
30
  self.loaded = {}
31
31
  self.rulesManager = RulesManager.new(self)
32
32
  end
33
- function AppForge:getBind(name)
33
+ function AppForge:getAtom(name)
34
34
  local _condition = not RunService:IsRunning()
35
35
  if _condition then
36
- local _binds = self.binds
36
+ local _atoms = self.atoms
37
37
  local _name = name
38
- _condition = not (_binds[_name] ~= nil)
38
+ _condition = not (_atoms[_name] ~= nil)
39
39
  end
40
40
  if _condition then
41
41
  return nil
42
42
  end
43
- local _binds = self.binds
43
+ local _atoms = self.atoms
44
44
  local _name = name
45
- if not (_binds[_name] ~= nil) then
45
+ if not (_atoms[_name] ~= nil) then
46
46
  error(`App "{name}" has no binding`)
47
47
  end
48
- local _binds_1 = self.binds
48
+ local _atoms_1 = self.atoms
49
49
  local _name_1 = name
50
- return _binds_1[_name_1][1]
50
+ return _atoms_1[_name_1]
51
51
  end
52
52
  function AppForge:getState(name)
53
- local _result = self:getBind(name)
54
- if _result ~= nil then
55
- _result = _result:getValue()
56
- end
57
- return _result
53
+ return self:getAtom(name)
58
54
  end
59
55
  function AppForge:set(name, value)
60
56
  if not self.rulesManager:applyRules(name, value) then
61
57
  return nil
62
58
  end
63
- local _binds = self.binds
59
+ local _atoms = self.atoms
64
60
  local _name = name
65
- local _binding = _binds[_name]
66
- local _ = _binding[1]
67
- local setBinding = _binding[2]
68
- if not setBinding then
61
+ local atom = _atoms[_name]
62
+ if not atom then
69
63
  error(`App "{name}" has no binding setter`)
70
64
  end
71
- setBinding(value)
65
+ atom(value)
72
66
  end
73
67
  function AppForge:open(name)
74
68
  self:set(name, true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "An App Manager for react",
5
5
  "main": "out/init.lua",
6
6
  "packageManager": "bun@1.3.1",
@@ -54,6 +54,7 @@
54
54
  "peerDependencies": {
55
55
  "@rbxts/loners-pretty-react-hooks": "*",
56
56
  "@rbxts/react-roblox": "*",
57
- "@rbxts/react": "*"
57
+ "@rbxts/react": "*",
58
+ "@rbxts/charm": "*"
58
59
  }
59
60
  }