--!strict --[[ Stores common type information used internally. These types may be used internally so Fusion code can type-check, but should never be exposed to public users, as these definitions are fair game for breaking changes. ]] local PubTypes = require "./PubTypes" type Set = { [T]: any } --[[ General use types ]] -- A symbol that represents the absence of a value. export type None = PubTypes.Symbol & { -- name: "None" (add this when Luau supports singleton types) } -- Stores useful information about Luau errors. export type Error = { type: string, -- replace with "Error" when Luau supports singleton types raw: string, message: string, trace: string, } -- An object which stores a value scoped in time. export type Contextual = PubTypes.Contextual & { _valuesNow: { [thread]: { value: T } }, _defaultValue: T, } --[[ Generic reactive graph types ]] export type StateObject = PubTypes.StateObject & { _peek: (StateObject) -> T, } --[[ Specific reactive graph types ]] -- A state object whose value can be set at any time by the user. export type State = PubTypes.Value & { _value: T, } -- A state object whose value is derived from other objects using a callback. export type Computed = PubTypes.Computed & { _oldDependencySet: Set, _callback: (PubTypes.Use) -> T, _value: T, } -- A state object whose value is derived from other objects using a callback. export type ForPairs = PubTypes.ForPairs & { _oldDependencySet: Set, _processor: (PubTypes.Use, KI, VI) -> (KO, VO), _destructor: (VO, M?) -> (), _inputIsState: boolean, _inputTable: PubTypes.CanBeState<{ [KI]: VI }>, _oldInputTable: { [KI]: VI }, _outputTable: { [KO]: VO }, _oldOutputTable: { [KO]: VO }, _keyIOMap: { [KI]: KO }, _meta: { [KO]: M? }, _keyData: { [KI]: { dependencySet: Set, oldDependencySet: Set, dependencyValues: { [PubTypes.Dependency]: any }, }, }, } -- A state object whose value is derived from other objects using a callback. export type ForKeys = PubTypes.ForKeys & { _oldDependencySet: Set, _processor: (PubTypes.Use, KI) -> KO, _destructor: (KO, M?) -> (), _inputIsState: boolean, _inputTable: PubTypes.CanBeState<{ [KI]: KO }>, _oldInputTable: { [KI]: KO }, _outputTable: { [KO]: any }, _keyOIMap: { [KO]: KI }, _meta: { [KO]: M? }, _keyData: { [KI]: { dependencySet: Set, oldDependencySet: Set, dependencyValues: { [PubTypes.Dependency]: any }, }, }, } -- A state object whose value is derived from other objects using a callback. export type ForValues = PubTypes.ForValues & { _oldDependencySet: Set, _processor: (PubTypes.Use, VI) -> VO, _destructor: (VO, M?) -> (), _inputIsState: boolean, _inputTable: PubTypes.CanBeState<{ [VI]: VO }>, _outputTable: { [any]: VI }, _valueCache: { [VO]: any }, _oldValueCache: { [VO]: any }, _meta: { [VO]: M? }, _valueData: { [VI]: { dependencySet: Set, oldDependencySet: Set, dependencyValues: { [PubTypes.Dependency]: any }, }, }, } -- A state object which follows another state object using tweens. export type Tween = PubTypes.Tween & { _goalState: State, _tweenInfo: TweenInfo, _prevValue: T, _nextValue: T, _currentValue: T, _currentTweenInfo: TweenInfo, _currentTweenDuration: number, _currentTweenStartTime: number, _currentlyAnimating: boolean, } -- A state object which follows another state object using spring simulation. export type Spring = PubTypes.Spring & { _speed: PubTypes.CanBeState, _speedIsState: boolean, _lastSpeed: number, _damping: PubTypes.CanBeState, _dampingIsState: boolean, _lastDamping: number, _goalState: State, _goalValue: T, _currentType: string, _currentValue: T, _springPositions: { number }, _springGoals: { number }, _springVelocities: { number }, } -- An object which can listen for updates on another state object. export type Observer = PubTypes.Observer & { _changeListeners: Set<() -> ()>, _numChangeListeners: number, } return nil