46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package plugin
|
|
|
|
import "github.com/Nwflower/reims-go/internal/plugin/uiassets"
|
|
|
|
// MaxPluginArchiveBytes is the maximum accepted size of a plugin archive.
|
|
const MaxPluginArchiveBytes = maxPluginArchiveBytes
|
|
|
|
// IsValidReverseDomainID reports whether id matches the reverse-domain plugin ID format.
|
|
func IsValidReverseDomainID(id string) bool {
|
|
return reReverseDomainID.MatchString(id)
|
|
}
|
|
|
|
// CheckHostCompatibility checks whether a plugin's platform list and engine
|
|
// constraints are compatible with the running host version.
|
|
func CheckHostCompatibility(platforms []string, engines Engines, hostVersion string) (bool, string) {
|
|
return checkHostCompatibility(platforms, engines, hostVersion)
|
|
}
|
|
|
|
// FileSHA256Hex returns the lowercase hex SHA-256 digest of the file at path.
|
|
func FileSHA256Hex(path string) (string, error) {
|
|
return fileSHA256Hex(path)
|
|
}
|
|
|
|
// SafeJoin joins rel under root and blocks lexical and symlink traversal.
|
|
func SafeJoin(root, rel string) (string, error) {
|
|
return uiassets.SafeJoin(root, rel)
|
|
}
|
|
|
|
// TrustSortRank orders trust levels with higher numbers being more trusted.
|
|
func TrustSortRank(t TrustLevel) int {
|
|
switch t {
|
|
case TrustOfficial:
|
|
return 3
|
|
case TrustVerified:
|
|
return 2
|
|
case TrustCommunity:
|
|
return 1
|
|
default:
|
|
return 0
|
|
}
|
|
}
|
|
|
|
func trustSortRank(t TrustLevel) int {
|
|
return TrustSortRank(t)
|
|
}
|