-------------------------------------------------------------------------------------------------------------- -- vide.lua -- v0.1.0 -------------------------------------------------------------------------------------------------------------- if not game then script = (require :: any) "test/wrap-require" end local create = require(script.create) local apply = require(script.apply) local wrap = require(script.wrap) local watch = require(script.watch) local derive = require(script.derive) local map = require(script.map) local unwrap = require(script.unwrap) local wrapped = require(script.wrapped) local Layout = require(script.Layout) local Children = require(script.Children) local Event = require(script.Event) local Changed = require(script.Change) local Created = require(script.Created) local spring, updateSprings = require(script.spring)() local flags = require(script.flags) type Map = { [K]: V } type Unwrapper = (T) -> T type Setter = ( (new: T, force: true?) -> T ) & ( (update: (old: T) -> T, force: true?) -> T ) local vide = { -- core create = create, apply = apply, wrap = (wrap :: any) :: (value: T?) -> (T, Setter), derive = (derive :: any) :: (deriver: (from: (U) -> U) -> T, cleanup: (T) -> ()?) -> T, map = (map :: any) :: ( (input: number, transform: (number) -> V, cleanup: (V) -> ()?) -> Map ) & ( (input: Map, transform: (K, VI) -> VO, cleanup: (VO) -> ()?) -> Map ), watch = watch :: ((Unwrapper) -> ()) -> () -> (), -- util unwrap = unwrap, wrapped = wrapped, -- animations spring = (spring :: any) :: (input: T, period: number, damping: number?) -> T, -- symbols Event = Event, Changed = Changed, Layout = Layout, Children = Children, Created = Created, -- flags strict = (nil :: any) :: boolean, -- test step = function(dt: number) updateSprings(dt) end } setmetatable(vide :: any, { __index = function(_, index: unknown) error(string.format("\"%s\" is not a valid member of vide", tostring(index)), 2) end, __newindex = function(_, index: unknown, value: unknown) if index == "strict" then flags.strict = if type(value) == "boolean" then value else error("strict must be a boolean", 2) else error(string.format("\"%s\" is not a valid member of vide", tostring(index)), 2) end end }) if game then game:GetService("RunService").Heartbeat:Connect(function(dt: number) task.defer(vide.step, dt) end) end return vide