Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,32 @@
import Foundation
public final class Action<Arguments> {
public let action: (Arguments) -> Void
public init(_ action: @escaping (Arguments) -> Void) {
self.action = action
}
public func callAsFunction(_ arguments: Arguments) {
self.action(arguments)
}
}
public final class ActionSlot<Arguments>: Equatable {
private var target: ((Arguments) -> Void)?
public init() {
}
public static func ==(lhs: ActionSlot<Arguments>, rhs: ActionSlot<Arguments>) -> Bool {
return lhs === rhs
}
public func connect(_ target: @escaping (Arguments) -> Void) {
self.target = target
}
public func invoke(_ arguments: Arguments) {
self.target?(arguments)
}
}
@@ -0,0 +1,8 @@
import Foundation
import UIKit
extension UIColor {
convenience init(rgb: UInt32) {
self.init(red: CGFloat((rgb >> 16) & 0xff) / 255.0, green: CGFloat((rgb >> 8) & 0xff) / 255.0, blue: CGFloat(rgb & 0xff) / 255.0, alpha: 1.0)
}
}
@@ -0,0 +1,9 @@
import Foundation
public func Condition<R>(_ f: @autoclosure () -> Bool, _ pass: () -> R) -> R? {
if f() {
return pass()
} else {
return nil
}
}
@@ -0,0 +1,28 @@
import Foundation
final class EscapeGuard {
final class Status {
fileprivate(set) var isDeallocated: Bool = false
}
let status = Status()
deinit {
self.status.isDeallocated = true
}
}
public final class EscapeNotification: NSObject {
let deallocated: () -> Void
public init(_ deallocated: @escaping () -> Void) {
self.deallocated = deallocated
}
deinit {
self.deallocated()
}
public func keep() {
}
}
@@ -0,0 +1,8 @@
import Foundation
import UIKit
public extension UIEdgeInsets {
init(_ value: CGFloat) {
self.init(top: value, left: value, bottom: value, right: value)
}
}
@@ -0,0 +1,8 @@
import Foundation
import UIKit
public extension CGRect {
var center: CGPoint {
return CGPoint(x: self.midX, y: self.midY)
}
}
@@ -0,0 +1,28 @@
import Foundation
import UIKit
public extension CGSize {
func centered(in rect: CGRect) -> CGRect {
return CGRect(origin: CGPoint(x: rect.minX + floor((rect.width - self.width) / 2.0), y: rect.minY + floor((rect.height - self.height) / 2.0)), size: self)
}
func centered(around position: CGPoint) -> CGRect {
return CGRect(origin: CGPoint(x: position.x - self.width / 2.0, y: position.y - self.height / 2.0), size: self)
}
func leftCentered(in rect: CGRect) -> CGRect {
return CGRect(origin: CGPoint(x: rect.minX, y: rect.minY + floor((rect.height - self.height) / 2.0)), size: self)
}
func rightCentered(in rect: CGRect) -> CGRect {
return CGRect(origin: CGPoint(x: rect.maxX - self.width, y: rect.minY + floor((rect.height - self.height) / 2.0)), size: self)
}
func topCentered(in rect: CGRect) -> CGRect {
return CGRect(origin: CGPoint(x: rect.minX + floor((rect.width - self.width) / 2.0), y: 0.0), size: self)
}
func bottomCentered(in rect: CGRect) -> CGRect {
return CGRect(origin: CGPoint(x: rect.minX + floor((rect.width - self.width) / 2.0), y: rect.maxY - self.height), size: self)
}
}