Skip to content

Commit

Permalink
chore: updates dependencies (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhermawan authored Jul 13, 2024
1 parent 3c44447 commit 825c423
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 104 deletions.
32 changes: 16 additions & 16 deletions Canvas.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
0A03693D2B4D6FBB00D7DAD4 /* SettingsModule in Frameworks */ = {isa = PBXBuildFile; productRef = 0A03693C2B4D6FBB00D7DAD4 /* SettingsModule */; };
0A20744D2B3CD3E5008516D1 /* ModelPricingModule in Frameworks */ = {isa = PBXBuildFile; productRef = 0A20744C2B3CD3E5008516D1 /* ModelPricingModule */; };
0A211A2A2C42D1C900B9029F /* AppInfo in Frameworks */ = {isa = PBXBuildFile; productRef = 0A211A292C42D1C900B9029F /* AppInfo */; };
0A809A402B39752200C9A015 /* CanvasApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A809A3F2B39752200C9A015 /* CanvasApp.swift */; };
0A809A462B39752300C9A015 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A809A452B39752300C9A015 /* Assets.xcassets */; };
0A809A492B39752300C9A015 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A809A482B39752300C9A015 /* Preview Assets.xcassets */; };
Expand All @@ -26,7 +27,6 @@
0A809A7C2B39988000C9A015 /* Defaults+Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A809A7B2B39988000C9A015 /* Defaults+Keys.swift */; };
0A809A7F2B39DDB100C9A015 /* CoreExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = 0A809A7E2B39DDB100C9A015 /* CoreExtensions */; };
0A809A812B39DDBA00C9A015 /* CoreModels in Frameworks */ = {isa = PBXBuildFile; productRef = 0A809A802B39DDBA00C9A015 /* CoreModels */; };
0A809A842B39EB0100C9A015 /* AppInfo in Frameworks */ = {isa = PBXBuildFile; productRef = 0A809A832B39EB0100C9A015 /* AppInfo */; };
0AE400612B3A98E600307732 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 0AE400602B3A98E600307732 /* Localizable.xcstrings */; };
0AE400642B3AD5F800307732 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 0AE400632B3AD5F800307732 /* Sparkle */; };
0AE400662B3AD84700307732 /* AppUpdater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE400652B3AD84700307732 /* AppUpdater.swift */; };
Expand Down Expand Up @@ -63,7 +63,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0A809A842B39EB0100C9A015 /* AppInfo in Frameworks */,
0A20744D2B3CD3E5008516D1 /* ModelPricingModule in Frameworks */,
0A809A632B397C3B00C9A015 /* ImageEditModule in Frameworks */,
0A809A612B397C3B00C9A015 /* CoreViews in Frameworks */,
Expand All @@ -76,6 +75,7 @@
0A809A812B39DDBA00C9A015 /* CoreModels in Frameworks */,
0A809A792B39986D00C9A015 /* Defaults in Frameworks */,
0A809A7F2B39DDB100C9A015 /* CoreExtensions in Frameworks */,
0A211A2A2C42D1C900B9029F /* AppInfo in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -209,10 +209,10 @@
0A809A782B39986D00C9A015 /* Defaults */,
0A809A7E2B39DDB100C9A015 /* CoreExtensions */,
0A809A802B39DDBA00C9A015 /* CoreModels */,
0A809A832B39EB0100C9A015 /* AppInfo */,
0AE400632B3AD5F800307732 /* Sparkle */,
0A20744C2B3CD3E5008516D1 /* ModelPricingModule */,
0A03693C2B4D6FBB00D7DAD4 /* SettingsModule */,
0A211A292C42D1C900B9029F /* AppInfo */,
);
productName = Canvas;
productReference = 0A809A3C2B39752200C9A015 /* Canvas.app */;
Expand Down Expand Up @@ -244,8 +244,8 @@
mainGroup = 0A809A332B39752200C9A015;
packageReferences = (
0A809A772B39986D00C9A015 /* XCRemoteSwiftPackageReference "Defaults" */,
0A809A822B39EB0100C9A015 /* XCRemoteSwiftPackageReference "AppInfo" */,
0AE400622B3AD5F800307732 /* XCRemoteSwiftPackageReference "Sparkle" */,
0A211A282C42D1C900B9029F /* XCRemoteSwiftPackageReference "AppInfo" */,
);
productRefGroup = 0A809A3D2B39752200C9A015 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -495,28 +495,28 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
0A809A772B39986D00C9A015 /* XCRemoteSwiftPackageReference "Defaults" */ = {
0A211A282C42D1C900B9029F /* XCRemoteSwiftPackageReference "AppInfo" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/Defaults.git";
repositoryURL = "https://github.com/kevinhermawan/AppInfo.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 7.3.1;
minimumVersion = 1.0.2;
};
};
0A809A822B39EB0100C9A015 /* XCRemoteSwiftPackageReference "AppInfo" */ = {
0A809A772B39986D00C9A015 /* XCRemoteSwiftPackageReference "Defaults" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/kevinhermawan/AppInfo";
repositoryURL = "https://github.com/sindresorhus/Defaults.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.2;
minimumVersion = 8.2.0;
};
};
0AE400622B3AD5F800307732 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.5.2;
minimumVersion = 2.6.4;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand All @@ -530,6 +530,11 @@
isa = XCSwiftPackageProductDependency;
productName = ModelPricingModule;
};
0A211A292C42D1C900B9029F /* AppInfo */ = {
isa = XCSwiftPackageProductDependency;
package = 0A211A282C42D1C900B9029F /* XCRemoteSwiftPackageReference "AppInfo" */;
productName = AppInfo;
};
0A809A5A2B397B6100C9A015 /* CoreViewModels */ = {
isa = XCSwiftPackageProductDependency;
productName = CoreViewModels;
Expand Down Expand Up @@ -567,11 +572,6 @@
isa = XCSwiftPackageProductDependency;
productName = CoreModels;
};
0A809A832B39EB0100C9A015 /* AppInfo */ = {
isa = XCSwiftPackageProductDependency;
package = 0A809A822B39EB0100C9A015 /* XCRemoteSwiftPackageReference "AppInfo" */;
productName = AppInfo;
};
0AE400632B3AD5F800307732 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 0AE400622B3AD5F800307732 /* XCRemoteSwiftPackageReference "Sparkle" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/Defaults.git",
"state" : {
"revision" : "3efef5a28ebdbbe922d4a2049493733ed14475a6",
"version" : "7.3.1"
"revision" : "38925e3cfacf3fb89a81a35b1cd44fd5a5b7e0fa",
"version" : "8.2.0"
}
},
{
Expand All @@ -41,17 +41,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kean/Nuke.git",
"state" : {
"revision" : "1694798e876113d44f6ec6ead965d7286695981d",
"version" : "12.2.0"
"revision" : "0ead44350d2737db384908569c012fe67c421e4d",
"version" : "12.8.0"
}
},
{
"identity" : "openai",
"kind" : "remoteSourceControl",
"location" : "https://github.com/MacPaw/OpenAI.git",
"state" : {
"branch" : "main",
"revision" : "497266a278de1f32a609981e0012faabcf2091b4"
"revision" : "fd13a41e987004d14f1793c570721953a2767b03",
"version" : "0.2.9"
}
},
{
Expand Down Expand Up @@ -86,8 +86,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kevinhermawan/ViewState.git",
"state" : {
"revision" : "8e5a5efbbf3fb5a2d2621533a115a9da031214cb",
"version" : "1.2.1"
"revision" : "6c85c207c23edf487007542651e3533a80dfa0bc",
"version" : "1.2.2"
}
}
],
Expand Down
7 changes: 3 additions & 4 deletions Canvas/Extensions/Defaults+Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import Foundation
extension Defaults.Keys {
static let ig_selectedModel = Key<DalleModel>("ig_selectedModel", default: .dalle2)
static let ig_selectedNumber = Key<Int>("ig_selectedNumber", default: DalleModel.dalle2.numbers[0])
static let ig_selectedSize = Key<String>("ig_selectedSize", default: DalleModel.dalle2.sizes[0])
static let ig_selectedSize = Key<DalleModel.Size>("ig_selectedSize", default: ._1024)
static let ig_selectedQuality = Key<DalleModel.Quality?>("ig_selectedQuality", default: .standard)
static let ig_selectedStyle = Key<DalleModel.Style?>("ig_selectedStyle", default: .vivid)

static let ie_selectedNumber = Key<Int>("ie_selectedNumber", default: DalleModel.dalle2.numbers[0])
static let ie_selectedSize = Key<String>("ie_selectedSize", default: DalleModel.dalle2.sizes[0])

static let ie_selectedSize = Key<DalleModel.Size>("ie_selectedSize", default: ._1024)

static let iv_selectedNumber = Key<Int>("iv_selectedNumber", default: DalleModel.dalle2.numbers[0])
static let iv_selectedSize = Key<String>("iv_selectedSize", default: DalleModel.dalle2.sizes[0])
static let iv_selectedSize = Key<DalleModel.Size>("iv_selectedSize", default: ._1024)
}
2 changes: 1 addition & 1 deletion CoreModels/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["CoreModels"]),
],
dependencies: [
.package(url: "https://github.com/sindresorhus/Defaults.git", .upToNextMajor(from: "7.3.1"))
.package(url: "https://github.com/sindresorhus/Defaults.git", .upToNextMajor(from: "8.2.0"))
],
targets: [
.target(
Expand Down
83 changes: 70 additions & 13 deletions CoreModels/Sources/CoreModels/DalleModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Defaults
import Foundation
import OpenAI

public enum DalleModel: String, CaseIterable {
case dalle2 = "dall-e-2"
Expand All @@ -29,15 +30,6 @@ public enum DalleModel: String, CaseIterable {
return Array(arrayLiteral: 1)
}
}

public var sizes: [String] {
switch self {
case .dalle2:
return ["256x256", "512x512", "1024x1024"]
case .dalle3:
return ["1024x1024", "1024x1792", "1792x1024"]
}
}
}

extension DalleModel: Identifiable {
Expand All @@ -48,10 +40,58 @@ extension DalleModel: Identifiable {

extension DalleModel: Codable, Defaults.Serializable {}

extension DalleModel {
public enum Size: String, CaseIterable, Identifiable, Codable, Defaults.Serializable {
case _256, _512, _1024, _1024_1792, _1792_1024

public var id: String {
self.rawValue
}

public var title: String {
switch self {
case ._256:
return "256x256 (Square)"
case ._512:
return "512x512 (Square)"
case ._1024:
return "1024x1024 (Square)"
case ._1024_1792:
return "1024x1792 (Landscape)"
case ._1792_1024:
return "1792x1024 (Portrait)"
}
}

public var imagesQuery: ImagesQuery.Size {
switch self {
case ._256:
return ._256
case ._512:
return ._512
case ._1024:
return ._1024
case ._1024_1792:
return ._1024_1792
case ._1792_1024:
return ._1792_1024
}
}
}

public var sizes: [Size] {
switch self {
case .dalle2:
return [._256, ._512, ._1024]
case .dalle3:
return [._1024, ._1024_1792, ._1792_1024]
}
}
}

extension DalleModel {
public enum Quality: String, CaseIterable, Identifiable, Codable, Defaults.Serializable {
case standard
case hd
case standard, hd

public var id: String {
self.rawValue
Expand All @@ -65,6 +105,15 @@ extension DalleModel {
return "HD"
}
}

public var imagesQuery: ImagesQuery.Quality {
switch self {
case .standard:
return .standard
case .hd:
return .hd
}
}
}

public var qualities: [Quality]? {
Expand All @@ -79,8 +128,7 @@ extension DalleModel {

extension DalleModel {
public enum Style: String, CaseIterable, Identifiable, Defaults.Serializable {
case vivid
case natural
case vivid, natural

public var id: String {
self.rawValue
Expand All @@ -94,6 +142,15 @@ extension DalleModel {
return "Natural"
}
}

public var imagesQuery: ImagesQuery.Style {
switch self {
case .vivid:
return .vivid
case .natural:
return .natural
}
}
}

public var styles: [Style]? {
Expand Down
4 changes: 2 additions & 2 deletions CoreViewModels/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ let package = Package(
.package(name: "CoreModels", path: "../CoreModels"),
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", .upToNextMajor(from: "4.2.2")),
.package(url: "https://github.com/kevinhermawan/AppInfo.git", .upToNextMajor(from: "1.0.2")),
.package(url: "https://github.com/kevinhermawan/ViewState.git", .upToNextMajor(from: "1.2.1")),
.package(url: "https://github.com/MacPaw/OpenAI.git", branch: "main")
.package(url: "https://github.com/kevinhermawan/ViewState.git", .upToNextMajor(from: "1.2.2")),
.package(url: "https://github.com/MacPaw/OpenAI.git", .upToNextMajor(from: "0.2.9"))
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion CoreViews/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["CoreViews"]),
],
dependencies: [
.package(url: "https://github.com/kean/Nuke.git", .upToNextMajor(from: "12.2.0")),
.package(url: "https://github.com/kean/Nuke.git", .upToNextMajor(from: "12.8.0")),
.package(url: "https://github.com/kevinhermawan/ChatField.git", .upToNextMajor(from: "1.0.0"))
],
targets: [
Expand Down
14 changes: 6 additions & 8 deletions ImageEditModule/Sources/ImageEditModule/ImageEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import CoreExtensions
import CoreModels
import CoreViewModels
import CoreViews
import Defaults
Expand All @@ -20,13 +21,13 @@ public struct ImageEditView: View {
@State private var prompt: String = ""

private var number: Int
private var size: String
private var size: DalleModel.Size?
private var imageData: Data?
private var maskData: Data?

public init(
number: Int,
size: String,
size: DalleModel.Size? = nil,
imageData: Data? = nil,
maskData: Data? = nil
) {
Expand Down Expand Up @@ -66,12 +67,9 @@ public struct ImageEditView: View {
@MainActor
func generationAction() {
guard let image = imageData else { return }
let fileName = UUID().uuidString

let mask = maskData
let maskFileName: String? = mask.isNotNil ? UUID().uuidString : nil

let query = ImageEditsQuery(image: image, fileName: fileName, mask: mask, maskFileName: maskFileName, prompt: prompt, n: number, size: size)
guard let mask = maskData else { return }
let size = size?.imagesQuery
let query = ImageEditsQuery(image: image, prompt: prompt, mask: mask, size: size)

dalleViewModel.setup(apiKey: settingsManager.apiKey)
dalleViewModel.imageEdit(query: query)
Expand Down
Loading

0 comments on commit 825c423

Please sign in to comment.