mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
swift 6 makes me wanna kms
This commit is contained in:
13 files changed
+165
-81
No files matched your search
@@ -932,7 +932,7 @@
|
||||
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,7";
|
||||
XROS_DEPLOYMENT_TARGET = 1;
|
||||
};
|
||||
@@ -984,7 +984,7 @@
|
||||
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,7";
|
||||
XROS_DEPLOYMENT_TARGET = 1;
|
||||
};
|
||||
@@ -1017,7 +1017,7 @@
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1049,7 +1049,7 @@
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
@@ -1072,7 +1072,7 @@
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StickerSlack.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/StickerSlack";
|
||||
};
|
||||
@@ -1095,7 +1095,7 @@
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SWIFT_VERSION = 6.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StickerSlack.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/StickerSlack";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2630"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "A986A6AC2EB658DF00B6E0FA"
|
||||
BuildableName = "StickerSlackiMessageApp.appex"
|
||||
BlueprintName = "StickerSlackiMessageApp"
|
||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
||||
BuildableName = "StickerSlack.app"
|
||||
BlueprintName = "StickerSlack"
|
||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
||||
BuildableName = "StickerSlack.app"
|
||||
BlueprintName = "StickerSlack"
|
||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
||||
BuildableName = "StickerSlack.app"
|
||||
BlueprintName = "StickerSlack"
|
||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -11,16 +11,11 @@ import SwiftUI
|
||||
import Messages
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
@MainActor
|
||||
struct Emoji: StickerProtocol {
|
||||
var id: String
|
||||
var name: String
|
||||
var typeGlyph: String = "slack.logo"
|
||||
var localImageURLString: String {
|
||||
let urlString = remoteImageURL.absoluteString
|
||||
let split = urlString.split(separator: ".")
|
||||
let fileExtension = ".\(split.last ?? "png")"
|
||||
return EmojiHoarder.container.path()+name+"."+id+fileExtension
|
||||
}
|
||||
var remoteImageURL: URL
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
|
||||
@@ -12,7 +12,7 @@ import UniformTypeIdentifiers
|
||||
import Haptics
|
||||
|
||||
class EmojiHoarder: BaseHoarder {
|
||||
static let container: URL = library.appendingPathComponent("Emojis", conformingTo: .directory)
|
||||
nonisolated static let container: URL = library.appendingPathComponent("Emojis", conformingTo: .directory)
|
||||
nonisolated static let localEmojiDB: URL = EmojiHoarder.library.appendingPathComponent("_____localEmojiDB.json", conformingTo: .fileURL)
|
||||
nonisolated static let localTrieDict: URL = EmojiHoarder.library.appendingPathComponent("_____localTrieDict.json", conformingTo: .fileURL)
|
||||
let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")!
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
extension Emoji {
|
||||
static var test: Emoji = Emoji(
|
||||
name: "a test slack emoji",
|
||||
@@ -19,6 +20,7 @@ extension Emoji {
|
||||
)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
extension Gif {
|
||||
static var test: Gif = GifObject(
|
||||
type: "gif",
|
||||
@@ -120,6 +122,7 @@ extension Gif {
|
||||
).toGif
|
||||
}
|
||||
|
||||
@MainActor
|
||||
extension EmojiPack {
|
||||
static var test: EmojiPack {
|
||||
EmojiPack(
|
||||
|
||||
@@ -9,18 +9,11 @@ import Foundation
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
@MainActor
|
||||
struct Gif: StickerProtocol {
|
||||
var id: String
|
||||
var name: String
|
||||
var typeGlyph: String = "giphy.logo"
|
||||
|
||||
var localImageURLString: String {
|
||||
let urlString = remoteImageURL.absoluteString
|
||||
let split = urlString.split(separator: ".")
|
||||
let fileExtension = ".\(split.last ?? "png")"
|
||||
|
||||
return GifHoarder.container.path()+name+"."+id+fileExtension
|
||||
}
|
||||
var remoteImageURL: URL
|
||||
|
||||
var giphyImages: GiphyImages?
|
||||
@@ -40,23 +33,4 @@ struct Gif: StickerProtocol {
|
||||
self.giphyImages = giphyImages
|
||||
self.remoteImageURL = url
|
||||
}
|
||||
|
||||
func downloadImage() async throws {
|
||||
if let data = try? Data(contentsOf: localImageURL),
|
||||
let _ = UIImage(data: data) {
|
||||
return
|
||||
}
|
||||
|
||||
var (data, _) = try await URLSession.shared.data(from: remoteImageURL)
|
||||
|
||||
if let uiImage = UIImage(data: data),
|
||||
let cgImage = uiImage.cgImage,
|
||||
!self.localImageURLString.contains(".gif"),
|
||||
cgImage.width < 300 || cgImage.height < 300 {
|
||||
data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
||||
}
|
||||
|
||||
try! data.write(to: localImageURL)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import UniformTypeIdentifiers
|
||||
import Combine
|
||||
|
||||
class GifHoarder: BaseHoarder {
|
||||
static let container: URL = library.appendingPathComponent("Gifs", conformingTo: .directory)
|
||||
nonisolated static let container: URL = library.appendingPathComponent("Gifs", conformingTo: .directory)
|
||||
|
||||
static var apiKey: String = "a2mFsDTpX5blodY8ltkG6Q1xy5NgFSbc"
|
||||
var endpoint: URL = URL(string: "https://api.giphy.com/v1/gifs/trending")!
|
||||
|
||||
@@ -22,8 +22,7 @@ protocol Hoarder: ObservableObject {
|
||||
}
|
||||
|
||||
class BaseHoarder: Hoarder {
|
||||
|
||||
static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
||||
nonisolated static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
||||
|
||||
@Published var downloadedStickers: Set<String> = []
|
||||
|
||||
@@ -49,7 +48,7 @@ class BaseHoarder: Hoarder {
|
||||
}
|
||||
} else {
|
||||
var newSet: Set<String> = []
|
||||
let url = await BaseHoarder.library.appendingPathComponent(stickerType, conformingTo: .directory)
|
||||
let url = BaseHoarder.library.appendingPathComponent(stickerType, conformingTo: .directory)
|
||||
if let files = try? FileManager.default.contentsOfDirectory(atPath: url.path()) {
|
||||
for file in files {
|
||||
let name = String(file.split(separator: ".")[0])
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
struct SlackResponse: Identifiable, Codable {
|
||||
var type: String
|
||||
var id: String
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
struct GifObject: Codable, Identifiable {
|
||||
var type: String
|
||||
var id: String
|
||||
|
||||
@@ -8,31 +8,23 @@
|
||||
import Foundation
|
||||
import Messages
|
||||
|
||||
nonisolated
|
||||
extension StickerProtocol {
|
||||
var localImageURL: URL {
|
||||
nonisolated var localImageURLString: String {
|
||||
let urlString = remoteImageURL.absoluteString
|
||||
let split = urlString.split(separator: ".")
|
||||
let fileExtension = ".\(split.last ?? "png")"
|
||||
|
||||
return GifHoarder.container.path()+name+"."+id+fileExtension
|
||||
}
|
||||
|
||||
nonisolated var localImageURL: URL {
|
||||
return URL(filePath: localImageURLString)
|
||||
}
|
||||
|
||||
var msSticker: MSSticker? {
|
||||
guard FileManager.default.fileExists(atPath: localImageURLString) else {
|
||||
return nil
|
||||
}
|
||||
return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
|
||||
}
|
||||
|
||||
var image: UIImage? {
|
||||
if FileManager.default.fileExists(atPath: localImageURLString),
|
||||
let data = try? Data(contentsOf: localImageURL),
|
||||
let img = UIImage(data: data) {
|
||||
return img
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated
|
||||
func downloadImage() async throws {
|
||||
if let data = try? await Data(contentsOf: localImageURL),
|
||||
if let data = try? Data(contentsOf: localImageURL),
|
||||
let _ = UIImage(data: data) {
|
||||
return
|
||||
}
|
||||
@@ -41,20 +33,24 @@ extension StickerProtocol {
|
||||
|
||||
if let uiImage = UIImage(data: data),
|
||||
let cgImage = uiImage.cgImage,
|
||||
await !self.localImageURLString.contains(".gif"),
|
||||
!self.localImageURLString.contains(".gif"),
|
||||
cgImage.width < 300 || cgImage.height < 300 {
|
||||
data = await resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
||||
data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
||||
}
|
||||
try! await data.write(to: localImageURL)
|
||||
try! data.write(to: localImageURL)
|
||||
return
|
||||
}
|
||||
|
||||
nonisolated
|
||||
func deleteImage() {
|
||||
try? FileManager.default.removeItem(at: localImageURL)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func resize(image: UIImage, to targetSize: CGSize) -> UIImage {
|
||||
@MainActor
|
||||
extension StickerProtocol {
|
||||
func resize(image: UIImage, to targetSize: CGSize) -> UIImage {
|
||||
let oldSize = image.size
|
||||
let ratio: (x: CGFloat, y: CGFloat)
|
||||
ratio.x = targetSize.width / oldSize.width
|
||||
@@ -84,4 +80,21 @@ extension StickerProtocol {
|
||||
image.draw(in: rect)
|
||||
return UIGraphicsGetImageFromCurrentImageContext() ?? UIImage()
|
||||
}
|
||||
|
||||
/*nonisolated*/ var msSticker: MSSticker? {
|
||||
guard FileManager.default.fileExists(atPath: localImageURLString) else {
|
||||
return nil
|
||||
}
|
||||
return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
|
||||
}
|
||||
|
||||
/*nonisolated*/ var image: UIImage? {
|
||||
if FileManager.default.fileExists(atPath: localImageURLString),
|
||||
let data = try? Data(contentsOf: localImageURL),
|
||||
let img = UIImage(data: data) {
|
||||
return img
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,21 +8,22 @@
|
||||
import Foundation
|
||||
import Messages
|
||||
|
||||
nonisolated
|
||||
protocol StickerProtocol: Codable, Identifiable, Hashable {
|
||||
var id: String { get set }
|
||||
var name: String { get set }
|
||||
nonisolated var id: String { get set }
|
||||
nonisolated var name: String { get set }
|
||||
|
||||
var typeGlyph: String { get }
|
||||
nonisolated var typeGlyph: String { get }
|
||||
|
||||
var localImageURL: URL { get }
|
||||
var localImageURLString: String { get }
|
||||
var remoteImageURL: URL { get set }
|
||||
nonisolated var localImageURL: URL { get }
|
||||
nonisolated var localImageURLString: String { get }
|
||||
nonisolated var remoteImageURL: URL { get set }
|
||||
|
||||
var msSticker: MSSticker? { get }
|
||||
var image: UIImage? { get }
|
||||
nonisolated var msSticker: MSSticker? { get }
|
||||
nonisolated var image: UIImage? { get }
|
||||
|
||||
func downloadImage() async throws
|
||||
func deleteImage()
|
||||
func resize(image: UIImage, to targetSize: CGSize) -> UIImage
|
||||
static var test: Self { get }
|
||||
nonisolated func downloadImage() async throws
|
||||
nonisolated func deleteImage()
|
||||
nonisolated func resize(image: UIImage, to targetSize: CGSize) -> UIImage
|
||||
nonisolated static var test: Self { get }
|
||||
}
|
||||
@@ -15,8 +15,8 @@ class TrieNode: Codable {
|
||||
var isEndOfWord: Bool = false
|
||||
}
|
||||
|
||||
nonisolated
|
||||
class Trie: ObservableObject {
|
||||
//nonisolated
|
||||
actor Trie: ObservableObject {
|
||||
var root: TrieNode = TrieNode()
|
||||
var dict: [String:Emoji] = [:]
|
||||
|
||||
|
||||