Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- name: Validate Release Workflow
run: bash Scripts/test-release-workflow.sh

- name: Test Release Cleanliness Check
run: bash Scripts/test-check-host-release-clean.sh

- name: Sync Derived Source
run: bash Scripts/sync-derived-source.sh

Expand Down
2 changes: 1 addition & 1 deletion LookInside/About/AboutWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import AppKit

final class AboutWindowController: WindowController {
@objc init() {
init() {
let window = AppWindow(contentRect: NSRect(x: 0, y: 0, width: 480, height: 460),
styleMask: [.titled, .closable, .fullSizeContentView],
backing: .buffered, defer: true)
Expand Down
1 change: 0 additions & 1 deletion LookInside/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import FoundationToolbox

@Loggable(subsystem: "com.lookinside.app")
@main
@objc(AppDelegate)
@MainActor
final class AppDelegate: NSObject, NSApplicationDelegate {
private var appearanceObservation: NSKeyValueObservation?
Expand Down
11 changes: 5 additions & 6 deletions LookInside/Base/BaseControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import AppKit

class BaseControl: NSControl {
@objc var clickAction: Selector?
var clickAction: Selector?

@objc var adjustAlphaWhenClick = false
var adjustAlphaWhenClick = false

@objc var didChangeAppearance: ((BaseControl?, Bool) -> Void)? {
var didChangeAppearance: ((BaseControl?, Bool) -> Void)? {
didSet {
triggerDidChangeAppearanceBlock()
}
Expand Down Expand Up @@ -47,13 +47,12 @@ class BaseControl: NSControl {
}
}

@objc(addTarget:clickAction:)
func addTarget(_ target: AnyObject?, clickAction action: Selector?) {
self.target = target
clickAction = action
}

@objc func triggerClickAction() {
func triggerClickAction() {
if let clickAction, target != nil {
sendAction(clickAction, to: target)
}
Expand All @@ -74,7 +73,7 @@ class BaseControl: NSControl {
}

/// 如果子类返回 true,则 mouseEntered: 和 mouseExited: 会被调用。默认为 false
@objc func shouldTrackMouseEnteredAndExited() -> Bool {
func shouldTrackMouseEnteredAndExited() -> Bool {
false
}

Expand Down
2 changes: 1 addition & 1 deletion LookInside/Base/BaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import AppKit

private let effectiveAppearanceContext = UnsafeMutableRawPointer.allocate(byteCount: 1, alignment: 1)

@objc enum ViewBorderPosition: Int {
enum ViewBorderPosition: Int {
case none
case top
case left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extension AttributesGroup {
/// The group's card title. `isMacTarget` describes the inspected app,
/// not the Host; it only changes the ViewLayer group, whose title names
/// the view class (`NSView` vs `UIView`), and the layout guide group.
@objc(queryDisplayTitleForMacTarget:)
func queryDisplayTitle(forMacTarget isMacTarget: Bool) -> String {
if let userCustomTitle, !userCustomTitle.isEmpty {
return userCustomTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import AppKit
import LookInsideHostCore

extension AutoLayoutConstraint {
@objc(descriptionWithItemObject:type:detailed:)
static func description(withItemObject object: InspectedObject?, type: LookinConstraintItemType, detailed: Bool) -> String {
switch type {
case .`nil`:
Expand All @@ -32,7 +31,6 @@ extension AutoLayoutConstraint {
}
}

@objc(descriptionWithAttributeInt:)
static func description(withAttributeInt attribute: Int) -> String {
if let name = ClientDisplayText.layoutAttributeName(attribute) {
return name
Expand All @@ -41,7 +39,6 @@ extension AutoLayoutConstraint {
return "unknownAttr(\(attribute))"
}

@objc(symbolWithRelation:)
static func symbol(with relation: NSLayoutConstraint.Relation) -> String {
if let symbol = ClientDisplayText.layoutRelationSymbol(relation.rawValue) {
return symbol
Expand All @@ -50,7 +47,6 @@ extension AutoLayoutConstraint {
return "?"
}

@objc(descriptionWithRelation:)
static func description(with relation: NSLayoutConstraint.Relation) -> String {
if let name = ClientDisplayText.layoutRelationName(relation.rawValue) {
return name
Expand Down
40 changes: 15 additions & 25 deletions LookInside/Base/Category/DisplayItem+LookinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import LookInsideHostCore

extension DisplayItem {
/// The row text in the hierarchy, usually the class name without module.
@objc func title() -> String {
func title() -> String {
let baseTitle: String?
if let customInfo {
baseTitle = customInfo.title
Expand All @@ -28,7 +28,7 @@ extension DisplayItem {

/// The owning window or view controller, a special trace, or the ivar
/// names that point at the object; nil when there is none.
@objc func subtitle() -> String? {
func subtitle() -> String? {
if let customInfo {
return customInfo.subtitle
}
Expand All @@ -51,7 +51,7 @@ extension DisplayItem {

/// The solo screenshot once children that draw something are shown on
/// their own; the group screenshot otherwise.
@objc func appropriateScreenshot() -> NSImage? {
func appropriateScreenshot() -> NSImage? {
// A node whose children are all pixelless (layout guides, cells, a
// view's outer layer) has nothing to exclude, and a leaf view has no
// solo screenshot at all — asking for one there blanks it out.
Expand All @@ -61,7 +61,6 @@ extension DisplayItem {
return groupScreenshot
}

@objc(bestObjectOidPreferView:)
func bestObjectOidPreferView(_: Bool) -> UInt {
switch resolvedNodeKind() {
case .window, .windowScene:
Expand Down Expand Up @@ -99,7 +98,7 @@ extension DisplayItem {
/// layer oid (backing-layer toggle ON); requests for this node must then
/// route by the view oid. Read off the tree rather than the preference,
/// so it stays false against servers that ignored the toggle.
@objc func ownsSeparateBackingLayerNode() -> Bool {
func ownsSeparateBackingLayerNode() -> Bool {
guard let layerOid = layerObject?.oid, layerOid != 0,
let viewOid = viewObject?.oid, viewOid != 0
else { return false }
Expand All @@ -119,7 +118,6 @@ extension DisplayItem {
}

/// The preferred oid first, then every other oid this node carries.
@objc(availableObjectOidsPreferView:)
func availableObjectOidsPreferView(_ preferView: Bool) -> [NSNumber] {
var oids: [UInt] = []
func add(_ oid: UInt?) {
Expand All @@ -135,24 +133,24 @@ extension DisplayItem {
}

/// Whether the title starts like a system class ("UI", "CA", "NS", "_").
@objc var representedForSystemClass: Bool {
var representedForSystemClass: Bool {
let title = title()
return title.hasPrefix("UI") || title.hasPrefix("CA") || title.hasPrefix("_") || title.hasPrefix("NS")
}

@objc func isUserCustom() -> Bool {
func isUserCustom() -> Bool {
customInfo != nil
}

/// Whether the preview can draw a box for this node.
@objc func hasPreviewBoxAbility() -> Bool {
func hasPreviewBoxAbility() -> Bool {
guard let customInfo else { return true }
return customInfo.hasValidFrame()
}

/// Whether an expanded node shows its group screenshot in the preview
/// because its solo screenshot is (nearly) empty.
@objc func usesGroupScreenshotFallbackInPreview() -> Bool {
func usesGroupScreenshotFallbackInPreview() -> Bool {
guard isExpandable, isExpanded else { return false }
// A window root's solo screenshot is always nearly transparent (just
// the frame) — its children draw the content. Falling back here
Expand All @@ -170,7 +168,7 @@ extension DisplayItem {
)
}

@objc func hasAncestorUsingGroupScreenshotFallbackInPreview() -> Bool {
func hasAncestorUsingGroupScreenshotFallbackInPreview() -> Bool {
var found = false
enumerateAncestors { item, stop in
if item.usesGroupScreenshotFallbackInPreview() {
Expand All @@ -183,7 +181,6 @@ extension DisplayItem {

/// Whether the node matches a non-empty hierarchy filter: its title,
/// subtitle or one of its objects' addresses contains the text.
@objc(isMatchedWithSearchString:)
func isMatched(withSearch string: String) -> Bool {
if string.isEmpty {
assertionFailure("an empty search string matches nothing")
Expand All @@ -207,7 +204,6 @@ extension DisplayItem {
}

/// Visits this item, then each ancestor up to the root, until stopped.
@objc(enumerateSelfAndAncestors:)
func enumerateSelfAndAncestors(_ block: (DisplayItem, UnsafeMutablePointer<ObjCBool>) -> Void) {
var item: DisplayItem? = self
while let current = item {
Expand All @@ -220,28 +216,24 @@ extension DisplayItem {
}
}

@objc(enumerateAncestors:)
func enumerateAncestors(_ block: (DisplayItem, UnsafeMutablePointer<ObjCBool>) -> Void) {
self.`super`?.enumerateSelfAndAncestors(block)
}

/// Visits this item and then its whole subtree, depth first.
@objc(enumerateSelfAndChildren:)
func enumerateSelfAndChildren(_ block: (DisplayItem) -> Void) {
block(self)
for subitem in subitems ?? [] {
subitem.enumerateSelfAndChildren(block)
}
}

@objc(itemIsKindOfClassWithName:)
func itemIsKindOfClass(withName className: String) -> Bool {
itemIsKindOfClasses(withNames: [className])
}

/// Whether any class in the displayed object's class chain, without its
/// module prefix, is one of `classNames`.
@objc(itemIsKindOfClassesWithNames:)
func itemIsKindOfClasses(withNames classNames: Set<String>) -> Bool {
guard !classNames.isEmpty, let object = displayingObject() else { return false }
let chain = object.classChainList ?? []
Expand All @@ -252,7 +244,7 @@ extension DisplayItem {

// MARK: - SwiftUI

@objc func isSwiftUISupportRelated() -> Bool {
func isSwiftUISupportRelated() -> Bool {
func looksLikeSwiftUISupport(_ object: InspectedObject?) -> Bool {
guard let object else { return false }
if ClientDisplayText.looksLikeSwiftUISupport(object.rawClassName()) {
Expand All @@ -270,7 +262,7 @@ extension DisplayItem {

/// Addresses of the layers named by "… Backed By" rows in the
/// "SwiftUI Layers" group.
@objc func swiftUIBackingLayerMemoryAddresses() -> [String] {
func swiftUIBackingLayerMemoryAddresses() -> [String] {
var addresses: [String] = []
for group in allAttributeGroups where group.userCustomTitle == "SwiftUI Layers" {
for attribute in group.allAttributes {
Expand All @@ -287,7 +279,7 @@ extension DisplayItem {

/// Display-list IDs from "… Display List ID" rows of "SwiftUI Layers"
/// and "Identity IDs" rows of "SwiftUI Display List".
@objc func swiftUIBackingDisplayListIDs() -> [NSNumber] {
func swiftUIBackingDisplayListIDs() -> [NSNumber] {
var displayListIDs: [UInt64] = []
for group in allAttributeGroups {
let isLayersGroup = group.userCustomTitle == "SwiftUI Layers"
Expand All @@ -308,7 +300,7 @@ extension DisplayItem {
}

/// The first "Display List ID" of the "SwiftUI" group, for layer nodes.
@objc func swiftUILayerDisplayListID() -> NSNumber? {
func swiftUILayerDisplayListID() -> NSNumber? {
guard layerObject != nil else { return nil }
for group in allAttributeGroups where group.userCustomTitle == "SwiftUI" {
for attribute in group.allAttributes {
Expand All @@ -322,7 +314,7 @@ extension DisplayItem {
}

/// "Source" and "Full Source" values of the "SwiftUI" group.
@objc func swiftUILayerSourceTypeNames() -> [String] {
func swiftUILayerSourceTypeNames() -> [String] {
var sourceNames: [String] = []
for group in allAttributeGroups where group.userCustomTitle == "SwiftUI" {
for attribute in group.allAttributes {
Expand All @@ -337,7 +329,7 @@ extension DisplayItem {

/// The custom node's title, then "Type" and "Full Type" values of the
/// "SwiftUI Type" group.
@objc func swiftUITypeNames() -> [String] {
func swiftUITypeNames() -> [String] {
var typeNames: [String] = []
if let customTitle = customInfo?.title {
typeNames.append(customTitle)
Expand All @@ -353,12 +345,10 @@ extension DisplayItem {
return typeNames
}

@objc(lk_validSwiftUIDisplayListIDsInString:)
static func validSwiftUIDisplayListIDs(in string: String) -> [NSNumber] {
ClientDisplayText.swiftUIDisplayListIDs(in: string).map { NSNumber(value: $0) }
}

@objc(lk_memoryAddressInObjectDescription:)
static func memoryAddress(inObjectDescription description: String) -> String? {
ClientDisplayText.memoryAddress(inObjectDescription: description)
}
Expand Down
4 changes: 2 additions & 2 deletions LookInside/Base/Category/InspectedObject+LookinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import LookInsideHostCore

extension InspectedObject {
/// The demangled class name, module prefix included.
@objc func completedDemangledClassName() -> String {
func completedDemangledClassName() -> String {
SwiftDemangler.completedParse(input: rawClassName() ?? "")
}

/// The demangled class name without its module prefix; generic
/// arguments keep theirs.
@objc func simpleDemangledClassName() -> String {
func simpleDemangledClassName() -> String {
ClientDisplayText.removingModulePrefix(SwiftDemangler.simpleParse(input: rawClassName() ?? ""))
}
}
2 changes: 1 addition & 1 deletion LookInside/Base/Category/NSAppearance+LookinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AppKit
extension NSAppearance {
/// Whether this is one of the dark appearances, including the vibrant
/// and high-contrast variants.
@objc var isDarkMode: Bool {
var isDarkMode: Bool {
[.darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark].contains(name)
}
}
2 changes: 1 addition & 1 deletion LookInside/Base/Category/NSArray+LookinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AppKit

extension NSArray {
/// The views that are not hidden. Every element must be an NSView.
@objc func visibleViews() -> [Any] {
func visibleViews() -> [Any] {
filter { object in
guard let view = object as? NSView else {
assertionFailure("visibleViews expects views only")
Expand Down
2 changes: 0 additions & 2 deletions LookInside/Base/Category/NSButton+LookinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import AppKit

extension NSButton {
/// A rounded push button, already sized 84×40.
@objc(lk_normalButtonWithTitle:target:action:)
static func normalButton(withTitle title: String, target: AnyObject?, action: Selector?) -> NSButton {
let button = NSButton()
button.bezelStyle = .rounded
Expand All @@ -20,7 +19,6 @@ extension NSButton {
}

/// A borderless image-only button; size it yourself.
@objc(lk_buttonWithImage:target:action:)
static func borderlessImageButton(with image: NSImage?, target: AnyObject?, action: Selector?) -> NSButton {
let button = NSButton()
button.image = image
Expand Down
4 changes: 2 additions & 2 deletions LookInside/Base/Category/NSColor+LookinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ extension NSColor {
}

/// "(15, 17, 19)" when opaque, "(15, 17, 19, 0.50)" otherwise.
@objc func rgbaString() -> String {
func rgbaString() -> String {
let rgba = sRGBComponentValues
return ClientDisplayText.rgbaString(red: rgba.red, green: rgba.green, blue: rgba.blue, alpha: rgba.alpha)
}

/// "#0f1113" when opaque, "#0f111380" otherwise.
@objc func hexString() -> String {
func hexString() -> String {
let rgba = sRGBComponentValues
return ClientDisplayText.hexString(red: rgba.red, green: rgba.green, blue: rgba.blue, alpha: rgba.alpha)
}
Expand Down
Loading
Loading