build: create project files for release

This commit is contained in:
littensy 2025-03-09 15:29:16 -07:00
parent aff5f768bf
commit b9d32ba4f2
13 changed files with 87 additions and 72 deletions

View file

@ -1,5 +1,14 @@
mkdir build
rojo build packages/charm -o build/charm.rbxm
rojo build packages/charm-sync -o build/charm-sync.rbxm
rojo build packages/react -o build/react-charm.rbxm
rojo build packages/vide -o build/vide-charm.rbxm
build() {
cat > packages/default.project.json <<EOF
{"name":"$1","globIgnorePaths":["**/node_modules","**/package.json","**/wally.toml"],"tree":{"\$path":"$1"}}
EOF
rojo build packages -o build/$1.rbxm
rm -rf packages/default.project.json
}
build charm
build charm-sync
build react
build vide

View file

@ -4,8 +4,8 @@
"description": "Sync server state with clients using Charm",
"repository": "littensy/charm",
"license": "MIT",
"main": "src/init.luau",
"types": "src/index.d.ts",
"main": "init.luau",
"types": "index.d.ts",
"scripts": {
"prepare": "cp ../../LICENSE.md . && cp ../../README.md .",
"publish:wally": "wally publish"

View file

@ -3,7 +3,8 @@ name = "littensy/charm-sync"
version = "0.2.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
exclude = ["package.json"]
exclude = ["package.json", "node_modules"]
include = ["LICENSE.md"]
[dependencies]
charm = "littensy/charm@^0.9"

View file

@ -4,8 +4,8 @@
"description": "An atomic state management library for Roblox",
"repository": "littensy/charm",
"license": "MIT",
"main": "src/init.luau",
"types": "src/index.d.ts",
"main": "init.luau",
"types": "index.d.ts",
"scripts": {
"prepare": "cp ../../LICENSE.md . && cp ../../README.md .",
"publish:wally": "wally publish"

View file

@ -3,6 +3,7 @@ name = "littensy/charm"
version = "0.9.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
exclude = ["package.json"]
exclude = ["package.json", "node_modules"]
include = ["LICENSE.md"]
[dependencies]

View file

@ -1,31 +1 @@
local Charm = require(script.Parent.charm)
local React = if script.Parent:FindFirstChild("React")
then require(script.Parent.React)
else require((script.Parent :: any).react) :: never
--[=[
A hook that subscribes to changes in the given atom or selector. The
component is re-rendered whenever the state changes.
If the `dependencies` array is provided, the subscription to the atom or
selector is re-created whenever the dependencies change. Otherwise, the
subscription is created once when the component is mounted.
@param callback The atom or selector to subscribe to.
@param dependencies An array of values that the subscription depends on.
@return The current state.
]=]
local function useAtom<State>(callback: Charm.Selector<State>, dependencies: { any }?): State
local state, setState = React.useState(callback)
React.useEffect(function()
setState(callback())
return Charm.subscribe(callback, setState)
end, dependencies or {})
return state
end
return {
useAtom = useAtom,
}
return require(script.src)

View file

@ -4,8 +4,8 @@
"description": "React bindings for Charm",
"repository": "littensy/charm",
"license": "MIT",
"main": "src/init.luau",
"types": "src/index.d.ts",
"main": "init.luau",
"types": "index.d.ts",
"scripts": {
"prepare": "cp ../../LICENSE.md . && cp ../../README.md .",
"publish:wally": "wally publish"

View file

@ -0,0 +1,31 @@
local Charm = require(script.Parent.Parent.charm)
local React = if script.Parent.Parent:FindFirstChild("React")
then require(script.Parent.Parent.React)
else require((script.Parent.Parent :: any).react) :: never
--[=[
A hook that subscribes to changes in the given atom or selector. The
component is re-rendered whenever the state changes.
If the `dependencies` array is provided, the subscription to the atom or
selector is re-created whenever the dependencies change. Otherwise, the
subscription is created once when the component is mounted.
@param callback The atom or selector to subscribe to.
@param dependencies An array of values that the subscription depends on.
@return The current state.
]=]
local function useAtom<State>(callback: Charm.Selector<State>, dependencies: { any }?): State
local state, setState = React.useState(callback)
React.useEffect(function()
setState(callback())
return Charm.subscribe(callback, setState)
end, dependencies or {})
return state
end
return {
useAtom = useAtom,
}

View file

@ -3,7 +3,8 @@ name = "littensy/react-charm"
version = "0.2.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
exclude = ["package.json"]
exclude = ["package.json", "node_modules"]
include = ["LICENSE.md"]
[dependencies]
charm = "littensy/charm@^0.9"

View file

@ -1,25 +1 @@
local Charm = require(script.Parent.charm)
local Vide = if script.Parent:FindFirstChild("Vide")
then require(script.Parent.Vide)
else require((script.Parent :: any).vide.src) :: never
--[=[
Subscribes to the state of an atom and returns a Vide source.
@param callback The atom or selector to subscribe to.
@return The reactive source.
]=]
local function useAtom<State>(callback: () -> State): () -> State
local state = Vide.source(callback())
local unsubscribe = Charm.subscribe(callback, function(value)
task.spawn(state :: (State) -> State, value)
end)
Vide.cleanup(unsubscribe)
return state
end
return {
useAtom = useAtom,
}
return require(script.src)

View file

@ -4,8 +4,8 @@
"description": "Vide bindings for Charm",
"repository": "littensy/charm",
"license": "MIT",
"main": "src/init.luau",
"types": "src/index.d.ts",
"main": "init.luau",
"types": "index.d.ts",
"scripts": {
"prepare": "cp ../../LICENSE.md . && cp ../../README.md .",
"publish:wally": "wally publish"

View file

@ -0,0 +1,25 @@
local Charm = require(script.Parent.Parent.charm)
local Vide = if script.Parent.Parent:FindFirstChild("Vide")
then require(script.Parent.Parent.Vide)
else require((script.Parent.Parent :: any).vide.src) :: never
--[=[
Subscribes to the state of an atom and returns a Vide source.
@param callback The atom or selector to subscribe to.
@return The reactive source.
]=]
local function useAtom<State>(callback: () -> State): () -> State
local state = Vide.source(callback())
local unsubscribe = Charm.subscribe(callback, function(value)
task.spawn(state :: (State) -> State, value)
end)
Vide.cleanup(unsubscribe)
return state
end
return {
useAtom = useAtom,
}

View file

@ -3,7 +3,8 @@ name = "littensy/vide-charm"
version = "0.2.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
exclude = ["package.json"]
exclude = ["package.json", "node_modules"]
include = ["LICENSE.md"]
[dependencies]
charm = "littensy/charm@^0.9"