Skip to content

Commit

Permalink
Merge branch 'release/24.1' into 91-extract-detections-to-module
Browse files Browse the repository at this point in the history
  • Loading branch information
Arclite committed May 19, 2024
2 parents 58b6ce3 + 7b5e7e6 commit a3fabf2
Show file tree
Hide file tree
Showing 132 changed files with 1,623 additions and 1,543 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
- name: "Run SwiftLint"
uses: norio-nomura/[email protected]
with:
args: "--strict"
args: "--strict --quiet --reporter github-actions-logging"

9 changes: 0 additions & 9 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
"version" : "1.2.5"
}
},
{
"identity" : "openssl",
"kind" : "remoteSourceControl",
"location" : "[email protected]:krzyzanowskim/OpenSSL.git",
"state" : {
"revision" : "84a8ae774291a4ab1971e42908d5114d98d4b623",
"version" : "3.1.5004"
}
},
{
"identity" : "performancebezier",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ disabled_rules:
- identifier_name # incompatible with "name a variable" redemption
- type_name # same
excluded:
- .build
- Derived
- vendor

cyclomatic_complexity:
Expand Down
58 changes: 54 additions & 4 deletions App/Configuration.storekit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"products" : [
{
"displayPrice" : "2.99",
"displayPrice" : "5.99",
"familyShareable" : false,
"internalID" : "F7423F26",
"localizations" : [
Expand All @@ -22,7 +22,57 @@
],
"settings" : {
"_askToBuyEnabled" : false,
"_billingIssuesEnabled" : false
"_billingIssuesEnabled" : false,
"_failTransactionsEnabled" : false,
"_locale" : "en_US",
"_storefront" : "USA",
"_storeKitErrors" : [
{
"current" : null,
"enabled" : false,
"name" : "Load Products"
},
{
"current" : null,
"enabled" : false,
"name" : "Purchase"
},
{
"current" : null,
"enabled" : false,
"name" : "Verification"
},
{
"current" : null,
"enabled" : false,
"name" : "App Store Sync"
},
{
"current" : null,
"enabled" : false,
"name" : "Subscription Status"
},
{
"current" : null,
"enabled" : false,
"name" : "App Transaction"
},
{
"current" : null,
"enabled" : false,
"name" : "Manage Subscriptions Sheet"
},
{
"current" : null,
"enabled" : false,
"name" : "Refund Request Sheet"
},
{
"current" : null,
"enabled" : false,
"name" : "Offer Code Redeem Sheet"
}
]
},
"subscriptionGroups" : [

Expand All @@ -32,7 +82,7 @@
"privateKey" : "MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgURFeyUUG7V+lJqVrfdDVGcV3iDiEBFQ76WIAK7MBH9agCgYIKoZIzj0DAQehRANCAATT6yZ9zEMzSiqYoWeZx8IHxX3ShGI73VlCUJZMt8WEzwdzWjSGGXD0zkLdWahaUrgZXOiTvOWYKWXPmHrqnlEP"
},
"version" : {
"major" : 1,
"minor" : 1
"major" : 3,
"minor" : 0
}
}
2 changes: 1 addition & 1 deletion Automator/Sources/RedactAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import AppKit
import Automator
import Detections
import DetectionsMac
import Redacting
import OSLog

Expand Down
2 changes: 1 addition & 1 deletion Automator/Sources/RedactActionExportOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import AppKit
import Redacting
import Redactions
import RedactionsMac

class RedactActionExportOperation: Operation {
var result: Result<String, Error>?
Expand Down
4 changes: 2 additions & 2 deletions Automator/Sources/RedactOperation.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Created by Geoff Pado on 11/2/20.
// Copyright © 2020 Cocoatype, LLC. All rights reserved.

import Detections
import DetectionsMac
import Foundation
import Redacting
import Redactions
import RedactionsMac

class RedactOperation: Operation {
var result: Result<String, Error>?
Expand Down
2 changes: 1 addition & 1 deletion Automator/Sources/RedactedImageExporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import AppKit
import Redacting
import Redactions
import RedactionsMac

class RedactActionExporter: NSObject {
static func export(_ input: RedactActionInput, redactions: [Redaction], completionHandler: @escaping((Result<String, Error>) -> Void)) {
Expand Down
11 changes: 11 additions & 0 deletions Highlighter.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
}
],
"defaultOptions" : {
"commandLineArgumentEntries" : [
{
"argument" : "-FeatureFlag.autoRedactInEdit YES"
}
],
"environmentVariableEntries" : [
{
"key" : "IS_TEST",
"value" : "1"
}
],
"testTimeoutsEnabled" : true
},
"testTargets" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import Defaults
import Editing
import LoggingDoubles
import TestHelpers
import XCTest

Expand Down Expand Up @@ -56,7 +57,7 @@ class AppRatingsPrompterTests: XCTestCase {

prompter.displayRatingsPrompt(in: nil)

let event = try XCTUnwrap(spy.loggedEvent)
let event = try XCTUnwrap(spy.loggedEvents.first)
XCTAssertEqual(event.value, "logError")
XCTAssertEqual(event.info, ["errorDescription": "missingWindowScene"])
}
Expand All @@ -69,14 +70,7 @@ class AppRatingsPrompterTests: XCTestCase {

prompter.displayRatingsPrompt(in: windowScene)

let event = try XCTUnwrap(spy.loggedEvent)
let event = try XCTUnwrap(spy.loggedEvents.first)
XCTAssertEqual(event.value, "AppRatingsPrompter.requestedRating")
}
}

private class SpyLogger: Logger {
private(set) var loggedEvent: Event?
func log(_ event: Event) {
loggedEvent = event
}
}
14 changes: 14 additions & 0 deletions Modules/Capabilities/DesignSystem/Sources/Tokens/Fonts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ public extension UIFont {
return regularFont(for: .subheadline)
}

// MARK: Font Loading

static let fontsRegistered: () = {
guard let fontURLs = Bundle.module.urls(forResourcesWithExtension: "otf", subdirectory: nil) else { return }
fontURLs.forEach { url in
guard let fontDataProvider = CGDataProvider(url: url as CFURL),
let font = CGFont(fontDataProvider)
else { return }

CTFontManagerRegisterGraphicsFont(font, nil)
}
}()

// MARK: Boilerplate

fileprivate static let boldFontName = "Aleo-Bold"
Expand All @@ -48,6 +61,7 @@ public extension UIFont {
}

private static func standardFont(named name: String, for textStyle: UIFont.TextStyle) -> UIFont {
_ = fontsRegistered
let size = standardFontSize(for: textStyle)
guard let appFont = UIFont(name: name, size: size) else {
ErrorHandler().crash("Couldn't get regular font")
Expand Down
11 changes: 6 additions & 5 deletions Modules/Capabilities/Detections/Sources/TextDetector.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Created by Geoff Pado on 4/22/19.
// Copyright © 2019 Cocoatype, LLC. All rights reserved.

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
import ObservationsMac
#elseif canImport(UIKit)
import Observations
import Vision

#if canImport(UIKit) && targetEnvironment(macCatalyst)
import UIKit
#elseif canImport(AppKit)
import AppKit
#endif

import Vision

open class TextDetector: NSObject {
#if canImport(UIKit) && targetEnvironment(macCatalyst)
public func detectTextRectangles(in image: UIImage, completionHandler: (([TextRectangleObservation]?) -> Void)? = nil) {
Expand Down
5 changes: 5 additions & 0 deletions Modules/Capabilities/ErrorHandling/Sources/ErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// Copyright © 2023 Cocoatype, LLC. All rights reserved.

import Foundation

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import LoggingMac
#else
import Logging
#endif

public struct ErrorHandler: ErrorHandling {
private var logger: Logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// Copyright © 2021 Cocoatype, LLC. All rights reserved.

import Foundation

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import LoggingMac
#else
import Logging
#endif

public protocol ErrorHandling {
init(logger: Logger)
Expand Down
18 changes: 6 additions & 12 deletions Modules/Capabilities/ErrorHandling/Tests/ErrorHandlerTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Created by Geoff Pado on 5/5/23.
// Copyright © 2023 Cocoatype, LLC. All rights reserved.

import LoggingDoubles
import XCTest

@testable import ErrorHandling
@testable import Logging

Expand All @@ -11,7 +13,7 @@ final class ErrorHandlerTests: XCTestCase {
let handler = ErrorHandler(logger: logger)

handler.log(SampleError.sample)
let event = try XCTUnwrap(logger.loggedEvent)
let event = try XCTUnwrap(logger.loggedEvents.first)

XCTAssertEqual(event.value, "logError")
XCTAssertEqual(event.info, ["errorDescription": "sample"])
Expand All @@ -23,7 +25,7 @@ final class ErrorHandlerTests: XCTestCase {
let error = NSError(domain: "sample", code: 19)

handler.log(error)
let event = try XCTUnwrap(logger.loggedEvent)
let event = try XCTUnwrap(logger.loggedEvents.first)

XCTAssertEqual(event.value, "logError")
XCTAssertEqual(event.info, ["errorDescription": "sample - 19: The operation couldn’t be completed. (sample error 19.)"])
Expand All @@ -33,7 +35,7 @@ final class ErrorHandlerTests: XCTestCase {
let logger = SpyLogger()
let crashExpectation = expectation(description: "exit method called")
let handler = ErrorHandler(logger: logger) { message in
guard let event = logger.loggedEvent else { return Self.stubbedExit() }
guard let event = logger.loggedEvents.first else { return Self.stubbedExit() }
XCTAssertEqual(event.value, "crash")
XCTAssertEqual(event.info, ["message": "crash"])
XCTAssertEqual(message, "crash")
Expand All @@ -52,7 +54,7 @@ final class ErrorHandlerTests: XCTestCase {
let logger = SpyLogger()
let crashExpectation = expectation(description: "exit method called")
let handler = ErrorHandler(logger: logger) { message in
guard let event = logger.loggedEvent else { return Self.stubbedExit() }
guard let event = logger.loggedEvents.first else { return Self.stubbedExit() }
XCTAssertEqual(event.value, "notImplemented")
XCTAssertEqual(event.info["file"], #fileID)
XCTAssertEqual(event.info["function"], #function)
Expand All @@ -78,11 +80,3 @@ final class ErrorHandlerTests: XCTestCase {
private enum SampleError: Error {
case sample
}

private final class SpyLogger: Logger {
var loggedEvent: Event?

func log(_ event: Event) {
loggedEvent = event
}
}
19 changes: 19 additions & 0 deletions Modules/Capabilities/Logging/Doubles/SpyLogger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Created by Geoff Pado on 5/16/24.
// Copyright © 2024 Cocoatype, LLC. All rights reserved.

import Logging
import TestHelpersInterface

public class SpyLogger: Logger {
public init(
logExpectation: Expectation? = nil
) {
self.logExpectation = logExpectation
}

private(set) public var loggedEvents = [Event]()
public var logExpectation: Expectation?
public func log(_ event: Event) {
loggedEvents.append(event)
}
}
6 changes: 6 additions & 0 deletions Modules/Capabilities/Logging/Sources/Logging.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Created by Geoff Pado on 5/16/24.
// Copyright © 2024 Cocoatype, LLC. All rights reserved.

public enum Logging {
public static let logger = TelemetryLogger()
}

This file was deleted.

Loading

0 comments on commit a3fabf2

Please sign in to comment.