Skip to content

Commit

Permalink
Merge branch 'feat/validate_service' of github.com:AkaShark/Easydict …
Browse files Browse the repository at this point in the history
…into feat/validate_service
  • Loading branch information
AkaShark committed Nov 19, 2024
2 parents e453b00 + 2665eeb commit c4ab146
Show file tree
Hide file tree
Showing 24 changed files with 311 additions and 57 deletions.
65 changes: 57 additions & 8 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
0309E1ED292B439A00AFB76A /* EZTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EC292B439A00AFB76A /* EZTextView.m */; };
0309E1F0292B4A5E00AFB76A /* NSView+EZGetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */; };
0309E1F4292BD6A100AFB76A /* EZQueryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1F3292BD6A100AFB76A /* EZQueryModel.m */; };
030D61252CD9B906000DF298 /* AcknowListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030D61242CD9B905000DF298 /* AcknowListView.swift */; };
030D612C2CD9BB34000DF298 /* Pods-Easydict-acknowledgements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 030D612B2CD9BB34000DF298 /* Pods-Easydict-acknowledgements.plist */; };
030D612E2CD9BBC3000DF298 /* Package.resolved in Resources */ = {isa = PBXBuildFile; fileRef = 030D612D2CD9BBC3000DF298 /* Package.resolved */; };
030D61312CD9C974000DF298 /* StaticWindows.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030D61302CD9C974000DF298 /* StaticWindows.swift */; };
030DB2612B56CC6500E27DEA /* BingLanguageVoice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030DB2602B56CC6500E27DEA /* BingLanguageVoice.swift */; };
0310C8272A94F5DF00B1D81E /* apple-dictionary.html in Resources */ = {isa = PBXBuildFile; fileRef = 0310C8262A94EFA100B1D81E /* apple-dictionary.html */; };
0313F8702AD5577400A5CFB0 /* EasydictTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0313F86F2AD5577400A5CFB0 /* EasydictTests.m */; };
Expand Down Expand Up @@ -243,6 +247,7 @@
03E02A2629250D1D00A10260 /* EZEventMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 03E02A2529250D1D00A10260 /* EZEventMonitor.m */; };
03E2BF752A298F2B00E010F3 /* NSString+EZUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 03E2BF742A298F2B00E010F3 /* NSString+EZUtils.m */; };
03E3E7C22ADE318800812C84 /* EZQueryMenuTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 03E3E7C12ADE318800812C84 /* EZQueryMenuTextView.m */; };
03E534BC2CE0D38C00B37264 /* AcknowList in Frameworks */ = {isa = PBXBuildFile; productRef = 03E534BB2CE0D38C00B37264 /* AcknowList */; };
03F0DB382953428300EBF9C1 /* EZLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 03F0DB372953428300EBF9C1 /* EZLog.m */; };
03F639952AA6CFBB009B9914 /* EZBingConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 03F639942AA6CFBB009B9914 /* EZBingConfig.m */; };
03FA677E2C2EFB10000FEA64 /* LLMStreamService+Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03FA677D2C2EFB10000FEA64 /* LLMStreamService+Configuration.swift */; };
Expand Down Expand Up @@ -391,6 +396,10 @@
0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSView+EZGetViewController.m"; sourceTree = "<group>"; };
0309E1F2292BD6A100AFB76A /* EZQueryModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZQueryModel.h; sourceTree = "<group>"; };
0309E1F3292BD6A100AFB76A /* EZQueryModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZQueryModel.m; sourceTree = "<group>"; };
030D61242CD9B905000DF298 /* AcknowListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcknowListView.swift; sourceTree = "<group>"; };
030D612B2CD9BB34000DF298 /* Pods-Easydict-acknowledgements.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Pods-Easydict-acknowledgements.plist"; path = "Pods/Target Support Files/Pods-Easydict/Pods-Easydict-acknowledgements.plist"; sourceTree = SOURCE_ROOT; };
030D612D2CD9BBC3000DF298 /* Package.resolved */ = {isa = PBXFileReference; lastKnownFileType = text; name = Package.resolved; path = Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved; sourceTree = SOURCE_ROOT; };
030D61302CD9C974000DF298 /* StaticWindows.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StaticWindows.swift; sourceTree = "<group>"; };
030DB2602B56CC6500E27DEA /* BingLanguageVoice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BingLanguageVoice.swift; sourceTree = "<group>"; };
0310C8262A94EFA100B1D81E /* apple-dictionary.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-dictionary.html"; sourceTree = "<group>"; };
0313F86D2AD5577400A5CFB0 /* EasydictTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EasydictTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -918,6 +927,7 @@
03B63ABF2A86967800E155ED /* CoreServices.framework in Frameworks */,
038030972B4106800009230C /* CocoaLumberjackSwift in Frameworks */,
038EA1AA2B41169C008A6DD1 /* ZipArchive in Frameworks */,
03E534BC2CE0D38C00B37264 /* AcknowList in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -997,6 +1007,24 @@
path = Model;
sourceTree = "<group>";
};
030D61262CD9BA0F000DF298 /* AcknowListView */ = {
isa = PBXGroup;
children = (
030D61242CD9B905000DF298 /* AcknowListView.swift */,
030D612B2CD9BB34000DF298 /* Pods-Easydict-acknowledgements.plist */,
030D612D2CD9BBC3000DF298 /* Package.resolved */,
);
path = AcknowListView;
sourceTree = "<group>";
};
030D612F2CD9C947000DF298 /* Windows */ = {
isa = PBXGroup;
children = (
030D61302CD9C974000DF298 /* StaticWindows.swift */,
);
path = Windows;
sourceTree = "<group>";
};
0313F86E2AD5577400A5CFB0 /* EasydictTests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1540,7 +1568,6 @@
03BDA7982A26DA000079D04F /* Libraries */,
038954372A25A94E00EFFDC3 /* Utility */,
03B0228629231FA6001C7E63 /* DarkMode */,
03B0228E29231FA6001C7E63 /* Snip */,
03B022A529231FA6001C7E63 /* MMKit */,
);
path = objc;
Expand Down Expand Up @@ -1941,6 +1968,7 @@
03BDA7982A26DA000079D04F /* Libraries */ = {
isa = PBXGroup;
children = (
03B0228E29231FA6001C7E63 /* Snip */,
033C30F82A7409C40095926A /* DictionaryKit */,
0361966B2A000E7800806370 /* FWEncryptorAES */,
03BDA7992A26DA280079D04F /* ArgumentParser */,
Expand Down Expand Up @@ -2262,6 +2290,8 @@
27FE98062B3DD525000AD654 /* View */ = {
isa = PBXGroup;
children = (
030D612F2CD9C947000DF298 /* Windows */,
030D61262CD9BA0F000DF298 /* AcknowListView */,
9643D93E2B6FC405000FBEA6 /* MenuView */,
27FE980A2B3DD5D1000AD654 /* MenuItemView.swift */,
0AC11B212B4D16A500F07198 /* WindowAccessor.swift */,
Expand Down Expand Up @@ -2677,6 +2707,7 @@
C4BE8E1B2C72E61B00F53204 /* LaunchAtLogin */,
036806572CA829F100800B76 /* SFSafeSymbols */,
03A173E62CD120E600791B51 /* SelectedTextKit */,
03E534BB2CE0D38C00B37264 /* AcknowList */,
);
productName = Bob;
productReference = C99EEB182385796700FEE666 /* Easydict-debug.app */;
Expand All @@ -2691,7 +2722,7 @@
BuildIndependentTargetsInParallel = YES;
CLASSPREFIX = EZ;
LastSwiftUpdateCheck = 1510;
LastUpgradeCheck = 1600;
LastUpgradeCheck = 1610;
ORGANIZATIONNAME = izual;
TargetAttributes = {
03022F2D2B370B7100B63209 = {
Expand Down Expand Up @@ -2743,6 +2774,7 @@
C4BE8E1A2C72E5C500F53204 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */,
036806562CA829F100800B76 /* XCRemoteSwiftPackageReference "SFSafeSymbols" */,
03A173E52CD120E600791B51 /* XCRemoteSwiftPackageReference "SelectedTextKit" */,
03E534BA2CE0D38C00B37264 /* XCRemoteSwiftPackageReference "AcknowList" */,
);
productRefGroup = C99EEB192385796700FEE666 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2785,10 +2817,12 @@
03BFBB652923998300C48725 /* [email protected] in Resources */,
03B022EC29231FA6001C7E63 /* baidu-translate-sign.js in Resources */,
03BFBB772923A09B00C48725 /* [email protected] in Resources */,
030D612E2CD9BBC3000DF298 /* Package.resolved in Resources */,
03B022F029231FA6001C7E63 /* google-translate-sign.js in Resources */,
03779F142BB256B5008D3C42 /* EncryptedSecretKeys.plist in Resources */,
03BFBB7229239E9F00C48725 /* [email protected] in Resources */,
03BFBB782923A09B00C48725 /* [email protected] in Resources */,
030D612C2CD9BB34000DF298 /* Pods-Easydict-acknowledgements.plist in Resources */,
03B022E629231FA6001C7E63 /* Assets.xcassets in Resources */,
03D1C8782952B1CD00F2C7BD /* GoogleService-Info.plist in Resources */,
03D2A3DF29F42B290035CED4 /* bd.js in Resources */,
Expand Down Expand Up @@ -3133,6 +3167,7 @@
03B0231729231FA6001C7E63 /* Snip.m in Sources */,
03BFFC6E295FE59C004E033E /* EZQueryResult+EZYoudaoDictModel.m in Sources */,
03779F0F2BB256A7008D3C42 /* LLMStreamService+Prompt.swift in Sources */,
030D61312CD9C974000DF298 /* StaticWindows.swift in Sources */,
03779F172BB256C5008D3C42 /* URL+Extension.swift in Sources */,
0315D3E02C4E64A500AC0442 /* QueryService+Translate.swift in Sources */,
6ADED1552BAE8809004A15BE /* NSBundle+Localization.m in Sources */,
Expand Down Expand Up @@ -3221,6 +3256,7 @@
03B0232B29231FA6001C7E63 /* NSMutableAttributedString+MM.m in Sources */,
03B022E829231FA6001C7E63 /* entry.m in Sources */,
0387FB7A2BFBA990000A7A82 /* LLMStreamService.swift in Sources */,
030D61252CD9B906000DF298 /* AcknowListView.swift in Sources */,
03008B3F29444B0A0062B821 /* NSView+EZAnimatedHidden.m in Sources */,
03B022FD29231FA6001C7E63 /* EZFixedQueryWindow.m in Sources */,
03B0232C29231FA6001C7E63 /* NSView+MM.m in Sources */,
Expand Down Expand Up @@ -3488,7 +3524,7 @@
CODE_SIGN_STYLE = $CODE_SIGN_STYLE;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 41;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -3503,7 +3539,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.10.0;
MARKETING_VERSION = 2.10.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.izual.Easydict-debug";
PRODUCT_MODULE_NAME = Easydict;
PRODUCT_NAME = "Easydict-debug";
Expand All @@ -3528,7 +3564,7 @@
CODE_SIGN_STYLE = $CODE_SIGN_STYLE;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 40;
CURRENT_PROJECT_VERSION = 41;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -3543,7 +3579,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.10.0;
MARKETING_VERSION = 2.10.1;
PRODUCT_BUNDLE_IDENTIFIER = com.izual.Easydict;
PRODUCT_MODULE_NAME = Easydict;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -3680,8 +3716,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/tisfeng/SelectedTextKit.git";
requirement = {
branch = main;
kind = branch;
kind = upToNextMajorVersion;
minimumVersion = 1.0.3;
};
};
03A8308B2B405F8E00112834 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand All @@ -3708,6 +3744,14 @@
minimumVersion = 10.19.1;
};
};
03E534BA2CE0D38C00B37264 /* XCRemoteSwiftPackageReference "AcknowList" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/tisfeng/AcknowList";
requirement = {
kind = revision;
revision = 6a7af0bb6ec82f77e2835b290c7e4fe950b8f7d8;
};
};
03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/krzyzanowskim/CryptoSwift";
Expand Down Expand Up @@ -3847,6 +3891,11 @@
package = 03A830932B4076FC00112834 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseAnalyticsSwift;
};
03E534BB2CE0D38C00B37264 /* AcknowList */ = {
isa = XCSwiftPackageProductDependency;
package = 03E534BA2CE0D38C00B37264 /* XCRemoteSwiftPackageReference "AcknowList" */;
productName = AcknowList;
};
03FD68BA2B1DC59600FD388E /* CryptoSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
LastUpgradeVersion = "1610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 13 additions & 5 deletions Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "68ad07a7a58de7ede24f52d8abef08548f760cda61aee03dc81b076aaa3e2aaf",
"originHash" : "6b2d9735092da5c9bc9b0a4954947f373d68f35b0939813ad8f54d785301c35e",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand All @@ -10,6 +10,14 @@
"version" : "1.2022062300.0"
}
},
{
"identity" : "acknowlist",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tisfeng/AcknowList",
"state" : {
"revision" : "6a7af0bb6ec82f77e2835b290c7e4fe950b8f7d8"
}
},
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -276,8 +284,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/microsoft/PLCrashReporter.git",
"state" : {
"revision" : "1aed8f7dc79ce8e674c61e430ef51ca3db18cea9",
"version" : "1.11.1"
"revision" : "6752f71de206f6a53fa6a758c3660fd9a7fe7527",
"version" : "1.11.2"
}
},
{
Expand Down Expand Up @@ -312,8 +320,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tisfeng/SelectedTextKit.git",
"state" : {
"branch" : "main",
"revision" : "90e1ba93646adc0efa2f6e6e424523d0648feb11"
"revision" : "b4a19071f3d2661dc1dd673e2a9206320a2f0484",
"version" : "1.0.3"
}
},
{
Expand Down
30 changes: 6 additions & 24 deletions Easydict/App/EasydictApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ struct EasydictApp: App {
Label {
Text("Easydict")
.openSettingsAccess() // trick way for open setting
.onReceive(NotificationCenter.default.publisher(
for: Notification.Name.openSettings,
object: nil
)) { _ in
.onReceive(
NotificationCenter.default.publisher(
for: Notification.Name.openSettings,
object: nil
)
) { _ in
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
// calling `openSettings` immediately doesn't work so wait a quick moment
try? openSettings()
Expand Down Expand Up @@ -97,26 +99,6 @@ struct EasydictApp: App {

@Default(.selectedMenuBarIcon) private var menuBarIcon
@StateObject private var languageState = LanguageState()

@State var aboutWindow: NSWindow?

private func showAboutWindow() {
if let aboutWindow = aboutWindow {
aboutWindow.makeKeyAndOrderFront(nil)
} else {
aboutWindow = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 500, height: 220),
styleMask: [.titled, .closable],
backing: .buffered, defer: false
)
aboutWindow?.titleVisibility = .hidden
aboutWindow?.titlebarAppearsTransparent = true
aboutWindow?.isReleasedWhenClosed = false
aboutWindow?.center()
aboutWindow?.contentView = NSHostingView(rootView: SettingsAboutTab())
aboutWindow?.makeKeyAndOrderFront(nil)
}
}
}

extension Bool {
Expand Down
35 changes: 35 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -6384,6 +6384,41 @@
}
}
},
"setting.about.acknowledgements" : {
"extractionState" : "translated",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Acknowledgements"
}
},
"en-CA" : {
"stringUnit" : {
"state" : "translated",
"value" : "Acknowledgements"
}
},
"sk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Díky"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "致谢"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "致謝"
}
}
}
},
"setting.about.contributor_link" : {
"localizations" : {
"en" : {
Expand Down
3 changes: 1 addition & 2 deletions Easydict/Swift/Service/Gemini/GeminiService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public final class GeminiService: LLMStreamService {
var systemInstruction: ModelContent? = try ModelContent(role: "system", systemPrompt)

// !!!: gemini-1.0-pro model does not support system instruction https://github.com/google-gemini/generative-ai-python/issues/328
if model == GeminiModel.gemini_1_0_pro.rawValue {
if model == "gemini-1.0-pro" {
systemInstruction = nil
enableSystemPromptInChats = true
}
Expand Down Expand Up @@ -216,7 +216,6 @@ enum GeminiModel: String, CaseIterable {

// RPM: Requests per minute, TPM: Tokens per minute
// RPD: Requests per day, TPD: Tokens per day
case gemini_1_0_pro = "gemini-1.0-pro" // Free 15 RPM/32,000 TPM, 1,500 RPD/46,080,000 TPD (n/a context length)
case gemini_1_5_flash = "gemini-1.5-flash" // Free 15 RPM/100million TPM, 1500 RPD/ n/a TPD (1048k context length)
case gemini_1_5_pro = "gemini-1.5-pro" // Free 2 RPM/32,000 TPM, 50 RPD/46,080,000 TPD (1048k context length)
case gemini_1_5_pro_exp_0801 = "gemini-1.5-pro-exp-0801" // Experimental
Expand Down
4 changes: 0 additions & 4 deletions Easydict/Swift/Utility/GetSelectedText/SharedUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
// Copyright © 2024 izual. All rights reserved.
//

import AXSwift
import AXSwiftExt
import Carbon
import KeySender
import SelectedTextKit

// MARK: - SharedUtilities
Expand Down
5 changes: 4 additions & 1 deletion Easydict/Swift/Utility/Throttler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import Foundation
class Throttler {
// MARK: Lifecycle

init(maxInterval: TimeInterval = 0.2, queue: DispatchQueue = DispatchQueue.main) {
/// - Parameters:
/// - maxInterval: The maximum interval between executions. This value should be greater than 0.2s, otherwise it may update UI too frequently, cause CPU too high.
/// - queue: The dispatch queue to execute the block on.
init(maxInterval: TimeInterval = 0.3, queue: DispatchQueue = DispatchQueue.main) {
self.maxInterval = maxInterval
self.queue = queue
}
Expand Down
Loading

0 comments on commit c4ab146

Please sign in to comment.