Skip to content

Commit

Permalink
Release 30.3.0
Browse files Browse the repository at this point in the history
b990a1e3967fc29e1a318896683b6060a6cbc6b3
  • Loading branch information
robot-divkit committed Jun 3, 2024
1 parent 96bffbd commit 5df3455
Show file tree
Hide file tree
Showing 30 changed files with 699 additions and 189 deletions.
6 changes: 6 additions & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"DivKit/Extensions/DivVideoExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivVideoExtensions.swift",
"DivKit/Extensions/DivVisibilityActionExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivVisibilityActionExtensions.swift",
"DivKit/Extensions/DurationExtensions.swift":"divkit/public-ios/DivKit/Extensions/DurationExtensions.swift",
"DivKit/Extensions/FontFeatureSettingsParser.swift":"divkit/public-ios/DivKit/Extensions/FontFeatureSettingsParser.swift",
"DivKit/Extensions/GradientExtentions.swift":"divkit/public-ios/DivKit/Extensions/GradientExtentions.swift",
"DivKit/Extensions/JSONSerializationExtensions.swift":"divkit/public-ios/DivKit/Extensions/JSONSerializationExtensions.swift",
"DivKit/Extensions/RelativeValueExtensions.swift":"divkit/public-ios/DivKit/Extensions/RelativeValueExtensions.swift",
Expand Down Expand Up @@ -878,6 +879,7 @@
"Specs/DivKit/30.0.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.0.0/DivKit.podspec",
"Specs/DivKit/30.1.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.1.0/DivKit.podspec",
"Specs/DivKit/30.2.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.2.0/DivKit.podspec",
"Specs/DivKit/30.3.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.3.0/DivKit.podspec",
"Specs/DivKitExtensions/24.3.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/24.3.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/25.0.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/25.0.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/25.1.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/25.1.0/DivKitExtensions.podspec",
Expand Down Expand Up @@ -932,6 +934,7 @@
"Specs/DivKitExtensions/30.0.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.0.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.1.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.1.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.2.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.2.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.3.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.3.0/DivKitExtensions.podspec",
"Specs/DivKit_LayoutKit/28.0.1/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/28.0.1/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/28.1.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/28.1.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/28.10.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/28.10.0/DivKit_LayoutKit.podspec",
Expand Down Expand Up @@ -968,6 +971,7 @@
"Specs/DivKit_LayoutKit/30.0.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.0.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.1.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.1.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.2.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.2.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.3.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.3.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKitInterface/28.0.1/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/28.0.1/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/28.1.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/28.1.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/28.10.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/28.10.0/DivKit_LayoutKitInterface.podspec",
Expand Down Expand Up @@ -1004,6 +1008,7 @@
"Specs/DivKit_LayoutKitInterface/30.0.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.0.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.1.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.1.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.2.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.2.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.3.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.3.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_Serialization/28.0.1/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/28.0.1/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/28.1.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/28.1.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/28.10.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/28.10.0/DivKit_Serialization.podspec",
Expand Down Expand Up @@ -1040,6 +1045,7 @@
"Specs/DivKit_Serialization/30.0.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.0.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.1.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.1.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.2.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.2.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.3.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.3.0/DivKit_Serialization.podspec",
"Specs/LayoutKit/24.3.0/LayoutKit.podspec":"divkit/public-ios/Specs/LayoutKit/24.3.0/LayoutKit.podspec",
"Specs/LayoutKit/25.0.0/LayoutKit.podspec":"divkit/public-ios/Specs/LayoutKit/25.0.0/LayoutKit.podspec",
"Specs/LayoutKit/25.1.0/LayoutKit.podspec":"divkit/public-ios/Specs/LayoutKit/25.1.0/LayoutKit.podspec",
Expand Down
24 changes: 12 additions & 12 deletions DivKit/DivBlockStateStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class DivBlockStateStorage {
private var statesById: [IdAndCardId: ElementState] = [:]
private var focusedElement: UIElementPath?
private var focusedElementById: IdAndCardId?
private let lock = RWLock()
private let lock = AllocatedUnfairLock()

public init(states: BlocksState = [:]) {
self.states = states
Expand All @@ -35,7 +35,7 @@ public final class DivBlockStateStorage {
}

public func getStateUntyped(_ path: UIElementPath) -> ElementState? {
lock.read {
lock.withLock {
statesById[IdAndCardId(path: path)] ?? states[path]
}
}
Expand All @@ -47,26 +47,26 @@ public final class DivBlockStateStorage {

public func getStateUntyped(_ id: String, cardId: DivCardID) -> ElementState? {
let idKey = IdAndCardId(id: id, cardId: cardId)
return lock.read {
return lock.withLock {
statesById[idKey] ?? states.first { IdAndCardId(path: $0.key) == idKey }?.value
}
}

public func setState(path: UIElementPath, state: ElementState) {
lock.write {
lock.withLock {
statesById[IdAndCardId(path: path)] = nil
states[path] = state
}
}

public func setState(id: String, cardId: DivCardID, state: ElementState) {
lock.write {
lock.withLock {
statesById[IdAndCardId(id: id, cardId: cardId)] = state
}
}

public func setFocused(isFocused: Bool, element: IdAndCardId) {
lock.write {
lock.withLock {
if isFocused {
focusedElement = nil
focusedElementById = element
Expand All @@ -78,7 +78,7 @@ public final class DivBlockStateStorage {
}

public func setFocused(isFocused: Bool, path: UIElementPath) {
lock.write {
lock.withLock {
if isFocused {
focusedElement = path
focusedElementById = nil
Expand All @@ -90,20 +90,20 @@ public final class DivBlockStateStorage {
}

public func clearFocus() {
lock.write {
lock.withLock {
focusedElement = nil
focusedElementById = nil
}
}

public func isFocused(element: IdAndCardId) -> Bool {
lock.read {
lock.withLock {
isFocusedInternal(element: element)
}
}

public func isFocused(path: UIElementPath) -> Bool {
lock.read {
lock.withLock {
isFocusedInternal(path: path)
}
}
Expand All @@ -121,7 +121,7 @@ public final class DivBlockStateStorage {
}

public func reset() {
lock.write {
lock.withLock {
states = [:]
statesById = [:]
focusedElement = nil
Expand All @@ -130,7 +130,7 @@ public final class DivBlockStateStorage {
}

public func reset(cardId: DivCardID) {
lock.write {
lock.withLock {
states = states.filter { $0.key.root != cardId.rawValue }
statesById = statesById.filter { $0.key.cardId != cardId }
if getFocusedElement()?.cardId == cardId {
Expand Down
2 changes: 1 addition & 1 deletion DivKit/DivKitInfo.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
public enum DivKitInfo {
public static let version = "30.2.0"
public static let version = "30.3.0"
}
10 changes: 5 additions & 5 deletions DivKit/DivLastVisibleBoundsCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import CommonCorePublic
import LayoutKit

public final class DivLastVisibleBoundsCache {
private let rwLock = RWLock()
private let lock = AllocatedUnfairLock()

private var storage: [UIElementPath: Int] = [:]

init() {}

func lastVisibleArea(for path: UIElementPath) -> Int {
rwLock.read {
lock.withLock {
storage[path] ?? .zero
}
}

func updateLastVisibleArea(for path: UIElementPath, area: Int) {
rwLock.write {
lock.withLock {
storage[path] = area
}
}

func dropVisibleBounds(forMatchingPrefix prefix: UIElementPath) {
let prefix = prefix.description + "/"
rwLock.write {
lock.withLock {
for item in storage {
if (item.key.description + "/").starts(with: prefix) {
storage[item.key] = nil
Expand All @@ -34,7 +34,7 @@ public final class DivLastVisibleBoundsCache {
}

func reset() {
rwLock.write {
lock.withLock {
storage.removeAll()
}
}
Expand Down
10 changes: 8 additions & 2 deletions DivKit/Expressions/Functions/BooleanOperators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private let andOperator = LazyFunction { args, evaluators in

let arg1 = try args[1].evaluate(evaluators)
guard let rhs = arg1 as? Bool else {
throw invalidArgsError(lhs: arg0, op: "&&")
throw invalidArgsError(lhs: arg0, rhs: arg1, op: "&&")
}
return rhs
}
Expand All @@ -45,7 +45,7 @@ private let orOperator = LazyFunction { args, evaluators in

let arg1 = try args[1].evaluate(evaluators)
guard let rhs = arg1 as? Bool else {
throw invalidArgsError(lhs: arg0, op: "||")
throw invalidArgsError(lhs: arg0, rhs: arg1, op: "||")
}
return rhs
}
Expand All @@ -68,3 +68,9 @@ private func invalidArgsError(lhs: Any, op: String) -> Error {
"Failed to evaluate [\(formatArgForError(lhs)) \(op) ...]. '\(op)' must be called with boolean operands."
)
}

private func invalidArgsError(lhs: Any, rhs: Any, op: String) -> Error {
ExpressionError(
"Failed to evaluate [\(formatArgForError(lhs)) \(op) \(formatArgForError(rhs))]. Operator '\(op)' cannot be applied to different types: \(formatTypeForError(lhs)) and \(formatTypeForError(rhs))."
)
}
22 changes: 5 additions & 17 deletions DivKit/Expressions/Functions/DateTimeFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,31 +189,19 @@ private let getMillis = FunctionUnary<Date, Int> {
}

private let formatDateAsLocal = FunctionBinary<Date, String, String> {
try formatDate($0, format: $1)
makeDateFormatter($1, isUTC: false).string(from: $0)
}

private let formatDateAsLocalWithLocale = FunctionTernary<Date, String, String, String> {
try formatDate($0, format: $1, locale: $2)
makeDateFormatter($1, isUTC: false, locale: $2).string(from: $0)
}

private let formatDateAsUTC = FunctionBinary<Date, String, String> {
try formatDate($0, format: $1, isUTC: true)
makeDateFormatter($1, isUTC: true).string(from: $0)
}

private let formatDateAsUTCWithLocale = FunctionTernary<Date, String, String, String> {
try formatDate($0, format: $1, isUTC: true, locale: $2)
}

private func formatDate(
_ value: Date,
format: String,
isUTC: Bool = false,
locale: String? = nil
) throws -> String {
guard !format.contains("Z"), !format.contains("z") else {
throw ExpressionError("z/Z not supported in [\(format)].")
}
return makeDateFormatter(format, isUTC: isUTC, locale: locale).string(from: value)
makeDateFormatter($1, isUTC: true, locale: $2).string(from: $0)
}

private let dateFormat = "yyyy-MM-dd HH:mm:ss"
Expand Down Expand Up @@ -264,7 +252,7 @@ private let calendar: Calendar = {

private func makeDateFormatter(
_ format: String,
isUTC: Bool = false,
isUTC: Bool,
locale: String? = nil
) -> DateFormatter {
let formatter = DateFormatter()
Expand Down
4 changes: 3 additions & 1 deletion DivKit/Extensions/DivAction/DivActionsHolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ extension DivActionsHolder {
extension Block {
func addActions(
context: DivBlockModelingContext,
actionsHolder: DivActionsHolder?
actionsHolder: DivActionsHolder?,
clipToBounds: Bool
) -> Block {
guard let actionsHolder else {
return self
Expand All @@ -66,6 +67,7 @@ extension Block {
}

return addingDecorations(
boundary: clipToBounds ? nil : .noClip,
actions: actions,
actionAnimation: actionsHolder.actionAnimation
.resolveActionAnimation(context.expressionResolver),
Expand Down
5 changes: 3 additions & 2 deletions DivKit/Extensions/DivBase/DivBaseExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ extension DivBase {
)
}

let clipToBounds = rotation == nil && shadow == nil
block = applyTransitioningAnimations(to: block, context: context, statePath: statePath)
.addActions(context: context, actionsHolder: actionsHolder)
.addActions(context: context, actionsHolder: actionsHolder, clipToBounds: clipToBounds)
.addingEdgeInsets(externalInsets, clipsToBounds: false)
.addingDecorations(
boundary: rotation != nil || shadow != nil ? .noClip : nil,
boundary: clipToBounds ? nil : .noClip,
alpha: CGFloat(resolveAlpha(expressionResolver))
)

Expand Down
3 changes: 3 additions & 0 deletions DivKit/Extensions/DivData/DivDataPatchExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extension DivGallery {
focus: focus,
height: height,
id: id,
itemBuilder: itemBuilder,
itemSpacing: itemSpacing,
items: patchedItems,
margins: margins,
Expand Down Expand Up @@ -233,6 +234,7 @@ extension DivPager {
height: height,
id: id,
infiniteScroll: infiniteScroll,
itemBuilder: itemBuilder,
itemSpacing: itemSpacing,
items: patchedItems,
layoutMode: layoutMode,
Expand Down Expand Up @@ -338,6 +340,7 @@ extension DivTabs {
separatorColor: separatorColor,
separatorPaddings: separatorPaddings,
switchTabsByContentSwipeEnabled: switchTabsByContentSwipeEnabled,
tabTitleDelimiter: tabTitleDelimiter,
tabTitleStyle: tabTitleStyle,
titlePaddings: titlePaddings,
tooltips: tooltips,
Expand Down
Loading

0 comments on commit 5df3455

Please sign in to comment.