Skip to content

Commit

Permalink
Release 30.20.0
Browse files Browse the repository at this point in the history
commit_hash:ad75916b6896503f436dce62fde8a9c4f3e6f689
  • Loading branch information
robot-divkit committed Sep 30, 2024
1 parent 6b2fa27 commit 379508e
Show file tree
Hide file tree
Showing 30 changed files with 630 additions and 18 deletions.
11 changes: 11 additions & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"DivKit/Actions/OverflowMode.swift":"divkit/public-ios/DivKit/Actions/OverflowMode.swift",
"DivKit/Actions/ScrollMode.swift":"divkit/public-ios/DivKit/Actions/ScrollMode.swift",
"DivKit/Actions/SetVariableActionHandler.swift":"divkit/public-ios/DivKit/Actions/SetVariableActionHandler.swift",
"DivKit/Actions/TimerActionHandler.swift":"divkit/public-ios/DivKit/Actions/TimerActionHandler.swift",
"DivKit/Actions/VideoActionHandler.swift":"divkit/public-ios/DivKit/Actions/VideoActionHandler.swift",
"DivKit/Debug/Block+DebugInfo.swift":"divkit/public-ios/DivKit/Debug/Block+DebugInfo.swift",
"DivKit/Debug/DebugParams.swift":"divkit/public-ios/DivKit/Debug/DebugParams.swift",
"DivKit/Debug/ErrorListView.swift":"divkit/public-ios/DivKit/Debug/ErrorListView.swift",
Expand All @@ -38,6 +40,8 @@
"DivKit/DivVisibilityCounter.swift":"divkit/public-ios/DivKit/DivVisibilityCounter.swift",
"DivKit/Expressions/CalcExpression/CalcExpression.swift":"divkit/public-ios/DivKit/Expressions/CalcExpression/CalcExpression.swift",
"DivKit/Expressions/CalcExpression/CalcExpressionSymbol.swift":"divkit/public-ios/DivKit/Expressions/CalcExpression/CalcExpressionSymbol.swift",
"DivKit/Expressions/CustomFunctions/CustomFunction.swift":"divkit/public-ios/DivKit/Expressions/CustomFunctions/CustomFunction.swift",
"DivKit/Expressions/CustomFunctions/DivFunctionsStorage.swift":"divkit/public-ios/DivKit/Expressions/CustomFunctions/DivFunctionsStorage.swift",
"DivKit/Expressions/Expression.swift":"divkit/public-ios/DivKit/Expressions/Expression.swift",
"DivKit/Expressions/ExpressionContext.swift":"divkit/public-ios/DivKit/Expressions/ExpressionContext.swift",
"DivKit/Expressions/ExpressionError.swift":"divkit/public-ios/DivKit/Expressions/ExpressionError.swift",
Expand Down Expand Up @@ -95,6 +99,7 @@
"DivKit/Extensions/DivDrawable/DivDrawableWidthTrait.swift":"divkit/public-ios/DivKit/Extensions/DivDrawable/DivDrawableWidthTrait.swift",
"DivKit/Extensions/DivDrawable/DivShapeExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivDrawable/DivShapeExtensions.swift",
"DivKit/Extensions/DivEdgeInsetsExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivEdgeInsetsExtensions.swift",
"DivKit/Extensions/DivEvaluableTypeExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivEvaluableTypeExtensions.swift",
"DivKit/Extensions/DivExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivExtensions.swift",
"DivKit/Extensions/DivFilterExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivFilterExtensions.swift",
"DivKit/Extensions/DivGallery/DivGalleryExtensions.swift":"divkit/public-ios/DivKit/Extensions/DivGallery/DivGalleryExtensions.swift",
Expand Down Expand Up @@ -503,6 +508,7 @@
"DivKitExtensions/ExtensionHandlers/GestureExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/GestureExtensionHandler.swift",
"DivKitExtensions/ExtensionHandlers/ImageExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/ImageExtensionHandler.swift",
"DivKitExtensions/ExtensionHandlers/ImageThemeExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/ImageThemeExtensionHandler.swift",
"DivKitExtensions/ExtensionHandlers/InputAccessoryViewExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/InputAccessoryViewExtensionHandler.swift",
"DivKitExtensions/ExtensionHandlers/PinchToZoomExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/PinchToZoomExtensionHandler.swift",
"DivKitExtensions/ExtensionHandlers/TextExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/TextExtensionHandler.swift",
"DivKitExtensions/ExtensionHandlers/VideoDurationExtensionHandler.swift":"divkit/public-ios/DivKitExtensions/ExtensionHandlers/VideoDurationExtensionHandler.swift",
Expand Down Expand Up @@ -939,6 +945,7 @@
"Specs/DivKit/30.18.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.18.0/DivKit.podspec",
"Specs/DivKit/30.19.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.19.0/DivKit.podspec",
"Specs/DivKit/30.2.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.2.0/DivKit.podspec",
"Specs/DivKit/30.20.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.20.0/DivKit.podspec",
"Specs/DivKit/30.3.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.3.0/DivKit.podspec",
"Specs/DivKit/30.4.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.4.0/DivKit.podspec",
"Specs/DivKit/30.5.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.5.0/DivKit.podspec",
Expand Down Expand Up @@ -1010,6 +1017,7 @@
"Specs/DivKitExtensions/30.18.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.18.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.19.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.19.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.2.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.2.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.20.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.20.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.3.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.3.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.4.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.4.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.5.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.5.0/DivKitExtensions.podspec",
Expand Down Expand Up @@ -1063,6 +1071,7 @@
"Specs/DivKit_LayoutKit/30.18.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.18.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.19.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.19.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.20.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.20.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_LayoutKit/30.4.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.4.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.5.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.5.0/DivKit_LayoutKit.podspec",
Expand Down Expand Up @@ -1116,6 +1125,7 @@
"Specs/DivKit_LayoutKitInterface/30.18.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.18.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.19.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.19.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.20.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.20.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_LayoutKitInterface/30.4.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.4.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.5.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.5.0/DivKit_LayoutKitInterface.podspec",
Expand Down Expand Up @@ -1169,6 +1179,7 @@
"Specs/DivKit_Serialization/30.18.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.18.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.19.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.19.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.20.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.20.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/DivKit_Serialization/30.4.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.4.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.5.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.5.0/DivKit_Serialization.podspec",
Expand Down
15 changes: 14 additions & 1 deletion DivKit/Actions/DivActionHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public final class DivActionHandler {
private let trackVisibility: TrackVisibility
private let trackDisappear: TrackVisibility
private let variablesStorage: DivVariablesStorage
private let functionsStorage: DivFunctionsStorage?
private let persistentValuesStorage: DivPersistentValuesStorage
private let blockStateStorage: DivBlockStateStorage
private let updateCard: DivActionURLHandler.UpdateCardAction
Expand All @@ -24,13 +25,16 @@ public final class DivActionHandler {
private let copyToClipboardActionHandler = CopyToClipboardActionHandler()
private let focusElementActionHandler = FocusElementActionHandler()
private let setVariableActionHandler = SetVariableActionHandler()
private let timerActionHandler: TimerActionHandler
private let videoActionHandler = VideoActionHandler()

/// Deprecated. Do not create `DivActionHandler`. Use the instance from `DivKitComponents`.
public init(
stateUpdater: DivStateUpdater,
blockStateStorage: DivBlockStateStorage = DivBlockStateStorage(),
patchProvider: DivPatchProvider,
variablesStorage: DivVariablesStorage = DivVariablesStorage(),
functionsStorage: DivFunctionsStorage? = nil,
updateCard: @escaping DivActionURLHandler.UpdateCardAction,
showTooltip: DivActionURLHandler.ShowTooltipAction? = nil,
tooltipActionPerformer: TooltipActionPerformer? = nil,
Expand Down Expand Up @@ -58,10 +62,12 @@ public final class DivActionHandler {
self.trackVisibility = trackVisibility
self.trackDisappear = trackDisappear
self.variablesStorage = variablesStorage
self.functionsStorage = functionsStorage
self.persistentValuesStorage = persistentValuesStorage
self.blockStateStorage = blockStateStorage
self.updateCard = updateCard
self.reporter = reporter ?? DefaultDivReporter()
self.timerActionHandler = TimerActionHandler(performer: performTimerAction)
}

public func handle(
Expand Down Expand Up @@ -106,6 +112,9 @@ public final class DivActionHandler {
functionsProvider: FunctionsProvider(
persistentValuesStorage: persistentValuesStorage
),
customFunctionsStorageProvider: { [weak functionsStorage] in
functionsStorage?.getStorage(path: path, contains: $0)
},
variableValueProvider: { [unowned variablesStorage] in
if let value = localValues[$0] {
return value
Expand Down Expand Up @@ -141,7 +150,11 @@ public final class DivActionHandler {
focusElementActionHandler.handle(action, context: context)
case let .divActionSetVariable(action):
setVariableActionHandler.handle(action, context: context)
case .divActionAnimatorStart, .divActionAnimatorStop, .divActionTimer, .divActionVideo,
case let .divActionTimer(action):
timerActionHandler.handle(action, context: context)
case let .divActionVideo(action):
videoActionHandler.handle(action, context: context)
case .divActionAnimatorStart, .divActionAnimatorStop,
.divActionShowTooltip, .divActionSetState, .divActionHideTooltip:
break
case .none:
Expand Down
44 changes: 44 additions & 0 deletions DivKit/Actions/TimerActionHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Foundation
import LayoutKit
import VGSL

final class TimerActionHandler {
private let performer: DivActionURLHandler.PerformTimerAction

init (performer: @escaping DivActionURLHandler.PerformTimerAction) {
self.performer = performer
}

func handle(
_ action: DivActionTimer,
context: DivActionHandlingContext
) {
let expressionResolver = context.expressionResolver

guard let id = action.resolveId(expressionResolver),
let command = action.resolveAction(expressionResolver) else {
return
}

performer(context.path.cardId, id, command.toDivTimerAction())
}
}

extension DivActionTimer.Action {
func toDivTimerAction() -> DivTimerAction {
switch self {
case .start:
return .start
case .stop:
return .stop
case .pause:
return .pause
case .resume:
return .resume
case .cancel:
return .cancel
case .reset:
return .reset
}
}
}
27 changes: 27 additions & 0 deletions DivKit/Actions/VideoActionHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation
import LayoutKit
import VGSL

final class VideoActionHandler {
func handle(
_ action: DivActionVideo,
context: DivActionHandlingContext
) {
let expressionResolver = context.expressionResolver

guard let id = action.resolveId(expressionResolver),
let command = action.resolveAction(expressionResolver) else {
return
}

let cardId = context.path.cardId

context.blockStateStorage.setState(
id: id,
cardId: cardId,
state: VideoBlockViewState(state: command == .start ? .playing : .paused)
)

context.updateCard(.state(cardId))
}
}
16 changes: 16 additions & 0 deletions DivKit/DivBlockModelingContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public struct DivBlockModelingContext {
private(set) var cardLogId: String?
private(set) var parentDivStatePath: DivStatePath?
let stateManager: DivStateManager
public let actionHandler: DivActionHandler?
public let blockStateStorage: DivBlockStateStorage
let visibilityCounter: DivVisibilityCounting
let lastVisibleBoundsCache: DivLastVisibleBoundsCache
Expand All @@ -31,6 +32,7 @@ public struct DivBlockModelingContext {
public private(set) var errorsStorage: DivErrorsStorage
private let persistentValuesStorage: DivPersistentValuesStorage
let tooltipViewFactory: DivTooltipViewFactory?
let functionsStorage: DivFunctionsStorage?
public let variablesStorage: DivVariablesStorage
let triggersStorage: DivTriggersStorage?
public private(set) var expressionResolver: ExpressionResolver
Expand All @@ -49,6 +51,7 @@ public struct DivBlockModelingContext {
parentPath: UIElementPath? = nil,
parentDivStatePath: DivStatePath? = nil,
stateManager: DivStateManager,
actionHandler: DivActionHandler? = nil,
blockStateStorage: DivBlockStateStorage = DivBlockStateStorage(),
visibilityCounter: DivVisibilityCounting? = nil,
lastVisibleBoundsCache: DivLastVisibleBoundsCache? = nil,
Expand All @@ -58,6 +61,7 @@ public struct DivBlockModelingContext {
fontProvider: DivFontProvider? = nil,
flagsInfo: DivFlagsInfo = .default,
extensionHandlers: [DivExtensionHandler] = [],
functionsStorage: DivFunctionsStorage? = nil,
variablesStorage: DivVariablesStorage = DivVariablesStorage(),
triggersStorage: DivTriggersStorage? = nil,
playerFactory: PlayerFactory? = nil,
Expand Down Expand Up @@ -86,6 +90,7 @@ public struct DivBlockModelingContext {
parentPath: parentPath,
parentDivStatePath: parentDivStatePath,
stateManager: stateManager,
actionHandler: actionHandler,
blockStateStorage: blockStateStorage,
visibilityCounter: visibilityCounter,
lastVisibleBoundsCache: lastVisibleBoundsCache,
Expand All @@ -95,6 +100,7 @@ public struct DivBlockModelingContext {
fontProvider: fontProvider,
flagsInfo: flagsInfo,
extensionHandlers: extensionsHandlersDictionary,
functionsStorage: functionsStorage,
variablesStorage: variablesStorage,
triggersStorage: triggersStorage,
playerFactory: playerFactory,
Expand All @@ -116,6 +122,7 @@ public struct DivBlockModelingContext {
parentPath: UIElementPath?,
parentDivStatePath: DivStatePath?,
stateManager: DivStateManager,
actionHandler: DivActionHandler?,
blockStateStorage: DivBlockStateStorage,
visibilityCounter: DivVisibilityCounting?,
lastVisibleBoundsCache: DivLastVisibleBoundsCache?,
Expand All @@ -125,6 +132,7 @@ public struct DivBlockModelingContext {
fontProvider: DivFontProvider?,
flagsInfo: DivFlagsInfo,
extensionHandlers: [String: DivExtensionHandler],
functionsStorage: DivFunctionsStorage?,
variablesStorage: DivVariablesStorage,
triggersStorage: DivTriggersStorage?,
playerFactory: PlayerFactory?,
Expand All @@ -145,6 +153,7 @@ public struct DivBlockModelingContext {
self.parentPath = parentPath
self.parentDivStatePath = parentDivStatePath
self.stateManager = stateManager
self.actionHandler = actionHandler
self.blockStateStorage = blockStateStorage
self.visibilityCounter = visibilityCounter ?? DivVisibilityCounter()
self.lastVisibleBoundsCache = lastVisibleBoundsCache ?? DivLastVisibleBoundsCache()
Expand All @@ -164,6 +173,7 @@ public struct DivBlockModelingContext {
let persistentValuesStorage = persistentValuesStorage ?? DivPersistentValuesStorage()
self.persistentValuesStorage = persistentValuesStorage
self.tooltipViewFactory = tooltipViewFactory
self.functionsStorage = functionsStorage
self.variablesStorage = variablesStorage
self.triggersStorage = triggersStorage
self.extensionHandlers = extensionHandlers
Expand All @@ -176,6 +186,7 @@ public struct DivBlockModelingContext {
viewId: viewId,
path: parentPath,
variablesStorage: variablesStorage,
functionsStorage: functionsStorage,
localValues: nil,
variableTracker: variableTracker,
errorsStorage: errorsStorage
Expand Down Expand Up @@ -277,6 +288,7 @@ public struct DivBlockModelingContext {
viewId: viewId,
path: context.parentPath,
variablesStorage: variablesStorage,
functionsStorage: functionsStorage,
localValues: context.localValues,
variableTracker: variableTracker,
errorsStorage: context.errorsStorage
Expand All @@ -297,12 +309,16 @@ private func makeExpressionResolver(
viewId: DivViewId,
path: UIElementPath,
variablesStorage: DivVariablesStorage,
functionsStorage: DivFunctionsStorage?,
localValues: [String: AnyHashable]?,
variableTracker: DivVariableTracker?,
errorsStorage: DivErrorsStorage
) -> ExpressionResolver {
ExpressionResolver(
functionsProvider: functionsProvider,
customFunctionsStorageProvider: {
functionsStorage?.getStorage(path: path, contains: $0)
},
variableValueProvider: {
if let value = localValues?[$0] {
return value
Expand Down
Loading

0 comments on commit 379508e

Please sign in to comment.