Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.6.1 GM // Maintenance. #497

Merged
merged 36 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0d523f8
Repo // Boost minimum OS req. to macOS 12.
ShikiSuen Sep 28, 2023
1795fb7
SwiftPackages // Boost platform req. to macOS 11.
ShikiSuen Sep 29, 2023
30f5376
PhraseEditorUI // Fine-tweaks.
ShikiSuen Sep 29, 2023
b885366
AppInstaller // Rewrite using SwiftUI.
ShikiSuen Sep 28, 2023
d1a7219
SettingsUI // Remove an unused variable.
ShikiSuen Sep 29, 2023
42eb3bc
CtlAboutUI // Refactor using SwiftUI.
ShikiSuen Sep 29, 2023
5a3a1b8
Assets // +AppIconFallback.
ShikiSuen Sep 30, 2023
55fab42
Repo // Add SCPC sequence data from Eten DOS.
ShikiSuen Oct 2, 2023
bc50b5b
MainAssembly // Remove PrefMgrObservable.
ShikiSuen Oct 23, 2023
2a157eb
TDKCandidates // Tweak default background color.
ShikiSuen Oct 14, 2023
79b6840
SymbolMenu // Add subset for radicals.
ShikiSuen Oct 14, 2023
fd8090d
NSEvent // Use filtered modifier flags.
ShikiSuen Oct 14, 2023
b1de067
Repo // Add HangarRash_SwiftyCapsLockToggler.
ShikiSuen Oct 14, 2023
8b58c50
SessionCtl // Turn off Caps Lock if Eisu key is turned off.
ShikiSuen Oct 15, 2023
319087f
SessionCtl // Turn off isASCIIMode if CapsLock is turned off.
ShikiSuen Oct 15, 2023
71e8070
CocoaExtension // Add SecureEventInputSputnik.
ShikiSuen Oct 22, 2023
f022c89
Repo // Introduce SecurityAgentHelper.
ShikiSuen Oct 22, 2023
585ba46
Prefs // +checkAbusersOfSecureEventInputAPI().
ShikiSuen Oct 23, 2023
1bc3c19
PrefUI // +checkAbusersOfSecureEventInputAPI().
ShikiSuen Oct 23, 2023
f7778d1
PrefWindow // +checkAbusersOfSecureEventInputAPI().
ShikiSuen Oct 23, 2023
8d04a6c
Repo // Notice that Shift-key toggle only works when CpLk is OFF.
ShikiSuen Oct 25, 2023
202cb1f
Repo // Remove PreferencePane.
ShikiSuen Oct 25, 2023
d052f84
UserDef // Add 2 new keys regarding Alphanumerical Modes.
ShikiSuen Oct 26, 2023
70261c6
Prefs // Add two new UserDef items.
ShikiSuen Oct 26, 2023
78bb05d
MainAssembly // Bind two new UserDef items.
ShikiSuen Oct 26, 2023
9bc2b7b
PrefWindow // Add two new UserDef items.
ShikiSuen Oct 26, 2023
e2ddda9
PrefUI // Add two new UserDef items.
ShikiSuen Oct 26, 2023
d0392f3
NotifierUI // Compensate the window area with system notifications.
ShikiSuen Oct 26, 2023
52918df
SessionCtl // Clear ICB display before committing things.
ShikiSuen Oct 28, 2023
f0c9702
PkgInstaller // Patch some commands to let them always return 0.
ShikiSuen Oct 28, 2023
5dc48e0
InputHandler // Fix Zhuyin typing in CapsLock mode.
ShikiSuen Oct 28, 2023
230c3a4
NSEvent // Omit .capslock from .keyModifierFlags().
ShikiSuen Oct 28, 2023
eb0cc7f
SessionCtl // Hide notifications if dedicated CpLk processing is off.
ShikiSuen Oct 28, 2023
85d7403
Update Data - 20231028
ShikiSuen Oct 28, 2023
db3f6bf
[VersionUp] 3.6.1 GM Build 3610.
ShikiSuen Oct 28, 2023
a9425f4
SUPPRESSOR
ShikiSuen Oct 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 0 additions & 199 deletions Installer/AppDelegate.swift

This file was deleted.

171 changes: 171 additions & 0 deletions Installer/InstallerShared.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// (c) 2021 and onwards The vChewing Project (MIT-NTL License).
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

import AppKit
import InputMethodKit
import SwiftUI

public let kTargetBin = "vChewing"
public let kTargetBinPhraseEditor = "vChewingPhraseEditor"
public let kTargetType = "app"
public let kTargetBundle = "vChewing.app"
public let kTargetBundleWithComponents = "Library/Input%20Methods/vChewing.app"
public let kTISInputSourceID = "org.atelierInmu.inputmethod.vChewing"

let imeURLInstalled = realHomeDir.appendingPathComponent("Library/Input Methods/vChewing.app")

public let realHomeDir = URL(
fileURLWithFileSystemRepresentation: getpwuid(getuid()).pointee.pw_dir, isDirectory: true, relativeTo: nil
)
public let urlDestinationPartial = realHomeDir.appendingPathComponent("Library/Input Methods")
public let urlTargetPartial = realHomeDir.appendingPathComponent(kTargetBundleWithComponents)
public let urlTargetFullBinPartial = urlTargetPartial.appendingPathComponent("Contents/MacOS")
.appendingPathComponent(kTargetBin)

public let kDestinationPartial = urlDestinationPartial.path
public let kTargetPartialPath = urlTargetPartial.path
public let kTargetFullBinPartialPath = urlTargetFullBinPartial.path

public let kTranslocationRemovalTickInterval: TimeInterval = 0.5
public let kTranslocationRemovalDeadline: TimeInterval = 60.0

public let installingVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String ?? "BAD_INSTALLING_VER"
public let versionString = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "BAD_VER_STR"
public let copyrightLabel = Bundle.main.localizedInfoDictionary?["NSHumanReadableCopyright"] as? String ?? "BAD_COPYRIGHT_LABEL"
public let eulaContent = Bundle.main.localizedInfoDictionary?["CFEULAContent"] as? String ?? "BAD_EULA_CONTENT"
public let eulaContentUpstream = Bundle.main.infoDictionary?["CFUpstreamEULAContent"] as? String ?? "BAD_EULA_UPSTREAM"

public var mainWindowTitle: String {
"i18n:installer.INSTALLER_APP_TITLE_FULL".i18n + " (v\(versionString), Build \(installingVersion))"
}

var allRegisteredInstancesOfThisInputMethod: [TISInputSource] {
guard let components = Bundle(url: imeURLInstalled)?.infoDictionary?["ComponentInputModeDict"] as? [String: Any],
let tsInputModeListKey = components["tsInputModeListKey"] as? [String: Any]
else {
return []
}
return tsInputModeListKey.keys.compactMap { TISInputSource.generate(from: $0) }
}

// MARK: - NSApp Activation Helper

// This is to deal with changes brought by macOS 14.

public extension NSApplication {
func popup() {
#if compiler(>=5.9) && canImport(AppKit, _version: "14.0")
if #available(macOS 14.0, *) {
NSApp.activate()
} else {
NSApp.activate(ignoringOtherApps: true)
}
#else
NSApp.activate(ignoringOtherApps: true)
#endif
}
}

// MARK: - KeyWindow Finder

public extension NSApplication {
var keyWindows: [NSWindow] {
NSApp.windows.filter(\.isKeyWindow)
}
}

// MARK: - NSApp End With Delay

public extension NSApplication {
func terminateWithDelay() {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) { [weak self] in
if let this = self {
this.terminate(this)
}
}
}
}

// MARK: - Alert Message & Title Structure

public struct AlertIntel {}

public enum AlertType: String, Identifiable {
public var id: String { rawValue }
case nothing, installationFailed, missingAfterRegistration, postInstallAttention, postInstallWarning, postInstallOK

var title: LocalizedStringKey {
switch self {
case .nothing: ""
case .installationFailed: "Install Failed"
case .missingAfterRegistration: "Fatal Error"
case .postInstallAttention: "Attention"
case .postInstallWarning: "Warning"
case .postInstallOK: "Installation Successful"
}
}

var message: String {
switch self {
case .nothing: ""
case .installationFailed:
"Cannot copy the file to the destination.".i18n
case .missingAfterRegistration:
String(
format: "Cannot find input source %@ after registration.".i18n,
kTISInputSourceID
)
case .postInstallAttention:
"vChewing is upgraded, but please log out or reboot for the new version to be fully functional.".i18n
case .postInstallWarning:
"Input method may not be fully enabled. Please enable it through System Preferences > Keyboard > Input Sources.".i18n
case .postInstallOK:
"vChewing is ready to use. \n\nPlease relogin if this is the first time you install it in this user account.".i18n
}
}
}

private extension StringLiteralType {
var i18n: String { NSLocalizedString(description, comment: "") }
}

// MARK: - Shell

public extension NSApplication {
func shell(_ command: String) throws -> String {
let task = Process()
let pipe = Pipe()

task.standardOutput = pipe
task.standardError = pipe
task.arguments = ["-c", command]
if #available(macOS 10.13, *) {
task.executableURL = URL(fileURLWithPath: "/bin/zsh")
} else {
task.launchPath = "/bin/zsh"
}
task.standardInput = nil

if #available(macOS 10.13, *) {
try task.run()
} else {
task.launch()
}

var output = ""
do {
let data = try pipe.fileHandleForReading.readToEnd()
if let data = data, let str = String(data: data, encoding: .utf8) {
output.append(str)
}
} catch {
return ""
}
return output
}
}
Loading
Loading