nitrowind-native 0.0.0-stage → 0.1.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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/Package.swift +104 -0
- package/README.md +39 -2
- package/android/src/main/java/com/margelo/nitro/nitrowind/HybridReducedMotion.kt +79 -0
- package/android/src/main/java/com/margelo/nitro/nitrowind/HybridThemeCover.kt +38 -0
- package/android/src/main/java/com/margelo/nitro/nitrowind/NitroWindCoverLog.kt +36 -0
- package/android/src/main/java/com/margelo/nitro/nitrowind/ThemeCoverActivityInitializer.kt +11 -0
- package/android/src/main/java/com/margelo/nitro/nitrowind/ThemeCoverController.kt +619 -0
- package/ios/HybridReducedMotion.swift +50 -0
- package/ios/HybridThemeCover.swift +46 -0
- package/ios/NitroWindCoverLog.swift +40 -0
- package/ios/ThemeCoverWindow.swift +324 -0
- package/nitro.json +13 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroWindNative+autolinking.cmake +34 -0
- package/nitrogen/generated/android/NitroWindNative+autolinking.gradle +10 -0
- package/nitrogen/generated/android/NitroWindNativeOnLoad.cpp +25 -0
- package/nitrogen/generated/android/c++/JCallback_void.cpp +54 -0
- package/nitrogen/generated/android/c++/JCallback_void_bool.cpp +56 -0
- package/nitrogen/generated/android/c++/JCoverRequest.cpp +42 -0
- package/nitrogen/generated/android/c++/JHybridReducedMotionSpec.cpp +84 -0
- package/nitrogen/generated/android/c++/JHybridThemeCoverSpec.cpp +114 -0
- package/nitrogen/generated/android/c++/JListenerSubscription.cpp +34 -0
- package/nitrogen/generated/android/c++/JThemeTransitionDirection.cpp +52 -0
- package/nitrogen/generated/android/c++/JThemeTransitionStyle.cpp +58 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JCallback_void.hpp +53 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JCallback_void_bool.hpp +55 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JCoverRequest.hpp +73 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JHybridReducedMotionSpec.hpp +90 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JHybridReducedMotionSpecJavaPart.hpp +26 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JHybridThemeCoverSpec.hpp +96 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JHybridThemeCoverSpecJavaPart.hpp +26 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JListenerSubscription.hpp +49 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JThemeTransitionDirection.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroWindNative/private/JThemeTransitionStyle.hpp +82 -0
- package/nitrogen/generated/android/include/NitroWindNative/private/NitroWindNativeOnLoad.hpp +13 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/Callback_void.kt +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/Callback_void_bool.kt +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/CoverRequest.kt +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/HybridReducedMotionSpec.kt +89 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/HybridThemeCoverSpec.kt +107 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/ListenerSubscription.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/NitroWindNativeOnLoad.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/ThemeTransitionDirection.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrowind/ThemeTransitionStyle.kt +52 -0
- package/nitrogen/generated/apple/NitroWindNative-Swift-Cxx-Bridge.cpp +68 -0
- package/nitrogen/generated/apple/NitroWindNativeAppleCxx/NitroWindNativeAppleCxx.cpp +9 -0
- package/nitrogen/generated/apple/NitroWindNativeAppleCxx/include/NitroWindNativeAppleCxx/NitroWindNativeAppleCxx.h +64 -0
- package/nitrogen/generated/apple/NitroWindNativeAutolinking.cpp +22 -0
- package/nitrogen/generated/apple/NitroWindNativeAutolinking.mm +24 -0
- package/nitrogen/generated/apple/c++/CoverRequest-Swift.cpp +36 -0
- package/nitrogen/generated/apple/c++/HybridReducedMotionSpecSwift.cpp +62 -0
- package/nitrogen/generated/apple/c++/HybridReducedMotionSpec_cxx-Swift.cpp +28 -0
- package/nitrogen/generated/apple/c++/HybridThemeCoverSpecSwift.cpp +104 -0
- package/nitrogen/generated/apple/c++/HybridThemeCoverSpec_cxx-Swift.cpp +28 -0
- package/nitrogen/generated/apple/c++/ListenerSubscription-Swift.cpp +37 -0
- package/nitrogen/generated/apple/c++/ThemeTransitionDirection-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/ThemeTransitionStyle-Swift.cpp +52 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/NitroWindNativeAutolinking.hpp +13 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/CoverRequest-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/HybridReducedMotionSpecSwift.hpp +74 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/HybridReducedMotionSpec_cxx-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/HybridThemeCoverSpecSwift.hpp +79 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/HybridThemeCoverSpec_cxx-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/ListenerSubscription-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/NitroWindNative-Swift-Cxx-Umbrella.hpp +41 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/ThemeTransitionDirection-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroWindNative/private/ThemeTransitionStyle-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/module.modulemap +12 -0
- package/nitrogen/generated/apple/swift/Callback_void.swift +60 -0
- package/nitrogen/generated/apple/swift/Callback_void_bool.swift +60 -0
- package/nitrogen/generated/apple/swift/CoverRequest.swift +56 -0
- package/nitrogen/generated/apple/swift/HybridReducedMotionSpec.swift +66 -0
- package/nitrogen/generated/apple/swift/HybridReducedMotionSpec_cxx.swift +164 -0
- package/nitrogen/generated/apple/swift/HybridThemeCoverSpec.swift +70 -0
- package/nitrogen/generated/apple/swift/HybridThemeCoverSpec_cxx.swift +207 -0
- package/nitrogen/generated/apple/swift/ListenerSubscription.swift +29 -0
- package/nitrogen/generated/apple/swift/Promise_bool.swift +100 -0
- package/nitrogen/generated/apple/swift/Promise_void.swift +100 -0
- package/nitrogen/generated/apple/swift/ThemeTransitionDirection.swift +54 -0
- package/nitrogen/generated/apple/swift/ThemeTransitionStyle.swift +64 -0
- package/nitrogen/generated/hybrid-classes.json +33 -0
- package/nitrogen/generated/shared/c++/NitroWindNativeCxxModule.cpp +2 -0
- package/nitrogen/generated/shared/c++/include/NitroWindNative/NitroWindNativeCxxModule.hpp +2 -0
- package/nitrogen/generated/shared/javascript/ReducedMotion.cjs +19 -0
- package/nitrogen/generated/shared/javascript/ReducedMotion.d.cts +9 -0
- package/nitrogen/generated/shared/javascript/ThemeCover.cjs +19 -0
- package/nitrogen/generated/shared/javascript/ThemeCover.d.cts +9 -0
- package/package.json +69 -4
- package/src/index.ts +59 -0
- package/src/specs/ListenerSubscription.ts +3 -0
- package/src/specs/ReducedMotion.nitro.ts +19 -0
- package/src/specs/ThemeCover.nitro.ts +49 -0
- package/src/testing.ts +18 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ListenerSubscription.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public import NitroModules
|
|
9
|
+
internal import NitroWindNativeAppleCxx
|
|
10
|
+
internal import CxxStdlib
|
|
11
|
+
|
|
12
|
+
@_expose(Cxx)
|
|
13
|
+
public struct ListenerSubscription: Sendable {
|
|
14
|
+
public let remove: any Callback<(), Void>
|
|
15
|
+
|
|
16
|
+
public init(remove: any Callback<(), Void>) {
|
|
17
|
+
self.remove = remove
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@_spi(NitroCxx)
|
|
21
|
+
public static func init_cxx(_ remove: UnsafeRawPointer) -> Self {
|
|
22
|
+
return Self(remove: remove.load(as: margelo.nitro.nitrowind.swift_bridge.Callback_void.self))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@_spi(NitroCxx)
|
|
26
|
+
public borrowing func getRemove_cxx(_ __outResult: UnsafeMutableRawPointer) -> Void {
|
|
27
|
+
__outResult.initializeMemory(as: margelo.nitro.nitrowind.swift_bridge.Callback_void.self, repeating: self.remove.toCpp(), count: 1)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Promise_bool.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public import NitroModules
|
|
9
|
+
internal import CxxStdlib
|
|
10
|
+
public import Dispatch
|
|
11
|
+
internal import NitroWindNativeAppleCxx
|
|
12
|
+
|
|
13
|
+
public typealias Promise_bool = margelo.nitro.nitrowind.swift_bridge.Promise_bool
|
|
14
|
+
|
|
15
|
+
extension Promise_bool {
|
|
16
|
+
public typealias T = Bool
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrowind.swift_bridge
|
|
18
|
+
|
|
19
|
+
public func __nitroResolve(result: Bool) {
|
|
20
|
+
resolve(consuming: result)
|
|
21
|
+
}
|
|
22
|
+
public func __nitroReject(error: any Error) {
|
|
23
|
+
reject(consuming: error.toCpp())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public func __nitroAddOnResolvedListener(_ listener: @escaping @Sendable (Bool) -> Void) {
|
|
27
|
+
addOnResolvedListener(.init { (value: Bool) -> Void in
|
|
28
|
+
listener(value)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
public func __nitroAddOnRejectedListener(_ listener: @escaping @Sendable (any Error) -> Void) {
|
|
32
|
+
addOnRejectedListener(.init { (exceptionPtr: std.exception_ptr) -> Void in
|
|
33
|
+
listener(RuntimeError.from(cppError: exceptionPtr))
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
extension Promise<Bool> where Self == Promise_bool {
|
|
39
|
+
public static func pending() -> Self {
|
|
40
|
+
return Promise_bool.__pending()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static func resolved(with result: Bool) -> Self {
|
|
44
|
+
let promise = Promise_bool.pending()
|
|
45
|
+
promise.resolve(result: result)
|
|
46
|
+
return promise
|
|
47
|
+
}
|
|
48
|
+
public static func rejected(with error: any Error) -> Self {
|
|
49
|
+
let promise = Promise_bool.pending()
|
|
50
|
+
promise.reject(error: error)
|
|
51
|
+
return promise
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static func `async`(
|
|
55
|
+
_ priority: TaskPriority? = nil,
|
|
56
|
+
_ run: sending @escaping @isolated(any) () async throws -> sending Bool
|
|
57
|
+
) -> Self {
|
|
58
|
+
let promise = Promise_bool.pending()
|
|
59
|
+
Task(priority: priority) { () async -> Void in
|
|
60
|
+
do {
|
|
61
|
+
promise.resolve(result: try await run())
|
|
62
|
+
} catch {
|
|
63
|
+
promise.reject(error: error)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return promise
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public static func parallel(
|
|
70
|
+
_ queue: DispatchQueue = .global(),
|
|
71
|
+
_ run: @escaping @Sendable () throws -> Bool
|
|
72
|
+
) -> Self {
|
|
73
|
+
let promise = Promise_bool.pending()
|
|
74
|
+
queue.async { () -> Void in
|
|
75
|
+
do {
|
|
76
|
+
promise.resolve(result: try run())
|
|
77
|
+
} catch {
|
|
78
|
+
promise.reject(error: error)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return promise
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
extension Promise<Bool> {
|
|
86
|
+
func toCpp() -> Promise_bool {
|
|
87
|
+
if let self = self as? Promise_bool {
|
|
88
|
+
return self
|
|
89
|
+
} else {
|
|
90
|
+
let promise = Promise_bool.pending()
|
|
91
|
+
self.addOnResolvedListener { (result: Bool) -> Void in
|
|
92
|
+
promise.resolve(result: result)
|
|
93
|
+
}
|
|
94
|
+
self.addOnRejectedListener { (error: any Error) -> Void in
|
|
95
|
+
promise.reject(error: error)
|
|
96
|
+
}
|
|
97
|
+
return promise
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Promise_void.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public import NitroModules
|
|
9
|
+
internal import CxxStdlib
|
|
10
|
+
public import Dispatch
|
|
11
|
+
internal import NitroWindNativeAppleCxx
|
|
12
|
+
|
|
13
|
+
public typealias Promise_void = margelo.nitro.nitrowind.swift_bridge.Promise_void
|
|
14
|
+
|
|
15
|
+
extension Promise_void {
|
|
16
|
+
public typealias T = Void
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrowind.swift_bridge
|
|
18
|
+
|
|
19
|
+
public func __nitroResolve(result: ()) {
|
|
20
|
+
resolve()
|
|
21
|
+
}
|
|
22
|
+
public func __nitroReject(error: any Error) {
|
|
23
|
+
reject(consuming: error.toCpp())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public func __nitroAddOnResolvedListener(_ listener: @escaping @Sendable (()) -> Void) {
|
|
27
|
+
addOnResolvedListener(.init { () -> Void in
|
|
28
|
+
listener(())
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
public func __nitroAddOnRejectedListener(_ listener: @escaping @Sendable (any Error) -> Void) {
|
|
32
|
+
addOnRejectedListener(.init { (exceptionPtr: std.exception_ptr) -> Void in
|
|
33
|
+
listener(RuntimeError.from(cppError: exceptionPtr))
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
extension Promise<Void> where Self == Promise_void {
|
|
39
|
+
public static func pending() -> Self {
|
|
40
|
+
return Promise_void.__pending()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static func resolved() -> Self {
|
|
44
|
+
let promise = Promise_void.pending()
|
|
45
|
+
promise.resolve(result: ())
|
|
46
|
+
return promise
|
|
47
|
+
}
|
|
48
|
+
public static func rejected(with error: any Error) -> Self {
|
|
49
|
+
let promise = Promise_void.pending()
|
|
50
|
+
promise.reject(error: error)
|
|
51
|
+
return promise
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static func `async`(
|
|
55
|
+
_ priority: TaskPriority? = nil,
|
|
56
|
+
_ run: sending @escaping @isolated(any) () async throws -> sending Void
|
|
57
|
+
) -> Self {
|
|
58
|
+
let promise = Promise_void.pending()
|
|
59
|
+
Task(priority: priority) { () async -> Void in
|
|
60
|
+
do {
|
|
61
|
+
promise.resolve(result: try await run())
|
|
62
|
+
} catch {
|
|
63
|
+
promise.reject(error: error)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return promise
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public static func parallel(
|
|
70
|
+
_ queue: DispatchQueue = .global(),
|
|
71
|
+
_ run: @escaping @Sendable () throws -> Void
|
|
72
|
+
) -> Self {
|
|
73
|
+
let promise = Promise_void.pending()
|
|
74
|
+
queue.async { () -> Void in
|
|
75
|
+
do {
|
|
76
|
+
promise.resolve(result: try run())
|
|
77
|
+
} catch {
|
|
78
|
+
promise.reject(error: error)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return promise
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
extension Promise<Void> {
|
|
86
|
+
func toCpp() -> Promise_void {
|
|
87
|
+
if let self = self as? Promise_void {
|
|
88
|
+
return self
|
|
89
|
+
} else {
|
|
90
|
+
let promise = Promise_void.pending()
|
|
91
|
+
self.addOnResolvedListener { (result: Void) -> Void in
|
|
92
|
+
promise.resolve(result: result)
|
|
93
|
+
}
|
|
94
|
+
self.addOnRejectedListener { (error: any Error) -> Void in
|
|
95
|
+
promise.reject(error: error)
|
|
96
|
+
}
|
|
97
|
+
return promise
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ThemeTransitionDirection.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents the JS union `ThemeTransitionDirection`.
|
|
12
|
+
*/
|
|
13
|
+
@_expose(Cxx)
|
|
14
|
+
public enum ThemeTransitionDirection: Int32, CaseIterable, Sendable, CustomStringConvertible {
|
|
15
|
+
case `left` = 0
|
|
16
|
+
case `right` = 1
|
|
17
|
+
|
|
18
|
+
public static func fromRawValue(_ value: Int32) -> Self {
|
|
19
|
+
return Self(rawValue: value)!
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public extension ThemeTransitionDirection {
|
|
24
|
+
/**
|
|
25
|
+
* Get a ThemeTransitionDirection for the given String value, or
|
|
26
|
+
* return `nil` if the given value was invalid/unknown.
|
|
27
|
+
*/
|
|
28
|
+
init?(fromString string: String) {
|
|
29
|
+
switch string {
|
|
30
|
+
case "left":
|
|
31
|
+
self = .left
|
|
32
|
+
case "right":
|
|
33
|
+
self = .right
|
|
34
|
+
default:
|
|
35
|
+
return nil
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get the String value this ThemeTransitionDirection represents.
|
|
41
|
+
*/
|
|
42
|
+
var stringValue: String {
|
|
43
|
+
switch self {
|
|
44
|
+
case .left:
|
|
45
|
+
return "left"
|
|
46
|
+
case .right:
|
|
47
|
+
return "right"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var description: String {
|
|
52
|
+
return stringValue
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ThemeTransitionStyle.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents the JS union `ThemeTransitionStyle`.
|
|
12
|
+
*/
|
|
13
|
+
@_expose(Cxx)
|
|
14
|
+
public enum ThemeTransitionStyle: Int32, CaseIterable, Sendable, CustomStringConvertible {
|
|
15
|
+
case `fade` = 0
|
|
16
|
+
case `circle` = 1
|
|
17
|
+
case `slide` = 2
|
|
18
|
+
case `blur` = 3
|
|
19
|
+
|
|
20
|
+
public static func fromRawValue(_ value: Int32) -> Self {
|
|
21
|
+
return Self(rawValue: value)!
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public extension ThemeTransitionStyle {
|
|
26
|
+
/**
|
|
27
|
+
* Get a ThemeTransitionStyle for the given String value, or
|
|
28
|
+
* return `nil` if the given value was invalid/unknown.
|
|
29
|
+
*/
|
|
30
|
+
init?(fromString string: String) {
|
|
31
|
+
switch string {
|
|
32
|
+
case "fade":
|
|
33
|
+
self = .fade
|
|
34
|
+
case "circle":
|
|
35
|
+
self = .circle
|
|
36
|
+
case "slide":
|
|
37
|
+
self = .slide
|
|
38
|
+
case "blur":
|
|
39
|
+
self = .blur
|
|
40
|
+
default:
|
|
41
|
+
return nil
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the String value this ThemeTransitionStyle represents.
|
|
47
|
+
*/
|
|
48
|
+
var stringValue: String {
|
|
49
|
+
switch self {
|
|
50
|
+
case .fade:
|
|
51
|
+
return "fade"
|
|
52
|
+
case .circle:
|
|
53
|
+
return "circle"
|
|
54
|
+
case .slide:
|
|
55
|
+
return "slide"
|
|
56
|
+
case .blur:
|
|
57
|
+
return "blur"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var description: String {
|
|
62
|
+
return stringValue
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"classes": {
|
|
4
|
+
"ReducedMotion": {
|
|
5
|
+
"android": {
|
|
6
|
+
"implementation": {
|
|
7
|
+
"className": "HybridReducedMotion"
|
|
8
|
+
},
|
|
9
|
+
"language": "kotlin"
|
|
10
|
+
},
|
|
11
|
+
"apple": {
|
|
12
|
+
"implementation": {
|
|
13
|
+
"className": "HybridReducedMotion"
|
|
14
|
+
},
|
|
15
|
+
"language": "swift"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"ThemeCover": {
|
|
19
|
+
"android": {
|
|
20
|
+
"implementation": {
|
|
21
|
+
"className": "HybridThemeCover"
|
|
22
|
+
},
|
|
23
|
+
"language": "kotlin"
|
|
24
|
+
},
|
|
25
|
+
"apple": {
|
|
26
|
+
"implementation": {
|
|
27
|
+
"className": "HybridThemeCover"
|
|
28
|
+
},
|
|
29
|
+
"language": "swift"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReducedMotion.cjs
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
const { NitroModules } = require('nitro-core')
|
|
9
|
+
|
|
10
|
+
let hybridClass
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
get ReducedMotion() {
|
|
14
|
+
if (hybridClass === undefined) {
|
|
15
|
+
hybridClass = NitroModules.getHybridClass('nitrowind.ReducedMotion')
|
|
16
|
+
}
|
|
17
|
+
return hybridClass
|
|
18
|
+
},
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReducedMotion.d.cts
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
// The spec's `export declare class ReducedMotion` types this runtime export.
|
|
9
|
+
export {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ThemeCover.cjs
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
const { NitroModules } = require('nitro-core')
|
|
9
|
+
|
|
10
|
+
let hybridClass
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
get ThemeCover() {
|
|
14
|
+
if (hybridClass === undefined) {
|
|
15
|
+
hybridClass = NitroModules.getHybridClass('nitrowind.ThemeCover')
|
|
16
|
+
}
|
|
17
|
+
return hybridClass
|
|
18
|
+
},
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ThemeCover.d.cts
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/margelo/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
// The spec's `export declare class ThemeCover` types this runtime export.
|
|
9
|
+
export {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitrowind-native",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Optional native capabilities for NitroWind: reduced-motion variants and animated theme transitions.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Aristote Ngoy",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Aris-ngoy/nitroui-libraries.git",
|
|
10
|
+
"directory": "packages/nitrowind-native"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Aris-ngoy/nitroui-libraries/tree/main/packages/nitrowind-native#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Aris-ngoy/nitroui-libraries/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"nitroui",
|
|
18
|
+
"nitrowind",
|
|
19
|
+
"nitro-modules",
|
|
20
|
+
"react-native",
|
|
21
|
+
"ios",
|
|
22
|
+
"android",
|
|
23
|
+
"reduced-motion",
|
|
24
|
+
"theme-transitions"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./src/index.ts",
|
|
29
|
+
"./testing": "./src/testing.ts",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"imports": {
|
|
33
|
+
"#nitro/*": "./nitrogen/generated/shared/javascript/*.cjs"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src",
|
|
37
|
+
"Package.swift",
|
|
38
|
+
"ios",
|
|
39
|
+
"android",
|
|
40
|
+
"nitrogen/generated",
|
|
41
|
+
"nitro.json",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"README.md",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"codegen": "nitrogen . --out nitrogen/generated --log-level warning",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"clean": "rm -rf .turbo"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"nitro-core": "1.0.0-alpha.nightly.137.gd4793c40b8b8"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"nitro-ui-renderer": "0.2.1",
|
|
56
|
+
"nitrowind": "0.1.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"nitrogen": "1.0.0-alpha.nightly.137.gd4793c40b8b8",
|
|
60
|
+
"nitrowind": "0.1.1",
|
|
61
|
+
"typescript": "7.0.2"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
},
|
|
66
|
+
"nitroUI": {
|
|
67
|
+
"android": {
|
|
68
|
+
"activityInitializer": "com.margelo.nitro.nitrowind.ThemeCoverActivityInitializer"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CaptureCoverOptions, NitroWindNative, Unsubscribe } from 'nitrowind'
|
|
2
|
+
import { ReducedMotion } from './specs/ReducedMotion.nitro'
|
|
3
|
+
import { type CoverRequest, ThemeCover } from './specs/ThemeCover.nitro'
|
|
4
|
+
|
|
5
|
+
const VERSION = '0.1.1'
|
|
6
|
+
|
|
7
|
+
let reducedMotionInstance: ReducedMotion | undefined
|
|
8
|
+
let themeCoverInstance: ThemeCover | undefined
|
|
9
|
+
|
|
10
|
+
function getReducedMotionHybrid(): ReducedMotion {
|
|
11
|
+
reducedMotionInstance ??= new ReducedMotion()
|
|
12
|
+
return reducedMotionInstance
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getThemeCoverHybrid(): ThemeCover {
|
|
16
|
+
themeCoverInstance ??= new ThemeCover()
|
|
17
|
+
return themeCoverInstance
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Typing the fields as the spec's unions makes this fail to typecheck if `nitrowind` gains a
|
|
21
|
+
// transition style or direction that the generated native enums don't have.
|
|
22
|
+
function toCoverRequest(options: CaptureCoverOptions): CoverRequest {
|
|
23
|
+
return {
|
|
24
|
+
style: options.style,
|
|
25
|
+
durationMs: options.duration,
|
|
26
|
+
originX: options.origin?.x,
|
|
27
|
+
originY: options.origin?.y,
|
|
28
|
+
direction: options.direction,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Native capabilities for NitroWind. Pass this to `configure({ native: nitroWindNative })`
|
|
34
|
+
* in your app's entry file before the first render.
|
|
35
|
+
*/
|
|
36
|
+
export const nitroWindNative: NitroWindNative = {
|
|
37
|
+
version: VERSION,
|
|
38
|
+
getReducedMotion(): boolean {
|
|
39
|
+
return getReducedMotionHybrid().isReducedMotionEnabled()
|
|
40
|
+
},
|
|
41
|
+
subscribeReducedMotion(listener: (reducedMotion: boolean) => void): Unsubscribe {
|
|
42
|
+
const subscription = getReducedMotionHybrid().addOnReducedMotionChangedListener(listener)
|
|
43
|
+
return () => subscription.remove()
|
|
44
|
+
},
|
|
45
|
+
captureCover(options: CaptureCoverOptions): boolean | Promise<boolean> {
|
|
46
|
+
const cover = getThemeCoverHybrid()
|
|
47
|
+
const request = toCoverRequest(options)
|
|
48
|
+
return cover.isSyncCaptureSupported ? cover.captureCoverSync(request) : cover.captureCoverAsync(request)
|
|
49
|
+
},
|
|
50
|
+
finishCover(): Promise<void> {
|
|
51
|
+
return getThemeCoverHybrid().finishCover()
|
|
52
|
+
},
|
|
53
|
+
cancelCover(): void {
|
|
54
|
+
getThemeCoverHybrid().cancelCover()
|
|
55
|
+
},
|
|
56
|
+
isCoverActive(): boolean {
|
|
57
|
+
return getThemeCoverHybrid().isCoverActive()
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Android, iOS, type HybridObject } from 'nitro-core'
|
|
2
|
+
import type { ListenerSubscription } from './ListenerSubscription'
|
|
3
|
+
|
|
4
|
+
export * from '#nitro/ReducedMotion'
|
|
5
|
+
|
|
6
|
+
/** Reports and observes the operating system's "reduce motion" accessibility setting. */
|
|
7
|
+
@iOS({ language: 'swift', implementation: { className: 'HybridReducedMotion' } })
|
|
8
|
+
@Android({ language: 'kotlin', implementation: { className: 'HybridReducedMotion' } })
|
|
9
|
+
export declare class ReducedMotion extends HybridObject {
|
|
10
|
+
public constructor()
|
|
11
|
+
|
|
12
|
+
/** Whether the user has enabled "reduce motion" in system settings. */
|
|
13
|
+
isReducedMotionEnabled(): boolean
|
|
14
|
+
/**
|
|
15
|
+
* Observes changes to the system "reduce motion" setting.
|
|
16
|
+
* Remove the returned subscription when observation is no longer needed.
|
|
17
|
+
*/
|
|
18
|
+
addOnReducedMotionChangedListener(listener: (reducedMotion: boolean) => void): ListenerSubscription
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Android, iOS, type HybridObject } from 'nitro-core'
|
|
2
|
+
|
|
3
|
+
export * from '#nitro/ThemeCover'
|
|
4
|
+
|
|
5
|
+
// Nitrogen cannot resolve the `nitrowind` package, so these mirror its unions of the same name;
|
|
6
|
+
// `toCoverRequest` in `src/index.ts` fails to typecheck if `nitrowind` adds a member these lack.
|
|
7
|
+
/** Mirrors `ThemeTransitionStyle` from `nitrowind`. Generated as a native enum. */
|
|
8
|
+
export type ThemeTransitionStyle = 'fade' | 'circle' | 'slide' | 'blur'
|
|
9
|
+
/** Mirrors `ThemeTransitionDirection` from `nitrowind`. Generated as a native enum. */
|
|
10
|
+
export type ThemeTransitionDirection = 'left' | 'right'
|
|
11
|
+
|
|
12
|
+
/** One theme-transition cover: how to animate it away, captured together with the screen. */
|
|
13
|
+
export interface CoverRequest {
|
|
14
|
+
/** Animation that reveals the new theme. */
|
|
15
|
+
style: ThemeTransitionStyle
|
|
16
|
+
/** Duration of the reveal in milliseconds. */
|
|
17
|
+
durationMs: number
|
|
18
|
+
/** Root-view x (points/dp) where a `'circle'` reveal starts. Ignored unless `originY` is set too. */
|
|
19
|
+
originX?: number
|
|
20
|
+
/** Root-view y (points/dp) where a `'circle'` reveal starts. Ignored unless `originX` is set too. */
|
|
21
|
+
originY?: number
|
|
22
|
+
/** Which way a `'slide'` reveal moves the old screen. Defaults to `'left'`. */
|
|
23
|
+
direction?: ThemeTransitionDirection
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Captures a native screen snapshot cover and animates it away for theme transitions. */
|
|
27
|
+
@iOS({ language: 'swift', implementation: { className: 'HybridThemeCover' } })
|
|
28
|
+
@Android({ language: 'kotlin', implementation: { className: 'HybridThemeCover' } })
|
|
29
|
+
export declare class ThemeCover extends HybridObject {
|
|
30
|
+
public constructor()
|
|
31
|
+
|
|
32
|
+
/** Whether screen capture is synchronous on this platform (`true` on iOS, `false` on Android). */
|
|
33
|
+
readonly isSyncCaptureSupported: boolean
|
|
34
|
+
/** Synchronously captures the screen and presents the cover window (iOS). */
|
|
35
|
+
captureCoverSync(request: CoverRequest): boolean
|
|
36
|
+
/** Asynchronously captures the screen and presents the cover overlay (Android). */
|
|
37
|
+
captureCoverAsync(request: CoverRequest): Promise<boolean>
|
|
38
|
+
/** Animates the active cover away and resolves once it has been removed. */
|
|
39
|
+
finishCover(): Promise<void>
|
|
40
|
+
/** Immediately removes any active cover overlay. */
|
|
41
|
+
cancelCover(): void
|
|
42
|
+
/** Whether a cover overlay is currently shown on screen. */
|
|
43
|
+
isCoverActive(): boolean
|
|
44
|
+
/**
|
|
45
|
+
* Test-only, not part of the public API: what the most recent capture did, such as `'captured'` or
|
|
46
|
+
* `'failed: <reason>'`. Read it through `nitrowind-native/testing`.
|
|
47
|
+
*/
|
|
48
|
+
lastCaptureOutcome(): string
|
|
49
|
+
}
|
package/src/testing.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only hooks into the native theme cover, for the package's own device tests.
|
|
3
|
+
* Not part of the public API: names and values can change in any release.
|
|
4
|
+
*/
|
|
5
|
+
import { ThemeCover } from './specs/ThemeCover.nitro'
|
|
6
|
+
|
|
7
|
+
let themeCover: ThemeCover | undefined
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* What the most recent native capture did, so a device test can tell an animated switch from one that
|
|
11
|
+
* fell back to instant. `'none'` before the first capture, then `'captured'` or `'failed: <reason>'`.
|
|
12
|
+
* Android also reports `'pending'`, `'captured on the recreated Activity'`, `'reused: <reason>'` and
|
|
13
|
+
* `'superseded'`.
|
|
14
|
+
*/
|
|
15
|
+
export function lastCaptureOutcome(): string {
|
|
16
|
+
themeCover ??= new ThemeCover()
|
|
17
|
+
return themeCover.lastCaptureOutcome()
|
|
18
|
+
}
|