chore: prepare release, set up workflows

This commit is contained in:
Richard 2024-10-12 17:46:07 -07:00
parent 0416717f6c
commit a5d38b0d6d
58 changed files with 261 additions and 110 deletions

3
modules/vide/.luaurc Normal file
View file

@ -0,0 +1,3 @@
{
"languageMode": "strict"
}

View file

@ -0,0 +1,6 @@
{
"name": "vide-charm",
"tree": {
"$path": "src"
}
}

19
modules/vide/package.json Normal file
View file

@ -0,0 +1,19 @@
{
"name": "@rbxts/vide-charm",
"version": "0.1.0",
"description": "Vide bindings for Charm",
"repository": "littensy/charm",
"license": "MIT",
"main": "src/init.luau",
"types": "src/index.d.ts",
"scripts": {
"prepare": "cp ../../LICENSE.md . && cp ../../README.md .",
"publish:wally": "wally publish"
},
"dependencies": {
"@rbxts/charm": "workspace:*"
},
"peerDependencies": {
"@rbxts/vide": "*"
}
}

9
modules/vide/src/index.d.ts vendored Normal file
View file

@ -0,0 +1,9 @@
import { Molecule } from "@rbxts/charm";
/**
* Subscribes to the state of an atom and returns a Vide source.
*
* @param molecule The atom or molecule to subscribe to.
* @returns The reactive source.
*/
export function useAtom<T>(atom: Molecule<T>): () => T;

View file

@ -0,0 +1,23 @@
local Charm = require(script.Parent.Charm)
local Vide = require(script.Parent.Vide)
--[=[
Subscribes to the state of an atom and returns a Vide source.
@param molecule The atom or molecule to subscribe to.
@return The reactive source.
]=]
local function useAtom<State>(molecule: () -> State): State
local state = Vide.source(molecule())
local unsubscribe = Charm.subscribe(molecule, function(value)
task.spawn(state, value)
end)
Vide.cleanup(unsubscribe)
return state
end
return {
useAtom = useAtom,
}

7
modules/vide/wally.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "littensy/vide-charm"
version = "0.1.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
[dependencies]