Documentation
¶
Index ¶
- Constants
- func GetImplicitMods() []string
- func IsImplicitMod(depID string) bool
- type Activator
- type BatchStateChange
- type DependencyOverrides
- func LoadDependencyOverrides(reader io.Reader, overrideSource OverrideSource) (*DependencyOverrides, error)
- func LoadDependencyOverridesFromPath(path string, overrideSource OverrideSource) (*DependencyOverrides, error)
- func MergeDependencyOverrides(overrides ...*DependencyOverrides) *DependencyOverrides
- type DependencyResolver
- func (dr *DependencyResolver) CalculateDirectlyUnresolvableMods(availableMods sets.Set) sets.Set
- func (dr *DependencyResolver) CalculateDirectlyUnresolvableModsWithDetails(availableMods sets.Set) map[string][]string
- func (dr *DependencyResolver) CalculateTransitivelyUnresolvableMods(initialCandidates sets.Set) sets.Set
- func (dr *DependencyResolver) CalculateUnresolvableModsDetails(initialCandidates sets.Set) UnresolvableModDetails
- func (dr *DependencyResolver) FindTransitiveDependersOf(targets sets.Set) sets.Set
- func (dr *DependencyResolver) ResolveEffectiveSet(targetSet sets.Set, modStatuses map[string]ModStatus) (sets.Set, ResolutionPath)
- type FileMissingError
- type Loader
- type MissingFilesError
- type Mod
- type ModLoader
- type ModMetadata
- type ModParser
- type ModStatus
- type NestedModule
- type OverrideAction
- type OverrideRule
- type OverrideSource
- type PotentialProvidersMap
- type ProviderInfo
- type ResolutionInfo
- type ResolutionPath
- type StateManager
- func (sm *StateManager) GetAllModIDs() []string
- func (sm *StateManager) GetAllMods() map[string]*Mod
- func (sm *StateManager) GetModStatus(modID string) (*ModStatus, bool)
- func (sm *StateManager) GetModStatusesSnapshot() map[string]ModStatus
- func (sm *StateManager) ResolveEffectiveSet(targetSet sets.Set) (sets.Set, ResolutionPath)
- func (sm *StateManager) Resolver() *DependencyResolver
- func (sm *StateManager) SetForceDisabled(modID string, disabled bool)
- func (sm *StateManager) SetForceDisabledBatch(modIDs []string, disabled bool)
- func (sm *StateManager) SetForceEnabled(modID string, enabled bool)
- func (sm *StateManager) SetForceEnabledBatch(modIDs []string, enabled bool)
- func (sm *StateManager) SetMissing(modID string, missing bool)
- func (sm *StateManager) SetMissingBatch(modIDs []string, missing bool)
- func (sm *StateManager) SetOmitted(modID string, isOmitted bool)
- func (sm *StateManager) SetOmittedBatch(modIDs []string, omitted bool)
- func (sm *StateManager) SetProblematic(modID string, problematic bool)
- func (sm *StateManager) SetProblematicBatch(modIDs []string, problematic bool)
- func (sm *StateManager) SetUnresolvable(modID string, unresolvable bool)
- func (sm *StateManager) SetUnresolvableBatch(modIDs []string, unresolvable bool)
- type UnresolvableModDetails
- type VersionField
- type VersionRanges
Constants ¶
const ( LoaderNone = Loader("") LoaderFabric = Loader("Fabric") LoaderQuilt = Loader("Quilt") LoaderNeoForge = Loader("NeoForge") )
Variables ¶
This section is empty.
Functions ¶
func GetImplicitMods ¶ added in v1.1.0
func GetImplicitMods() []string
func IsImplicitMod ¶
IsImplicitMod checks if a dependency ID is for an implicit (non-mod) dependency.
Types ¶
type Activator ¶
type Activator struct {
// contains filtered or unexported fields
}
Activator manages the physical file state of mods (enabled/disabled).
func NewModActivator ¶
NewModActivator creates a new activator. It initializes the internal tracking based on the mod's initial active state.
func (*Activator) Apply ¶
func (a *Activator) Apply(effectiveSet sets.Set, statuses map[string]ModStatus) ([]BatchStateChange, error)
Apply calculates and executes the necessary file renames to achieve the effectiveSet state. It performs a batch of renames and returns the list of changes made. Before renaming, it also verifies that all mods that should be active are present on disk (unless already marked as missing in statuses). This helps catch unexpected deletions.
func (*Activator) Revert ¶
func (a *Activator) Revert(changes []BatchStateChange)
Revert applies a set of changes in reverse order to restore a previous state. This is used for cleanup or undo operations.
type BatchStateChange ¶
type BatchStateChange struct {
ModID string
OldPath string
NewPath string
Activate bool // True if the mod became active, false if it became disabled.
}
BatchStateChange represents a single file rename operation.
type DependencyOverrides ¶
type DependencyOverrides struct {
Rules []OverrideRule
}
DependencyOverrides holds a pre-parsed list of polymorphic rules.
func LoadDependencyOverrides ¶
func LoadDependencyOverrides(reader io.Reader, overrideSource OverrideSource) (*DependencyOverrides, error)
LoadDependencyOverrides loads and parses dependency overrides from an io.Reader.
func LoadDependencyOverridesFromPath ¶
func LoadDependencyOverridesFromPath(path string, overrideSource OverrideSource) (*DependencyOverrides, error)
LoadDependencyOverridesFromPath loads overrides from a specific file path.
func MergeDependencyOverrides ¶
func MergeDependencyOverrides(overrides ...*DependencyOverrides) *DependencyOverrides
MergeDependencyOverrides combines multiple DependencyOverrides objects.
type DependencyResolver ¶
type DependencyResolver struct {
// contains filtered or unexported fields
}
DependencyResolver is a long-lived service that holds the static universe of all mods and their potential providers. It is safe for concurrent use.
func NewDependencyResolver ¶
func NewDependencyResolver(allMods map[string]*Mod, potentialProviders PotentialProvidersMap) *DependencyResolver
NewDependencyResolver creates a new DependencyResolver service.
func (*DependencyResolver) CalculateDirectlyUnresolvableMods ¶
func (dr *DependencyResolver) CalculateDirectlyUnresolvableMods(availableMods sets.Set) sets.Set
CalculateDirectlyUnresolvableMods performs a fast, first-degree check to determine which mods are immediately unresolvable because they lack providers for their direct dependencies.
It does NOT check if the providers themselves are resolvable (no transitive checks). It halts checking a mod the moment its first failed dependency is encountered (early exit).
Use Case: Used internally as the fast-path engine for CalculateTransitivelyUnresolvableMods, or for quick surface-level validation of a mod set.
func (*DependencyResolver) CalculateDirectlyUnresolvableModsWithDetails ¶ added in v1.1.0
func (dr *DependencyResolver) CalculateDirectlyUnresolvableModsWithDetails(availableMods sets.Set) map[string][]string
CalculateDirectlyUnresolvableModsWithDetails performs a first-degree check like CalculateDirectlyUnresolvableMods, but maps each unresolvable mod to a complete slice of every direct dependency that failed to resolve.
Performance: It must evaluate every dependency for every mod without early exiting, resulting in memory allocations for the string slices.
Use Case: Useful when you need a shallow, immediate error report for a specific subset of mods, without traversing the entire dependency tree.
func (*DependencyResolver) CalculateTransitivelyUnresolvableMods ¶
func (dr *DependencyResolver) CalculateTransitivelyUnresolvableMods(initialCandidates sets.Set) sets.Set
CalculateTransitivelyUnresolvableMods iteratively calculates the complete boolean set of all mods that cannot be resolved, whether directly missing a dependency or failing transitively due to cascading dependency failures.
Performance: This is highly optimized for speed. It uses fast-path boolean checks and avoids tracking causality or allocating slices for failed dependencies.
Use Case: Ideal for background processing, bisection loops, or filtering where you only need to know *if* a mod is broken to exclude it from further testing.
func (*DependencyResolver) CalculateUnresolvableModsDetails ¶ added in v1.1.0
func (dr *DependencyResolver) CalculateUnresolvableModsDetails(initialCandidates sets.Set) UnresolvableModDetails
CalculateUnresolvableModsDetails performs a full, iterative dependency check to find all broken mods and meticulously tracks the causal chain of failure.
It guarantees that transitively broken mods are accurately mapped to the directly unresolvable mods (root causes) that initiated the cascading failure.
Use Case: Ideal for generating detailed, user-facing error reports or logs where explaining *why* a mod is broken is just as important as knowing that it is broken. Note: This is slightly more resource-intensive than CalculateTransitivelyUnresolvableMods.
func (*DependencyResolver) FindTransitiveDependersOf ¶
func (dr *DependencyResolver) FindTransitiveDependersOf(targets sets.Set) sets.Set
FindTransitiveDependersOf calculates the complete set of mods that depend, directly or indirectly, on any mod in the initial target set. This function operates on dependency IDs and does not evaluate versions.
func (*DependencyResolver) ResolveEffectiveSet ¶
func (dr *DependencyResolver) ResolveEffectiveSet(targetSet sets.Set, modStatuses map[string]ModStatus) (sets.Set, ResolutionPath)
ResolveEffectiveSet calculates the set of active top-level mods based on targets, dependencies, and force flags.
type FileMissingError ¶
FileMissingError represents an error for a single missing mod file.
func (*FileMissingError) Error ¶
func (e *FileMissingError) Error() string
type MissingFilesError ¶
type MissingFilesError struct {
Errors []*FileMissingError
}
MissingFilesError is a wrapper error that contains one or more FileMissingError instances.
func (*MissingFilesError) Error ¶
func (e *MissingFilesError) Error() string
type Mod ¶
type Mod struct {
Path string
BaseFilename string
Metadata ModMetadata
IsInitiallyActive bool // Was the mod active (.jar) when first loaded?
NestedModules []NestedModule
EffectiveProvides map[string]version.Version // Maps all unique IDs this mod provides to their version.
}
Mod represents a single discovered mod and its metadata.
func (*Mod) FriendlyName ¶
FriendlyName returns a human-readable name for the mod.
type ModLoader ¶
type ModLoader struct {
ModParser
}
ModLoader loads mod information from the filesystem, parses metadata, resolves conflicts, and builds dependency provider maps.
func (*ModLoader) LoadMods ¶
func (ml *ModLoader) LoadMods(modsDir string, overrides *DependencyOverrides, progressReport func(fileNameBeingProcessed string)) ( map[string]*Mod, PotentialProvidersMap, []string, error, )
LoadMods discovers mods, parses metadata, resolves basic conflicts, and builds provider maps.
type ModMetadata ¶ added in v1.1.0
type ModMetadata struct {
// ID is the unique identifier for the mod (e.g., "example-mod").
ID string
// Name is the human-readable name of the mod.
Name string
// Version is the mod's version number.
Version VersionField
// Loader indicates which mod loader the mod is designed for.
Loader Loader
// Provides is a list of mod IDs this mod provides. This does not include the mod's own ID.
Provides []string
// Depends maps mod IDs to version ranges, representing required dependencies.
Depends VersionRanges
// Breaks maps mod IDs to version ranges, representing mods that are broken by this mod.
Breaks VersionRanges
// Recommends maps mod IDs to version ranges, representing recommended (but not required) dependencies.
Recommends VersionRanges
// Suggests maps mod IDs to version ranges, representing suggested (optional) dependencies.
Suggests VersionRanges
// Conflicts maps mod IDs to version ranges, representing mods that are incompatible with this mod.
Conflicts VersionRanges
// Jars is a list of nested JAR file paths referenced by this mod (e.g., for container mods).
Jars []string
// Indicates that this mod metadata doesn't represent a real mod
IsJavaLibrary bool
}
ModMetadata contains the metadata extracted from a mod's manifest file. It represents the core information about a mod as defined in its manifest (fabric.mod.json, quilt.mod.json, or neoforge.mods.toml).
type ModParser ¶
func (*ModParser) ExtractModMetadata ¶
func (p *ModParser) ExtractModMetadata(jarPath, jarName string, logBuffer *logBuffer) (ModMetadata, []NestedModule, error)
ExtractModMetadata opens a JAR and extracts its top-level and nested mod files.
type ModStatus ¶
type ModStatus struct {
ID string
Mod *Mod
ForceEnabled bool // Is mutually exclusive with ForceDisabled and Omitted
ForceDisabled bool
Omitted bool // Previously called ManuallyGood. Mod is not a search candidate, but can be activated
IsMissing bool
IsProblematic bool
IsUnresolvable bool
}
ModStatus represents the current runtime state of a single mod.
func (ModStatus) IsActivatable ¶
func (ModStatus) IsSearchCandidate ¶
func (ModStatus) IsUserEditable ¶ added in v1.0.1
type NestedModule ¶
type NestedModule struct {
Info ModMetadata
PathInJar string
}
NestedModule holds metadata for a mod found inside another JAR file, including its full path within the parent archive.
type OverrideAction ¶
type OverrideAction int
OverrideAction defines the type of modification for a rule.
const ( ActionReplace OverrideAction = iota ActionAdd ActionRemove )
func (OverrideAction) String ¶
func (a OverrideAction) String() string
type OverrideRule ¶
type OverrideRule interface {
Apply(mm *ModMetadata)
Target() string
Field() string
Key() string
Action() OverrideAction
Value() string
Source() OverrideSource
}
OverrideRule is the interface for any dependency or provides override rule.
type OverrideSource ¶ added in v1.1.0
type OverrideSource int
OverrideSource indicates where an override rule originates from.
const ( // OverrideSourceBuiltin indicates an override from the embedded fabric_loader_dependencies.json OverrideSourceBuiltin OverrideSource = iota // OverrideSourceUserProvided indicates an override from a user-provided config file OverrideSourceUserProvided )
func (OverrideSource) String ¶ added in v1.1.0
func (s OverrideSource) String() string
String returns the string representation of the OverrideSource.
type PotentialProvidersMap ¶
type PotentialProvidersMap map[string][]ProviderInfo
PotentialProvidersMap maps a dependency ID to a list of ProviderInfo structs.
type ProviderInfo ¶
type ProviderInfo struct {
TopLevelModID string
VersionOfProvidedItem version.Version
IsDirectProvide bool
TopLevelModVersion version.Version
}
ProviderInfo describes a mod that can satisfy a dependency.
type ResolutionInfo ¶
type ResolutionInfo struct {
ModID string
Reason string
NeededFor []string
SatisfiedDep string
SelectedProvider *ProviderInfo
}
ResolutionInfo stores details about why a mod is included in an effective set.
type ResolutionPath ¶
type ResolutionPath []ResolutionInfo
ResolutionPath is a slice of ResolutionInfo that provides a custom string representation for logging the dependency activation paths.
func (ResolutionPath) String ¶
func (rp ResolutionPath) String() string
String implements the fmt.Stringer interface for ResolutionPath.
type StateManager ¶
type StateManager struct {
// OnStateChanged is a callback function that is executed whenever the
// state of any mod is modified.
OnStateChanged func()
// contains filtered or unexported fields
}
StateManager provides a way to manage the state of mods. It uses a synchronous callback model for state change notifications.
func NewStateManager ¶
func NewStateManager(allMods map[string]*Mod, potentialProviders PotentialProvidersMap) *StateManager
NewStateManager creates a new mod state manager. It initializes the mod statuses based on the initially loaded mod data.
func (*StateManager) GetAllModIDs ¶
func (sm *StateManager) GetAllModIDs() []string
GetAllModIDs returns a sorted slice of all mod IDs known to the manager.
func (*StateManager) GetAllMods ¶
func (sm *StateManager) GetAllMods() map[string]*Mod
GetAllMods returns the map of all loaded mods.
func (*StateManager) GetModStatus ¶
func (sm *StateManager) GetModStatus(modID string) (*ModStatus, bool)
GetModStatus returns the current ModStatus for a given modID. Returns nil and false if the modID is not found.
func (*StateManager) GetModStatusesSnapshot ¶
func (sm *StateManager) GetModStatusesSnapshot() map[string]ModStatus
GetModStatusesSnapshot returns a consistent snapshot of the current mod statuses.
func (*StateManager) ResolveEffectiveSet ¶
func (sm *StateManager) ResolveEffectiveSet(targetSet sets.Set) (sets.Set, ResolutionPath)
ResolveEffectiveSet calculates the set of active top-level mods based on the given target set and the current mod statuses managed by the StateManager.
func (*StateManager) Resolver ¶
func (sm *StateManager) Resolver() *DependencyResolver
func (*StateManager) SetForceDisabled ¶
func (sm *StateManager) SetForceDisabled(modID string, disabled bool)
SetForceDisabled updates the force-disabled state of a mod.
func (*StateManager) SetForceDisabledBatch ¶
func (sm *StateManager) SetForceDisabledBatch(modIDs []string, disabled bool)
SetForceDisabledBatch updates the force-disabled state for multiple mods at once. It sends only a single notification after all changes are made.
func (*StateManager) SetForceEnabled ¶
func (sm *StateManager) SetForceEnabled(modID string, enabled bool)
SetForceEnabled updates the force-enabled state of a mod.
func (*StateManager) SetForceEnabledBatch ¶
func (sm *StateManager) SetForceEnabledBatch(modIDs []string, enabled bool)
SetForceEnabledBatch updates the force-enabled state for multiple mods at once. It sends only a single notification after all changes are made.
func (*StateManager) SetMissing ¶
func (sm *StateManager) SetMissing(modID string, missing bool)
SetMissing updates the missing state for a single mod.
func (*StateManager) SetMissingBatch ¶
func (sm *StateManager) SetMissingBatch(modIDs []string, missing bool)
SetMissingBatch updates the missing state for multiple mods at once, sending only a single notification.
func (*StateManager) SetOmitted ¶
func (sm *StateManager) SetOmitted(modID string, isOmitted bool)
SetOmitted updates the "ignored in search" state of a mod.
func (*StateManager) SetOmittedBatch ¶
func (sm *StateManager) SetOmittedBatch(modIDs []string, omitted bool)
SetOmittedBatch updates the "ignored in search" state for multiple mods at once. It sends only a single notification after all changes are made.
func (*StateManager) SetProblematic ¶ added in v1.0.1
func (sm *StateManager) SetProblematic(modID string, problematic bool)
SetProblematic updates the problematic state for a single mod.
func (*StateManager) SetProblematicBatch ¶ added in v1.0.1
func (sm *StateManager) SetProblematicBatch(modIDs []string, problematic bool)
SetProblematicBatch updates the problematic state for multiple mods at once, sending only a single notification.
func (*StateManager) SetUnresolvable ¶ added in v1.0.1
func (sm *StateManager) SetUnresolvable(modID string, unresolvable bool)
SetUnresolvable updates the unresolvable state for a single mod.
func (*StateManager) SetUnresolvableBatch ¶ added in v1.0.1
func (sm *StateManager) SetUnresolvableBatch(modIDs []string, unresolvable bool)
SetUnresolvableBatch updates the unresolvable state for multiple mods at once, sending only a single notification.
type UnresolvableModDetails ¶ added in v1.1.0
type UnresolvableModDetails struct {
DirectlyUnresolvable map[string][]string // ModID -> missing dependencies
TransitivelyUnresolvable map[string]sets.Set // ModID -> set of root cause ModIDs
}
UnresolvableModDetails contains categorized information about unresolvable mods, separating direct failures from transitive failures and mapping their root causes.
type VersionField ¶
VersionField is a wrapper for version.Version that handles JSON unmarshaling from a string, ensuring the version is parsed and valid at load time.
func (VersionField) String ¶
func (vf VersionField) String() string
func (*VersionField) UnmarshalJSON ¶
func (vf *VersionField) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type VersionRanges ¶
type VersionRanges map[string][]*version.VersionPredicate
VersionRanges is a custom type for dependency maps that handles parsing of version predicate strings into a slice of VersionPredicate objects. A dependency can be satisfied if ANY of the predicates in the slice are met (OR relationship).
func (*VersionRanges) UnmarshalJSON ¶
func (vr *VersionRanges) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface, allowing us to parse the complex "string or array of strings" format for version ranges.