nitro-ui-macos 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +21 -0
- package/PARITY.md +373 -0
- package/README.md +147 -2
- package/native/nitro-core/Package.swift +78 -0
- package/native/nitro-ui-core/Package.swift +112 -0
- package/native/nitro-ui-core/Sources/NitroUICoreMac/AnimationFrameDisplayLink.swift +127 -0
- package/native/nitro-ui-core/Sources/NitroUICoreMac/HybridAnimationFrameScheduler.swift +91 -0
- package/native/nitro-ui-core/Sources/NitroUICoreMac/HybridLinking.swift +18 -0
- package/native/nitro-ui-dev/Package.swift +102 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevBundleLoad.swift +14 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevBundleLoader.swift +85 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevLauncher.swift +192 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevMenu.swift +172 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevServerBrowser.swift +86 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevSession.swift +151 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevShortcuts.swift +85 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevToast.swift +85 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/DevTools.swift +141 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/ErrorModels.swift +97 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/ErrorOverlay.swift +698 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/HybridDevBundles.swift +64 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/HybridDevErrors.swift +56 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/HybridDevLoadingView.swift +27 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/HybridDevMenu.swift +40 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/HybridDevToast.swift +19 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/LauncherWindowController.swift +217 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/LoadingOverlay.swift +104 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/RegisterDevLoader.swift +22 -0
- package/native/nitro-ui-dev/Sources/NitroUIDevMac/SavedBundles.swift +70 -0
- package/native/nitro-ui-glass/Package.swift +103 -0
- package/native/nitro-ui-glass/macos/HybridLiquidGlass.swift +5 -0
- package/native/nitro-ui-glass/macos/HybridNativeLiquidGlassContainerView.swift +40 -0
- package/native/nitro-ui-glass/macos/HybridNativeLiquidGlassView.swift +80 -0
- package/native/nitro-ui-glass/macos/LiquidGlassEffectView.swift +181 -0
- package/native/nitro-ui-glass/macos/LiquidGlassSupport.swift +17 -0
- package/native/nitro-ui-navigation/Package.swift +105 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/HybridNavigationScreen.swift +199 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/HybridNavigationSharedElement.swift +17 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/HybridNavigationSplit.swift +889 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/HybridNavigationStack.swift +404 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/HybridNavigationTabs.swift +186 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/MacStackContainerController.swift +260 -0
- package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/NavigationSharedElementView.swift +28 -0
- package/native/nitro-ui-renderer/Package.swift +105 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Animations/HybridAnimator.swift +502 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Animations/NitroAnimationContext.swift +54 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Animations/View+Animations.swift +35 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/AssetFonts.swift +36 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/FlippedView.swift +360 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridContainerView.swift +28 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridFonts.swift +7 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridLabel.swift +127 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridMaskedView.swift +185 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridScrollView.swift +255 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridScrollViewContent.swift +22 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/HybridView.swift +18 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/Image/HybridImage.swift +281 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/Image/HybridImageFactory.swift +132 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/Image/HybridImageLoader.swift +149 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/Image/HybridImageView.swift +601 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/Image/ImagePixelSupport.swift +418 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/LabelView.swift +198 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/HybridListView.swift +177 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListCell.swift +98 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListContentView.swift +12 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListFenwickTree.swift +94 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListScrollView.swift +1100 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListSnapshot.swift +24 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListUpdate.swift +11 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/List/NativeListView.swift +260 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/NativeContainerView.swift +443 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/NitroViewProtocols.swift +275 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/ShadowLayers.swift +338 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/TextInput/HybridTextInput.swift +252 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/TextInput/NitroTextInputView.swift +447 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Components/View.swift +660 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/CustomViewController.swift +254 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/DesktopHostDelegate.swift +14 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Extensions.swift +102 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Gestures/GestureRecognizerDelegate.swift +24 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Gestures/HybridGestureRecognizer.swift +41 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Gestures/HybridLongPressGestureRecognizer.swift +172 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Gestures/HybridPanGestureRecognizer.swift +193 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Gestures/HybridTapGestureRecognizer.swift +165 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridAppearance.swift +75 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridApplication.swift +29 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridKeyboard.swift +26 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridScreen.swift +29 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridViewController.swift +232 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridWindow.swift +61 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/HybridWindowScene.swift +17 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/LayoutNode.swift +73 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/NSColor+rgba.swift +29 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/RegisterRootCallback.swift +27 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/RuntimeReloadableAppDelegate.swift +7 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/SafeAreaInsetsListeners.swift +26 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/SizeListeners.swift +27 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/UIErrorHandler.swift +15 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/ViewController.swift +6 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/Window.swift +156 -0
- package/native/nitro-ui-renderer/Sources/NitroUIRendererMac/WindowScene.swift +23 -0
- package/native/nitro-ui-runtime/Package.swift +67 -0
- package/native/nitro-ui-runtime/Sources/NitroUIRuntimeMac/DevLoader.swift +16 -0
- package/native/nitro-ui-runtime/Sources/NitroUIRuntimeMac/NitroUIAppDelegate.swift +253 -0
- package/package.json +59 -4
- package/src/Platform.ts +43 -0
- package/src/bin.js +18 -0
- package/src/build.ts +453 -0
- package/src/bundleWorker.ts +80 -0
- package/src/cli.ts +157 -0
- package/src/config.ts +233 -0
- package/src/create.ts +67 -0
- package/src/files.ts +70 -0
- package/src/index.ts +1 -0
- package/src/init.ts +301 -0
- package/src/inlinePlatform.ts +140 -0
- package/src/modules.ts +385 -0
- package/src/packageApp.ts +103 -0
- package/src/packageDirectory.ts +61 -0
- package/src/preload.ts +40 -0
- package/src/prepare.ts +433 -0
- package/src/run.ts +41 -0
- package/src/runApp.ts +81 -0
- package/src/start.ts +152 -0
- package/src/toolchain.ts +83 -0
- package/src/versions.ts +103 -0
- package/templates/AppIcon.icns +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// swift-tools-version: 6.4
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
let name = "NitroGlass"
|
|
7
|
+
let generated = "nitrogen/generated"
|
|
8
|
+
let nitroDependencies: [Target.Dependency] = [
|
|
9
|
+
.product(name: "NitroModules", package: "nitro-core"),
|
|
10
|
+
.product(name: "NitroUIRenderer", package: "nitro-ui-renderer"),
|
|
11
|
+
]
|
|
12
|
+
let cxxSettings: [CXXSetting] = [
|
|
13
|
+
.define("DEBUG", .when(configuration: .debug)),
|
|
14
|
+
.define("NDEBUG", .when(configuration: .release)),
|
|
15
|
+
.disableWarning("nullability-extension"),
|
|
16
|
+
]
|
|
17
|
+
let swiftSources = [
|
|
18
|
+
"macos",
|
|
19
|
+
"\(generated)/apple/swift",
|
|
20
|
+
]
|
|
21
|
+
let bridgeSources = ["c++", "NitroGlass-Swift-Cxx-Bridge.cpp", "NitroGlassAutolinking.cpp"]
|
|
22
|
+
|
|
23
|
+
let package = Package(
|
|
24
|
+
name: name,
|
|
25
|
+
platforms: [.macOS(.v13)],
|
|
26
|
+
products: [
|
|
27
|
+
.library(name: name, targets: ["\(name)Cxx", name, "\(name)SwiftBridge"])
|
|
28
|
+
],
|
|
29
|
+
dependencies: [
|
|
30
|
+
.package(path: "../nitro-core"),
|
|
31
|
+
.package(path: "../nitro-ui-renderer"),
|
|
32
|
+
],
|
|
33
|
+
targets: [
|
|
34
|
+
.target(
|
|
35
|
+
name: "\(name)Cxx",
|
|
36
|
+
dependencies: nitroDependencies,
|
|
37
|
+
path: "\(generated)/shared/c++",
|
|
38
|
+
exclude: ["include"],
|
|
39
|
+
publicHeadersPath: "include",
|
|
40
|
+
cxxSettings: cxxSettings
|
|
41
|
+
),
|
|
42
|
+
.target(
|
|
43
|
+
name: "\(name)AppleCxx",
|
|
44
|
+
dependencies: [.target(name: "\(name)Cxx")] + nitroDependencies,
|
|
45
|
+
path: "\(generated)/apple/\(name)AppleCxx",
|
|
46
|
+
cxxSettings: cxxSettings
|
|
47
|
+
),
|
|
48
|
+
.target(
|
|
49
|
+
name: name,
|
|
50
|
+
dependencies: [.target(name: "\(name)AppleCxx")] + nitroDependencies,
|
|
51
|
+
path: ".",
|
|
52
|
+
exclude: excludes(in: ".", keeping: swiftSources),
|
|
53
|
+
sources: swiftSources,
|
|
54
|
+
cxxSettings: cxxSettings,
|
|
55
|
+
swiftSettings: [
|
|
56
|
+
.swiftLanguageMode(.v5),
|
|
57
|
+
.unsafeFlags(["-strict-concurrency=minimal"]),
|
|
58
|
+
.enableUpcomingFeature("InternalImportsByDefault"),
|
|
59
|
+
.enableUpcomingFeature("MemberImportVisibility"),
|
|
60
|
+
.interoperabilityMode(.Cxx),
|
|
61
|
+
.unsafeFlags(["-Xfrontend", "-clang-header-expose-decls=has-expose-attr-or-stdlib"]),
|
|
62
|
+
.unsafeFlags([
|
|
63
|
+
"-Xfrontend", "-clang-header-expose-module",
|
|
64
|
+
"-Xfrontend", "NitroModules=NitroModules-Swift.h",
|
|
65
|
+
]),
|
|
66
|
+
]
|
|
67
|
+
),
|
|
68
|
+
.target(
|
|
69
|
+
name: "\(name)SwiftBridge",
|
|
70
|
+
dependencies: [.target(name: name), .target(name: "\(name)AppleCxx")] + nitroDependencies,
|
|
71
|
+
path: "\(generated)/apple",
|
|
72
|
+
exclude: excludes(in: "\(generated)/apple", keeping: bridgeSources) + ["c++/include"],
|
|
73
|
+
sources: bridgeSources,
|
|
74
|
+
publicHeadersPath: "c++/include",
|
|
75
|
+
cxxSettings: cxxSettings + [
|
|
76
|
+
.unsafeFlags(["-I${GENERATED_MODULEMAP_DIR}", "-fno-modules"])
|
|
77
|
+
]
|
|
78
|
+
),
|
|
79
|
+
],
|
|
80
|
+
cxxLanguageStandard: .cxx20
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
func excludes(in path: String, keeping sources: [String]) -> [String] {
|
|
84
|
+
var parents: Set<String> = [""]
|
|
85
|
+
for source in sources {
|
|
86
|
+
var components = source.split(separator: "/").dropLast()
|
|
87
|
+
while !components.isEmpty {
|
|
88
|
+
parents.insert(components.joined(separator: "/"))
|
|
89
|
+
components = components.dropLast()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let root = URL(fileURLWithPath: Context.packageDirectory).appendingPathComponent(path)
|
|
93
|
+
return parents.sorted().flatMap { parent in
|
|
94
|
+
let entries =
|
|
95
|
+
(try? FileManager.default.contentsOfDirectory(
|
|
96
|
+
atPath: root.appendingPathComponent(parent).path)) ?? []
|
|
97
|
+
return entries.sorted().compactMap { entry in
|
|
98
|
+
let entryPath = parent.isEmpty ? entry : "\(parent)/\(entry)"
|
|
99
|
+
return entry.hasPrefix(".") || sources.contains(entryPath) || parents.contains(entryPath)
|
|
100
|
+
? nil : entryPath
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
internal import AppKit
|
|
2
|
+
internal import NitroModules
|
|
3
|
+
internal import NitroUIRenderer
|
|
4
|
+
|
|
5
|
+
final class HybridNativeLiquidGlassContainerView: HybridNativeLiquidGlassContainerViewSpec {
|
|
6
|
+
typealias AllowedChildrenType = any View
|
|
7
|
+
|
|
8
|
+
let view = LiquidGlassContainerHostView(frame: .zero)
|
|
9
|
+
let layoutNode = LayoutNode()
|
|
10
|
+
var parentReference: (any HybridViewSpec)?
|
|
11
|
+
var gestureRecognizers: [any HybridGestureRecognizerSpec] = []
|
|
12
|
+
|
|
13
|
+
var spacing: Double = 0 {
|
|
14
|
+
didSet { view.spacing = CGFloat(spacing) }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override init() throws {
|
|
18
|
+
try super.init()
|
|
19
|
+
view.updateEffect()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Descendant NSGlassEffectViews merge when placed inside NSGlassEffectContainerView.contentView.
|
|
23
|
+
func appendChild(child: any HybridViewSpec) throws {
|
|
24
|
+
view.contentHost.addSubview(child.view)
|
|
25
|
+
child.parentReference = self
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
func insertBefore(child: any HybridViewSpec, beforeChild: any HybridViewSpec) throws {
|
|
29
|
+
if child === beforeChild {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
view.contentHost.addSubview(child.view, positioned: .below, relativeTo: beforeChild.view)
|
|
33
|
+
child.parentReference = self
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
func removeChild(child: any HybridViewSpec) throws {
|
|
37
|
+
child.view.removeFromSuperview()
|
|
38
|
+
child.parentReference = nil
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
internal import AppKit
|
|
2
|
+
internal import NitroModules
|
|
3
|
+
internal import NitroUIRenderer
|
|
4
|
+
|
|
5
|
+
final class HybridNativeLiquidGlassView: HybridNativeLiquidGlassViewSpec {
|
|
6
|
+
typealias AllowedChildrenType = any View
|
|
7
|
+
|
|
8
|
+
let view = LiquidGlassHostView(frame: .zero)
|
|
9
|
+
let layoutNode = LayoutNode()
|
|
10
|
+
var parentReference: (any HybridViewSpec)?
|
|
11
|
+
var gestureRecognizers: [any HybridGestureRecognizerSpec] = []
|
|
12
|
+
|
|
13
|
+
override init() throws {
|
|
14
|
+
try super.init()
|
|
15
|
+
view.updateEffect()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var effect: LiquidGlassEffect = .regular {
|
|
19
|
+
didSet {
|
|
20
|
+
view.glassEffect = effect
|
|
21
|
+
view.updateEffect()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var interactive = false {
|
|
26
|
+
didSet {
|
|
27
|
+
view.isInteractive = interactive
|
|
28
|
+
view.updateEffect()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var tintColor: Double? {
|
|
33
|
+
didSet {
|
|
34
|
+
view.glassTintColor = tintColor.map { NSColor(rgba: UInt32($0)) }
|
|
35
|
+
view.updateEffect()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var colorScheme: LiquidGlassColorScheme = .system {
|
|
40
|
+
didSet {
|
|
41
|
+
view.applyColorScheme(colorScheme)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var animated = true {
|
|
46
|
+
didSet { view.animatesChanges = animated }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var animationDuration: Double? {
|
|
50
|
+
didSet { view.animationDuration = animationDuration }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var cornerRadius: Double {
|
|
54
|
+
get { Double(view.glassCornerRadius) }
|
|
55
|
+
set {
|
|
56
|
+
view.glassCornerRadius = CGFloat(newValue)
|
|
57
|
+
view.layer?.cornerRadius = CGFloat(newValue)
|
|
58
|
+
view.updateEffect()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Embed children inside the flipped contentHost managed by NSGlassEffectView.contentView.
|
|
63
|
+
func appendChild(child: any HybridViewSpec) throws {
|
|
64
|
+
view.contentHost.addSubview(child.view)
|
|
65
|
+
child.parentReference = self
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
func insertBefore(child: any HybridViewSpec, beforeChild: any HybridViewSpec) throws {
|
|
69
|
+
if child === beforeChild {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
view.contentHost.addSubview(child.view, positioned: .below, relativeTo: beforeChild.view)
|
|
73
|
+
child.parentReference = self
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
func removeChild(child: any HybridViewSpec) throws {
|
|
77
|
+
child.view.removeFromSuperview()
|
|
78
|
+
child.parentReference = nil
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
internal import AppKit
|
|
2
|
+
internal import NitroUIRenderer
|
|
3
|
+
internal import QuartzCore
|
|
4
|
+
|
|
5
|
+
final class LiquidGlassHostView: FlippedView {
|
|
6
|
+
let contentHost = FlippedView(frame: .zero)
|
|
7
|
+
private var glassViewStorage: NSView?
|
|
8
|
+
|
|
9
|
+
var glassEffect: LiquidGlassEffect = .regular
|
|
10
|
+
var isInteractive = false
|
|
11
|
+
var glassTintColor: NSColor?
|
|
12
|
+
var glassCornerRadius: CGFloat = 0
|
|
13
|
+
var animatesChanges = true
|
|
14
|
+
var animationDuration: TimeInterval?
|
|
15
|
+
|
|
16
|
+
override init(frame frameRect: NSRect) {
|
|
17
|
+
super.init(frame: frameRect)
|
|
18
|
+
contentHost.autoresizingMask = [.width, .height]
|
|
19
|
+
contentHost.frame = bounds
|
|
20
|
+
addSubview(contentHost)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override func setFrameSize(_ newSize: NSSize) {
|
|
24
|
+
super.setFrameSize(newSize)
|
|
25
|
+
syncChildFrames()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override func layout() {
|
|
29
|
+
super.layout()
|
|
30
|
+
syncChildFrames()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private func syncChildFrames() {
|
|
34
|
+
if let glassView = glassViewStorage {
|
|
35
|
+
if glassView.frame != bounds {
|
|
36
|
+
glassView.frame = bounds
|
|
37
|
+
}
|
|
38
|
+
if contentHost.frame != glassView.bounds {
|
|
39
|
+
contentHost.frame = glassView.bounds
|
|
40
|
+
}
|
|
41
|
+
} else if contentHost.frame != bounds {
|
|
42
|
+
contentHost.frame = bounds
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func updateEffect() {
|
|
47
|
+
let reduceMotion = NSWorkspace.shared.accessibilityDisplayShouldReduceMotion
|
|
48
|
+
let shouldAnimate = animatesChanges && !reduceMotion
|
|
49
|
+
|
|
50
|
+
if LiquidGlassSupport.isSupported, glassEffect != .none, #available(macOS 26.0, *) {
|
|
51
|
+
let glassView: NSGlassEffectView
|
|
52
|
+
let newlyCreated: Bool
|
|
53
|
+
if let existing = glassViewStorage as? NSGlassEffectView {
|
|
54
|
+
glassView = existing
|
|
55
|
+
newlyCreated = false
|
|
56
|
+
} else {
|
|
57
|
+
let created = NSGlassEffectView(frame: bounds)
|
|
58
|
+
created.autoresizingMask = [.width, .height]
|
|
59
|
+
glassViewStorage = created
|
|
60
|
+
glassView = created
|
|
61
|
+
newlyCreated = true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if glassView.superview !== self {
|
|
65
|
+
addSubview(glassView)
|
|
66
|
+
}
|
|
67
|
+
glassView.frame = bounds
|
|
68
|
+
|
|
69
|
+
if glassView.contentView !== contentHost {
|
|
70
|
+
contentHost.removeFromSuperview()
|
|
71
|
+
contentHost.frame = glassView.bounds
|
|
72
|
+
glassView.contentView = contentHost
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let style: NSGlassEffectView.Style = glassEffect == .clear ? .clear : .regular
|
|
76
|
+
let applyProperties = {
|
|
77
|
+
glassView.style = style
|
|
78
|
+
glassView.tintColor = self.glassTintColor
|
|
79
|
+
glassView.cornerRadius = self.glassCornerRadius
|
|
80
|
+
if #available(macOS 27.0, *) {
|
|
81
|
+
glassView.effectIsInteractive = self.isInteractive
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if shouldAnimate && !newlyCreated {
|
|
86
|
+
NSAnimationContext.runAnimationGroup { context in
|
|
87
|
+
context.duration = animationDuration ?? 0.25
|
|
88
|
+
context.allowsImplicitAnimation = true
|
|
89
|
+
applyProperties()
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
applyProperties()
|
|
93
|
+
}
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Fallback plain view on macOS < 26, compatibility mode, or `effect === 'none'`.
|
|
98
|
+
if #available(macOS 26.0, *), let glassView = glassViewStorage as? NSGlassEffectView {
|
|
99
|
+
if glassView.contentView === contentHost {
|
|
100
|
+
glassView.contentView = nil
|
|
101
|
+
}
|
|
102
|
+
glassView.removeFromSuperview()
|
|
103
|
+
glassViewStorage = nil
|
|
104
|
+
}
|
|
105
|
+
if contentHost.superview !== self {
|
|
106
|
+
contentHost.removeFromSuperview()
|
|
107
|
+
contentHost.frame = bounds
|
|
108
|
+
addSubview(contentHost)
|
|
109
|
+
}
|
|
110
|
+
layer?.cornerRadius = glassCornerRadius
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
func applyColorScheme(_ scheme: LiquidGlassColorScheme) {
|
|
114
|
+
switch scheme {
|
|
115
|
+
case .light:
|
|
116
|
+
appearance = NSAppearance(named: .aqua)
|
|
117
|
+
case .dark:
|
|
118
|
+
appearance = NSAppearance(named: .darkAqua)
|
|
119
|
+
case .system:
|
|
120
|
+
appearance = nil
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
final class LiquidGlassContainerHostView: FlippedView {
|
|
126
|
+
let contentHost = FlippedView(frame: .zero)
|
|
127
|
+
private var containerStorage: NSView?
|
|
128
|
+
|
|
129
|
+
var spacing: CGFloat = 0 {
|
|
130
|
+
didSet {
|
|
131
|
+
updateEffect()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
override init(frame frameRect: NSRect) {
|
|
136
|
+
super.init(frame: frameRect)
|
|
137
|
+
contentHost.autoresizingMask = [.width, .height]
|
|
138
|
+
contentHost.frame = bounds
|
|
139
|
+
if LiquidGlassSupport.isSupported, #available(macOS 26.0, *) {
|
|
140
|
+
let container = NSGlassEffectContainerView(frame: bounds)
|
|
141
|
+
container.autoresizingMask = [.width, .height]
|
|
142
|
+
container.contentView = contentHost
|
|
143
|
+
addSubview(container)
|
|
144
|
+
containerStorage = container
|
|
145
|
+
} else {
|
|
146
|
+
addSubview(contentHost)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
override func setFrameSize(_ newSize: NSSize) {
|
|
151
|
+
super.setFrameSize(newSize)
|
|
152
|
+
syncChildFrames()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
override func layout() {
|
|
156
|
+
super.layout()
|
|
157
|
+
syncChildFrames()
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private func syncChildFrames() {
|
|
161
|
+
if let container = containerStorage {
|
|
162
|
+
if container.frame != bounds {
|
|
163
|
+
container.frame = bounds
|
|
164
|
+
}
|
|
165
|
+
if contentHost.frame != container.bounds {
|
|
166
|
+
contentHost.frame = container.bounds
|
|
167
|
+
}
|
|
168
|
+
} else if contentHost.frame != bounds {
|
|
169
|
+
contentHost.frame = bounds
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
func updateEffect() {
|
|
174
|
+
guard LiquidGlassSupport.isSupported, #available(macOS 26.0, *) else {
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
if let container = containerStorage as? NSGlassEffectContainerView {
|
|
178
|
+
container.spacing = spacing
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
internal import AppKit
|
|
2
|
+
|
|
3
|
+
enum LiquidGlassSupport {
|
|
4
|
+
static let isSupported: Bool = {
|
|
5
|
+
guard #available(macOS 26.0, *) else {
|
|
6
|
+
return false
|
|
7
|
+
}
|
|
8
|
+
// NitroUI apps build with the macOS 27 SDK, so macOS 27 ignores UIDesignRequiresCompatibility.
|
|
9
|
+
if #available(macOS 27.0, *) {
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
// An absent key means the app uses the new design.
|
|
13
|
+
let requiresCompatibility =
|
|
14
|
+
Bundle.main.object(forInfoDictionaryKey: "UIDesignRequiresCompatibility") as? Bool ?? false
|
|
15
|
+
return !requiresCompatibility
|
|
16
|
+
}()
|
|
17
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// swift-tools-version: 6.4
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
let name = "NitroUINavigation"
|
|
7
|
+
let generated = "nitrogen/generated"
|
|
8
|
+
let nitroDependencies: [Target.Dependency] = [
|
|
9
|
+
.product(name: "NitroModules", package: "nitro-core"),
|
|
10
|
+
.product(name: "NitroUIRenderer", package: "nitro-ui-renderer"),
|
|
11
|
+
]
|
|
12
|
+
let cxxSettings: [CXXSetting] = [
|
|
13
|
+
.define("DEBUG", .when(configuration: .debug)),
|
|
14
|
+
.define("NDEBUG", .when(configuration: .release)),
|
|
15
|
+
.disableWarning("nullability-extension"),
|
|
16
|
+
]
|
|
17
|
+
let swiftSources = [
|
|
18
|
+
"Sources/NitroUINavigationMac",
|
|
19
|
+
"\(generated)/apple/swift",
|
|
20
|
+
]
|
|
21
|
+
let bridgeSources = [
|
|
22
|
+
"c++", "NitroUINavigation-Swift-Cxx-Bridge.cpp", "NitroUINavigationAutolinking.cpp",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
let package = Package(
|
|
26
|
+
name: name,
|
|
27
|
+
platforms: [.macOS(.v13)],
|
|
28
|
+
products: [
|
|
29
|
+
.library(name: name, targets: ["\(name)Cxx", name, "\(name)SwiftBridge"])
|
|
30
|
+
],
|
|
31
|
+
dependencies: [
|
|
32
|
+
.package(path: "../nitro-core"),
|
|
33
|
+
.package(path: "../nitro-ui-renderer"),
|
|
34
|
+
],
|
|
35
|
+
targets: [
|
|
36
|
+
.target(
|
|
37
|
+
name: "\(name)Cxx",
|
|
38
|
+
dependencies: nitroDependencies,
|
|
39
|
+
path: "\(generated)/shared/c++",
|
|
40
|
+
exclude: ["include"],
|
|
41
|
+
publicHeadersPath: "include",
|
|
42
|
+
cxxSettings: cxxSettings
|
|
43
|
+
),
|
|
44
|
+
.target(
|
|
45
|
+
name: "\(name)AppleCxx",
|
|
46
|
+
dependencies: [.target(name: "\(name)Cxx")] + nitroDependencies,
|
|
47
|
+
path: "\(generated)/apple/\(name)AppleCxx",
|
|
48
|
+
cxxSettings: cxxSettings
|
|
49
|
+
),
|
|
50
|
+
.target(
|
|
51
|
+
name: name,
|
|
52
|
+
dependencies: [.target(name: "\(name)AppleCxx")] + nitroDependencies,
|
|
53
|
+
path: ".",
|
|
54
|
+
exclude: excludes(in: ".", keeping: swiftSources),
|
|
55
|
+
sources: swiftSources,
|
|
56
|
+
cxxSettings: cxxSettings,
|
|
57
|
+
swiftSettings: [
|
|
58
|
+
.swiftLanguageMode(.v5),
|
|
59
|
+
.unsafeFlags(["-strict-concurrency=minimal"]),
|
|
60
|
+
.enableUpcomingFeature("InternalImportsByDefault"),
|
|
61
|
+
.enableUpcomingFeature("MemberImportVisibility"),
|
|
62
|
+
.interoperabilityMode(.Cxx),
|
|
63
|
+
.unsafeFlags(["-Xfrontend", "-clang-header-expose-decls=has-expose-attr-or-stdlib"]),
|
|
64
|
+
.unsafeFlags([
|
|
65
|
+
"-Xfrontend", "-clang-header-expose-module",
|
|
66
|
+
"-Xfrontend", "NitroModules=NitroModules-Swift.h",
|
|
67
|
+
]),
|
|
68
|
+
]
|
|
69
|
+
),
|
|
70
|
+
.target(
|
|
71
|
+
name: "\(name)SwiftBridge",
|
|
72
|
+
dependencies: [.target(name: name), .target(name: "\(name)AppleCxx")] + nitroDependencies,
|
|
73
|
+
path: "\(generated)/apple",
|
|
74
|
+
exclude: excludes(in: "\(generated)/apple", keeping: bridgeSources) + ["c++/include"],
|
|
75
|
+
sources: bridgeSources,
|
|
76
|
+
publicHeadersPath: "c++/include",
|
|
77
|
+
cxxSettings: cxxSettings + [
|
|
78
|
+
.unsafeFlags(["-I${GENERATED_MODULEMAP_DIR}", "-fno-modules"])
|
|
79
|
+
]
|
|
80
|
+
),
|
|
81
|
+
],
|
|
82
|
+
cxxLanguageStandard: .cxx20
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
func excludes(in path: String, keeping sources: [String]) -> [String] {
|
|
86
|
+
var parents: Set<String> = [""]
|
|
87
|
+
for source in sources {
|
|
88
|
+
var components = source.split(separator: "/").dropLast()
|
|
89
|
+
while !components.isEmpty {
|
|
90
|
+
parents.insert(components.joined(separator: "/"))
|
|
91
|
+
components = components.dropLast()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
let root = URL(fileURLWithPath: Context.packageDirectory).appendingPathComponent(path)
|
|
95
|
+
return parents.sorted().flatMap { parent in
|
|
96
|
+
let entries =
|
|
97
|
+
(try? FileManager.default.contentsOfDirectory(
|
|
98
|
+
atPath: root.appendingPathComponent(parent).path)) ?? []
|
|
99
|
+
return entries.sorted().compactMap { entry in
|
|
100
|
+
let entryPath = parent.isEmpty ? entry : "\(parent)/\(entry)"
|
|
101
|
+
return entry.hasPrefix(".") || sources.contains(entryPath) || parents.contains(entryPath)
|
|
102
|
+
? nil : entryPath
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|