nitro-ui-macos 0.0.0 → 0.0.2
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 +49 -0
- package/LICENSE +4 -3
- package/PARITY.md +373 -0
- package/README.md +144 -5
- 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 -8
- 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
package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/MacStackContainerController.swift
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
internal import AppKit
|
|
2
|
+
internal import Foundation
|
|
3
|
+
internal import QuartzCore
|
|
4
|
+
|
|
5
|
+
/// Lightweight AppKit view-controller stack used by `NavigationStack` and each column of `NavigationSplit`.
|
|
6
|
+
final class MacStackContainerController: NSViewController {
|
|
7
|
+
private(set) var viewControllers: [NSViewController] = []
|
|
8
|
+
var onPopRequested: ((Int) -> Void)?
|
|
9
|
+
var onTopViewControllerChanged: ((NSViewController?) -> Void)?
|
|
10
|
+
var sharedElementIdForController: ((NSViewController) -> String?)?
|
|
11
|
+
|
|
12
|
+
var topViewController: NSViewController? {
|
|
13
|
+
viewControllers.last
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override func loadView() {
|
|
17
|
+
let container = StackContainerView()
|
|
18
|
+
container.onBackShortcut = { [weak self] in
|
|
19
|
+
self?.requestPopOne() ?? false
|
|
20
|
+
}
|
|
21
|
+
self.view = container
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override func viewDidLoad() {
|
|
25
|
+
super.viewDidLoad()
|
|
26
|
+
syncTopView()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override func viewDidLayout() {
|
|
30
|
+
super.viewDidLayout()
|
|
31
|
+
if let top = viewControllers.last, top.view.superview === view {
|
|
32
|
+
top.view.frame = view.bounds
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
func setViewControllers(_ next: [NSViewController], animated: Bool) {
|
|
37
|
+
if viewControllers.count == next.count,
|
|
38
|
+
zip(viewControllers, next).allSatisfy({ $0 === $1 }) {
|
|
39
|
+
syncTopView()
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let previousTop = viewControllers.last
|
|
44
|
+
let nextTop = next.last
|
|
45
|
+
let isPop = next.count < viewControllers.count
|
|
46
|
+
let transitionCapture = animated
|
|
47
|
+
? captureSharedElementSource(from: previousTop, to: nextTop, isPop: isPop)
|
|
48
|
+
: nil
|
|
49
|
+
|
|
50
|
+
for existing in viewControllers where !next.contains(where: { $0 === existing }) {
|
|
51
|
+
existing.view.removeFromSuperview()
|
|
52
|
+
existing.removeFromParent()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for controller in next where controller.parent !== self {
|
|
56
|
+
if controller.parent != nil {
|
|
57
|
+
controller.view.removeFromSuperview()
|
|
58
|
+
controller.removeFromParent()
|
|
59
|
+
}
|
|
60
|
+
addChild(controller)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
viewControllers = next
|
|
64
|
+
syncTopView()
|
|
65
|
+
|
|
66
|
+
if let transitionCapture, let nextTop {
|
|
67
|
+
runSharedElementTransition(transitionCapture, to: nextTop)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if previousTop !== viewControllers.last {
|
|
71
|
+
onTopViewControllerChanged?(viewControllers.last)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@discardableResult
|
|
76
|
+
func requestPopOne() -> Bool {
|
|
77
|
+
guard viewControllers.count > 1 else { return false }
|
|
78
|
+
let removed = viewControllers.removeLast()
|
|
79
|
+
let nextTop = viewControllers.last
|
|
80
|
+
let transitionCapture = view.window != nil
|
|
81
|
+
? captureSharedElementSource(from: removed, to: nextTop, isPop: true)
|
|
82
|
+
: nil
|
|
83
|
+
removed.view.removeFromSuperview()
|
|
84
|
+
removed.removeFromParent()
|
|
85
|
+
syncTopView()
|
|
86
|
+
if let transitionCapture, let nextTop {
|
|
87
|
+
runSharedElementTransition(transitionCapture, to: nextTop)
|
|
88
|
+
}
|
|
89
|
+
onTopViewControllerChanged?(viewControllers.last)
|
|
90
|
+
onPopRequested?(1)
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private struct SharedElementTransitionCapture {
|
|
95
|
+
let elementId: String
|
|
96
|
+
let snapshot: NSImage
|
|
97
|
+
let startFrame: NSRect
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private func captureSharedElementSource(
|
|
101
|
+
from outgoing: NSViewController?,
|
|
102
|
+
to incoming: NSViewController?,
|
|
103
|
+
isPop: Bool
|
|
104
|
+
) -> SharedElementTransitionCapture? {
|
|
105
|
+
guard isViewLoaded, let outgoing, let incoming else { return nil }
|
|
106
|
+
let elementId = isPop
|
|
107
|
+
? sharedElementIdForController?(outgoing)
|
|
108
|
+
: sharedElementIdForController?(incoming)
|
|
109
|
+
guard let elementId, elementId.isEmpty == false else { return nil }
|
|
110
|
+
guard outgoing.isViewLoaded,
|
|
111
|
+
let sourceView = NavigationSharedElementView.findElement(in: outgoing.view, id: elementId) else {
|
|
112
|
+
return nil
|
|
113
|
+
}
|
|
114
|
+
let bounds = sourceView.bounds
|
|
115
|
+
guard bounds.width > 0.5, bounds.height > 0.5,
|
|
116
|
+
let rep = sourceView.bitmapImageRepForCachingDisplay(in: bounds) else {
|
|
117
|
+
return nil
|
|
118
|
+
}
|
|
119
|
+
sourceView.cacheDisplay(in: bounds, to: rep)
|
|
120
|
+
let snapshot = NSImage(size: bounds.size)
|
|
121
|
+
snapshot.addRepresentation(rep)
|
|
122
|
+
let startFrame = sourceView.convert(bounds, to: view)
|
|
123
|
+
return SharedElementTransitionCapture(elementId: elementId, snapshot: snapshot, startFrame: startFrame)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private func runSharedElementTransition(
|
|
127
|
+
_ capture: SharedElementTransitionCapture,
|
|
128
|
+
to incoming: NSViewController,
|
|
129
|
+
existingOverlay: NSImageView? = nil,
|
|
130
|
+
attemptsRemaining: Int = 12
|
|
131
|
+
) {
|
|
132
|
+
guard isViewLoaded, incoming.isViewLoaded, topViewController === incoming else {
|
|
133
|
+
existingOverlay?.removeFromSuperview()
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
view.layoutSubtreeIfNeeded()
|
|
137
|
+
incoming.view.layoutSubtreeIfNeeded()
|
|
138
|
+
|
|
139
|
+
let overlay: NSImageView
|
|
140
|
+
if let existingOverlay {
|
|
141
|
+
overlay = existingOverlay
|
|
142
|
+
} else {
|
|
143
|
+
let created = NSImageView(frame: capture.startFrame)
|
|
144
|
+
created.identifier = NSUserInterfaceItemIdentifier("NitroSharedElementOverlay")
|
|
145
|
+
created.image = capture.snapshot
|
|
146
|
+
created.imageScaling = .scaleAxesIndependently
|
|
147
|
+
created.wantsLayer = true
|
|
148
|
+
created.layer?.zPosition = 9_999
|
|
149
|
+
view.addSubview(created)
|
|
150
|
+
overlay = created
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
guard let destinationView = NavigationSharedElementView.findElement(in: incoming.view, id: capture.elementId) else {
|
|
154
|
+
if attemptsRemaining > 0 {
|
|
155
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.008) { [weak self, weak incoming, weak overlay] in
|
|
156
|
+
guard let self, let incoming else {
|
|
157
|
+
overlay?.removeFromSuperview()
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
self.runSharedElementTransition(
|
|
161
|
+
capture,
|
|
162
|
+
to: incoming,
|
|
163
|
+
existingOverlay: overlay,
|
|
164
|
+
attemptsRemaining: attemptsRemaining - 1
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
overlay.removeFromSuperview()
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
let endFrame = destinationView.convert(destinationView.bounds, to: view)
|
|
173
|
+
guard endFrame.width > 0.5, endFrame.height > 0.5 else {
|
|
174
|
+
if attemptsRemaining > 0 {
|
|
175
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.008) { [weak self, weak incoming, weak overlay] in
|
|
176
|
+
guard let self, let incoming else {
|
|
177
|
+
overlay?.removeFromSuperview()
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
self.runSharedElementTransition(
|
|
181
|
+
capture,
|
|
182
|
+
to: incoming,
|
|
183
|
+
existingOverlay: overlay,
|
|
184
|
+
attemptsRemaining: attemptsRemaining - 1
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
overlay.removeFromSuperview()
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
destinationView.alphaValue = 0
|
|
194
|
+
NSAnimationContext.runAnimationGroup({ context in
|
|
195
|
+
context.duration = 0.24
|
|
196
|
+
context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
|
|
197
|
+
overlay.animator().frame = endFrame
|
|
198
|
+
}, completionHandler: {
|
|
199
|
+
DispatchQueue.main.async {
|
|
200
|
+
destinationView.alphaValue = 1
|
|
201
|
+
overlay.removeFromSuperview()
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
func detachAll() {
|
|
207
|
+
for existing in viewControllers {
|
|
208
|
+
existing.view.removeFromSuperview()
|
|
209
|
+
existing.removeFromParent()
|
|
210
|
+
}
|
|
211
|
+
viewControllers.removeAll()
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private func syncTopView() {
|
|
215
|
+
guard isViewLoaded else { return }
|
|
216
|
+
let top = viewControllers.last
|
|
217
|
+
for controller in viewControllers where controller !== top {
|
|
218
|
+
if controller.isViewLoaded && controller.view.superview === view {
|
|
219
|
+
controller.view.removeFromSuperview()
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if let top {
|
|
223
|
+
let topView = top.view
|
|
224
|
+
if topView.superview !== view {
|
|
225
|
+
topView.removeFromSuperview()
|
|
226
|
+
topView.frame = view.bounds
|
|
227
|
+
topView.autoresizingMask = [.width, .height]
|
|
228
|
+
view.addSubview(topView)
|
|
229
|
+
} else if topView.frame != view.bounds {
|
|
230
|
+
topView.frame = view.bounds
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private final class StackContainerView: NSView {
|
|
237
|
+
var onBackShortcut: (() -> Bool)?
|
|
238
|
+
|
|
239
|
+
override var isFlipped: Bool { true }
|
|
240
|
+
|
|
241
|
+
override func performKeyEquivalent(with event: NSEvent) -> Bool {
|
|
242
|
+
let flags = event.modifierFlags.intersection([.command, .option, .control, .shift])
|
|
243
|
+
if flags == .command, event.charactersIgnoringModifiers == "[" {
|
|
244
|
+
if onBackShortcut?() == true {
|
|
245
|
+
return true
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return super.performKeyEquivalent(with: event)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
override func cancelOperation(_ sender: Any?) {
|
|
252
|
+
if window?.firstResponder is NSText {
|
|
253
|
+
super.cancelOperation(sender)
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
if onBackShortcut?() != true {
|
|
257
|
+
super.cancelOperation(sender)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
package/native/nitro-ui-navigation/Sources/NitroUINavigationMac/NavigationSharedElementView.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
internal import AppKit
|
|
2
|
+
internal import NitroUIRenderer
|
|
3
|
+
|
|
4
|
+
final class NavigationSharedElementView: FlippedView {
|
|
5
|
+
var sharedElementId: String? {
|
|
6
|
+
didSet {
|
|
7
|
+
identifier = sharedElementId.map { NSUserInterfaceItemIdentifier("NitroSharedElement:\($0)") }
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static func findElement(in root: NSView, id: String) -> NSView? {
|
|
12
|
+
if root.isHidden { return nil }
|
|
13
|
+
if let marker = root as? NavigationSharedElementView, marker.sharedElementId == id {
|
|
14
|
+
let children = marker.subviews
|
|
15
|
+
guard children.count == 1, let child = children.first else { return nil }
|
|
16
|
+
guard !child.isHidden, !child.bounds.isEmpty else { return nil }
|
|
17
|
+
return child
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for child in root.subviews {
|
|
21
|
+
if child.nextResponder is NSViewController { continue }
|
|
22
|
+
if let element = findElement(in: child, id: id) {
|
|
23
|
+
return element
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return nil
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// swift-tools-version: 6.4
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
let name = "NitroUIRenderer"
|
|
7
|
+
let generated = "nitrogen/generated"
|
|
8
|
+
let nitroDependencies: [Target.Dependency] = [
|
|
9
|
+
.product(name: "NitroModules", package: "nitro-core"),
|
|
10
|
+
.product(name: "NitroLayout", package: "nitro-ui-layout"),
|
|
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/NitroUIRendererMac",
|
|
19
|
+
"\(generated)/apple/swift",
|
|
20
|
+
]
|
|
21
|
+
let bridgeSources = [
|
|
22
|
+
"c++", "NitroUIRenderer-Swift-Cxx-Bridge.cpp", "NitroUIRendererAutolinking.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-layout"),
|
|
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
|
+
}
|