Skip to content

Commit

Permalink
Release 30.33.0
Browse files Browse the repository at this point in the history
commit_hash:3382acdf9d443706895eae2c474378499eddd133
  • Loading branch information
robot-divkit committed Jan 20, 2025
1 parent 5e7bef5 commit baeae01
Show file tree
Hide file tree
Showing 337 changed files with 2,960 additions and 873 deletions.
18 changes: 18 additions & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"DivKit/Animators/ProgressInterpolator.swift":"divkit/public-ios/DivKit/Animators/ProgressInterpolator.swift",
"DivKit/Animators/ValueInterpolator.swift":"divkit/public-ios/DivKit/Animators/ValueInterpolator.swift",
"DivKit/Debug/Block+DebugInfo.swift":"divkit/public-ios/DivKit/Debug/Block+DebugInfo.swift",
"DivKit/Debug/DebugBlock+UIViewRenderableBlock.swift":"divkit/public-ios/DivKit/Debug/DebugBlock+UIViewRenderableBlock.swift",
"DivKit/Debug/DebugBlock.swift":"divkit/public-ios/DivKit/Debug/DebugBlock.swift",
"DivKit/Debug/DebugErrorCollector.swift":"divkit/public-ios/DivKit/Debug/DebugErrorCollector.swift",
"DivKit/Debug/DebugParams.swift":"divkit/public-ios/DivKit/Debug/DebugParams.swift",
"DivKit/Debug/ErrorListView.swift":"divkit/public-ios/DivKit/Debug/ErrorListView.swift",
"DivKit/DivAccessibilityElementsStorage.swift":"divkit/public-ios/DivKit/DivAccessibilityElementsStorage.swift",
Expand Down Expand Up @@ -181,6 +184,7 @@
"DivKit/Timers/DivTimerStorage.swift":"divkit/public-ios/DivKit/Timers/DivTimerStorage.swift",
"DivKit/Timers/TimeIntervalMeasuring.swift":"divkit/public-ios/DivKit/Timers/TimeIntervalMeasuring.swift",
"DivKit/Tooltips/DivTooltipViewFactory.swift":"divkit/public-ios/DivKit/Tooltips/DivTooltipViewFactory.swift",
"DivKit/Types.swift":"divkit/public-ios/DivKit/Types.swift",
"DivKit/Variables/DivTriggersStorage.swift":"divkit/public-ios/DivKit/Variables/DivTriggersStorage.swift",
"DivKit/Variables/DivVariableName.swift":"divkit/public-ios/DivKit/Variables/DivVariableName.swift",
"DivKit/Variables/DivVariableStorage.swift":"divkit/public-ios/DivKit/Variables/DivVariableStorage.swift",
Expand Down Expand Up @@ -483,6 +487,14 @@
"DivKit/generated_sources/DivTextRangeBackgroundTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeBackgroundTemplate.swift",
"DivKit/generated_sources/DivTextRangeBorder.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeBorder.swift",
"DivKit/generated_sources/DivTextRangeBorderTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeBorderTemplate.swift",
"DivKit/generated_sources/DivTextRangeMask.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMask.swift",
"DivKit/generated_sources/DivTextRangeMaskBase.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskBase.swift",
"DivKit/generated_sources/DivTextRangeMaskBaseTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskBaseTemplate.swift",
"DivKit/generated_sources/DivTextRangeMaskParticles.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskParticles.swift",
"DivKit/generated_sources/DivTextRangeMaskParticlesTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskParticlesTemplate.swift",
"DivKit/generated_sources/DivTextRangeMaskSolid.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskSolid.swift",
"DivKit/generated_sources/DivTextRangeMaskSolidTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskSolidTemplate.swift",
"DivKit/generated_sources/DivTextRangeMaskTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextRangeMaskTemplate.swift",
"DivKit/generated_sources/DivTextTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTextTemplate.swift",
"DivKit/generated_sources/DivTimer.swift":"divkit/public-ios/DivKit/generated_sources/DivTimer.swift",
"DivKit/generated_sources/DivTimerTemplate.swift":"divkit/public-ios/DivKit/generated_sources/DivTimerTemplate.swift",
Expand Down Expand Up @@ -717,6 +729,7 @@
"LayoutKit/LayoutKit/ClosureIntrinsicCalculator.swift":"divkit/public-ios/LayoutKit/LayoutKit/ClosureIntrinsicCalculator.swift",
"LayoutKit/LayoutKit/Exports.swift":"divkit/public-ios/LayoutKit/LayoutKit/Exports.swift",
"LayoutKit/LayoutKit/GenericViewBlock.swift":"divkit/public-ios/LayoutKit/LayoutKit/GenericViewBlock.swift",
"LayoutKit/LayoutKit/Tooltips/TooltipAnchorView.swift":"divkit/public-ios/LayoutKit/LayoutKit/Tooltips/TooltipAnchorView.swift",
"LayoutKit/LayoutKit/Tooltips/TooltipFactory.swift":"divkit/public-ios/LayoutKit/LayoutKit/Tooltips/TooltipFactory.swift",
"LayoutKit/LayoutKit/Tooltips/TooltipManager.swift":"divkit/public-ios/LayoutKit/LayoutKit/Tooltips/TooltipManager.swift",
"LayoutKit/LayoutKit/Types.swift":"divkit/public-ios/LayoutKit/LayoutKit/Types.swift",
Expand Down Expand Up @@ -1011,6 +1024,7 @@
"Specs/DivKit/30.30.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.30.0/DivKit.podspec",
"Specs/DivKit/30.31.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.31.0/DivKit.podspec",
"Specs/DivKit/30.32.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.32.0/DivKit.podspec",
"Specs/DivKit/30.33.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.33.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",
"Specs/DivKit/30.6.0/DivKit.podspec":"divkit/public-ios/Specs/DivKit/30.6.0/DivKit.podspec",
Expand Down Expand Up @@ -1095,6 +1109,7 @@
"Specs/DivKitExtensions/30.30.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.30.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.31.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.31.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.32.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.32.0/DivKitExtensions.podspec",
"Specs/DivKitExtensions/30.33.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.33.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",
"Specs/DivKitExtensions/30.6.0/DivKitExtensions.podspec":"divkit/public-ios/Specs/DivKitExtensions/30.6.0/DivKitExtensions.podspec",
Expand Down Expand Up @@ -1161,6 +1176,7 @@
"Specs/DivKit_LayoutKit/30.30.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.30.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.31.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.31.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.32.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.32.0/DivKit_LayoutKit.podspec",
"Specs/DivKit_LayoutKit/30.33.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.33.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",
"Specs/DivKit_LayoutKit/30.6.0/DivKit_LayoutKit.podspec":"divkit/public-ios/Specs/DivKit_LayoutKit/30.6.0/DivKit_LayoutKit.podspec",
Expand Down Expand Up @@ -1227,6 +1243,7 @@
"Specs/DivKit_LayoutKitInterface/30.30.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.30.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.31.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.31.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.32.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.32.0/DivKit_LayoutKitInterface.podspec",
"Specs/DivKit_LayoutKitInterface/30.33.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.33.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",
"Specs/DivKit_LayoutKitInterface/30.6.0/DivKit_LayoutKitInterface.podspec":"divkit/public-ios/Specs/DivKit_LayoutKitInterface/30.6.0/DivKit_LayoutKitInterface.podspec",
Expand Down Expand Up @@ -1293,6 +1310,7 @@
"Specs/DivKit_Serialization/30.30.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.30.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.31.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.31.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.32.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.32.0/DivKit_Serialization.podspec",
"Specs/DivKit_Serialization/30.33.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.33.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",
"Specs/DivKit_Serialization/30.6.0/DivKit_Serialization.podspec":"divkit/public-ios/Specs/DivKit_Serialization/30.6.0/DivKit_Serialization.podspec",
Expand Down
4 changes: 2 additions & 2 deletions DivKit/Actions/ArrayActionsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ final class ArrayActionsHandler {
}

extension DivActionHandlingContext {
fileprivate func getVariableValue(_ name: DivVariableName) -> [AnyHashable]? {
fileprivate func getVariableValue(_ name: DivVariableName) -> DivArray? {
variablesStorage.getVariableValue(path: path, name: name)
}

fileprivate func setVariableValue(_ name: DivVariableName, _ value: [AnyHashable]) {
fileprivate func setVariableValue(_ name: DivVariableName, _ value: DivArray) {
variablesStorage.update(path: path, name: name, value: .array(value))
}
}
Expand Down
1 change: 0 additions & 1 deletion DivKit/Actions/DivActionInfo.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation

import LayoutKit

public struct DivActionInfo {
Expand Down
1 change: 0 additions & 1 deletion DivKit/Actions/DivActionIntent.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation

import VGSL

enum DivActionIntent {
Expand Down
1 change: 0 additions & 1 deletion DivKit/Actions/DivActionURLHandler.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import CoreGraphics
import Foundation

import LayoutKit
import VGSL

Expand Down
6 changes: 4 additions & 2 deletions DivKit/Actions/SetStoredValueActionHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ extension DivTypedValue {
.string
case .urlValue:
.url
case .arrayValue, .dictValue:
nil
case .arrayValue:
.array
case .dictValue:
.dict
}
}
}
69 changes: 7 additions & 62 deletions DivKit/Debug/Block+DebugInfo.swift
Original file line number Diff line number Diff line change
@@ -1,83 +1,28 @@
import CoreGraphics
import Foundation

import LayoutKit
import VGSL

extension Block {
func addingDebugInfo(context: DivBlockModelingContext) -> Block {
let debugParams = context.debugParams
guard debugParams.isDebugInfoEnabled else {
return self
}

let errors = context.errorsStorage.errors
let errorsCount = errors.count
guard errorsCount > 0 else {
guard debugParams.isDebugInfoEnabled,
let debugErrorCollector = context.debugErrorCollector else {
return self
}

let counterText = errorsCount > maxCount
? "\(maxCount)+"
: "\(errorsCount)"

let typo = Typo(font: context.fontProvider.font(size: 14))
.with(color: .white)

let action = UserInterfaceAction(
payload: .url(DebugInfoBlock.showOverlayURL),
path: context.parentPath + "div_errors_indicator",
accessibilityElement: nil
)

let counter = TextBlock(
widthTrait: .intrinsic,
text: counterText.with(typo: typo)
)

let indicator = counter
.addingVerticalGaps(errorsButtonCounterGaps)
.addingHorizontalGaps(calculateCounterHorizontalGaps(counter: counter))
.addingDecorations(
boundary: .clipCorner(radius: 10),
backgroundColor: .red
)
.addingEdgeInsets(debugParams.errorCounterInsets)
.addingEdgeGaps(2)
.addingAccessibilityID(withTraits: (
"divLayoutErrorCounter",
.button
))
.addingDecorations(action: action)

let debugInfoBlock = DebugInfoBlock(
child: indicator,
showDebugInfo: {
#if os(iOS)
debugParams.showDebugInfo(ErrorListView(errors: errors.map(\.prettyMessage)))
#else
return
#endif
}
let debugBlock = DebugBlock(
errorCollector: debugErrorCollector,
showDebugInfo: debugParams.showDebugInfo
)

let block = LayeredBlock(
widthTrait: calculatedWidthTrait,
heightTrait: calculatedHeightTrait,
children: [self, debugInfoBlock]
verticalChildrenAlignment: .center,
children: [self, debugBlock]
)

return block
}
}

private func calculateCounterHorizontalGaps(counter: Block) -> CGFloat {
let additionalGap = (counter.intrinsicSize.height - counter.intrinsicSize.width) / 2
return max(
errorsButtonCounterGaps,
errorsButtonCounterGaps + additionalGap
)
}

private let errorsButtonCounterGaps: CGFloat = 4
private let maxCount = 9999
98 changes: 98 additions & 0 deletions DivKit/Debug/DebugBlock+UIViewRenderableBlock.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import LayoutKit
import UIKit
import VGSL

extension DebugBlock: UIViewRenderable {
static func makeBlockView() -> any LayoutKit.BlockView {
DebugBlockView()
}

func canConfigureBlockView(_ view: any LayoutKit.BlockView) -> Bool {
view is DebugBlockView
}

func configureBlockView(
_ view: BlockView,
observer _: ElementStateObserver?,
overscrollDelegate _: ScrollDelegate?,
renderingDelegate _: RenderingDelegate?
) {
(view as? DebugBlockView)?.configure(
errorCollector: errorCollector,
showDebugInfo: showDebugInfo
)
}
}

private final class DebugBlockView: BlockView, VisibleBoundsTrackingContainer {
let effectiveBackgroundColor: UIColor? = nil
let visibleBoundsTrackingSubviews: [VisibleBoundsTrackingView] = []

private var showDebugInfo: ((ViewType) -> Void)?
private var errorCollector: DebugErrorCollector?
private let disposePool = AutodisposePool()

private let errorsLabel: UILabel = {
let label = UILabel(frame: CGRect(origin: .zero, size: CGSize(squareDimension: 50.0)))
label.text = "0"
label.numberOfLines = 1
label.font = .systemFont(ofSize: 14)
label.textColor = .white
label.textAlignment = .center
label.backgroundColor = .red
label.isHidden = true
return label
}()

init() {
super.init(frame: .zero)
addSubview(errorsLabel)
accessibilityIdentifier = "divLayoutErrorCounter"
accessibilityTraits = .button
clipsToBounds = true
addGestureRecognizer(UITapGestureRecognizer(
target: self,
action: #selector(handleTapGesture(_:))
))
}

@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func configure(
errorCollector: DebugErrorCollector,
showDebugInfo: @escaping (ViewType) -> Void
) {
self.showDebugInfo = showDebugInfo
if self.errorCollector !== errorCollector {
self.errorCollector = errorCollector
errorCollector.observableErrorCount.currentAndNewValues.addObserver { [weak self] _ in
self?.updateCountLabel()
}.dispose(in: disposePool)
}
}

override func layoutSubviews() {
super.layoutSubviews()
errorsLabel.frame = bounds
layer.cornerRadius = bounds.size.height / 2
}

private func updateCountLabel() {
let errorsCount = errorCollector?.totalErrorCount ?? 0
let isHidden = errorsCount == 0
isUserInteractionEnabled = !isHidden
errorsLabel.isHidden = isHidden
errorsLabel.text = "\(min(maxCount, errorsCount))"
}

@objc func handleTapGesture(_: UITapGestureRecognizer) {
guard let showDebugInfo, let errorCollector, errorCollector.totalErrorCount > 0 else { return }
showDebugInfo(ErrorListView(errors: errorCollector.errorList))
}
}

private let showOverlayURL = URL(string: "debugInfo://show")!
private let maxCount = 9999
47 changes: 47 additions & 0 deletions DivKit/Debug/DebugBlock.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Foundation
import LayoutKit
import VGSL

final class DebugBlock: BlockWithTraits, LayoutCachingDefaultImpl {
let widthTrait = LayoutTrait.fixed(buttonSize)
let heightTrait = LayoutTrait.fixed(buttonSize)

var intrinsicContentWidth: CGFloat {
widthTrait.fixedValue ?? 0.0
}

func intrinsicContentHeight(forWidth _: CGFloat) -> CGFloat {
heightTrait.fixedValue ?? 0.0
}

let errorCollector: DebugErrorCollector
let showDebugInfo: (ViewType) -> Void

init(
errorCollector: DebugErrorCollector,
showDebugInfo: @escaping (ViewType) -> Void
) {
self.errorCollector = errorCollector
self.showDebugInfo = showDebugInfo
}

func equals(_ other: any LayoutKit.Block) -> Bool {
if self === other { return true }
guard let other = other as? DebugBlock else { return false }
return errorCollector === other.errorCollector
}

var debugDescription: String {
"DebugBlock errors: \(errorCollector.debugDescription))"
}

func getImageHolders() -> [any VGSLUI.ImageHolder] {
[]
}

func updated(withStates _: LayoutKit.BlocksState) throws -> Self {
self
}
}

private let buttonSize = 50.0
Loading

0 comments on commit baeae01

Please sign in to comment.