-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Format code * Increase test coverage * Update `ci.yml` * Update `README.md` * Add `codecov.yml` * Add templates
- Loading branch information
1 parent
4c4a35a
commit e84c3d3
Showing
39 changed files
with
1,359 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
name: "🐛 Bug Report" | ||
about: Report a reproducible bug or regression. | ||
title: 'Bug: ' | ||
labels: 'bug' | ||
|
||
--- | ||
|
||
<!-- | ||
Please provide a clear and concise description of what the bug is. Include | ||
screenshots if needed. Please test using the latest version of the relevant | ||
React packages to make sure your issue has not already been fixed. | ||
--> | ||
|
||
Application version: | ||
|
||
## Steps To Reproduce | ||
|
||
1. | ||
2. | ||
|
||
<!-- | ||
Your bug will get fixed much faster if we can run your code and it doesn't | ||
have dependencies other than React. Issues without reproduction steps or | ||
code examples may be immediately closed as not actionable. | ||
--> | ||
|
||
Link to code example: | ||
|
||
<!-- | ||
Please provide a CodeSandbox (https://codesandbox.io/s/new), a link to a | ||
repository on GitHub, or provide a minimal code example that reproduces the | ||
problem. You may provide a screenshot of the application if you think it is | ||
relevant to your bug report. Here are some tips for providing a minimal | ||
example: https://stackoverflow.com/help/mcve. | ||
--> | ||
|
||
## The current behavior | ||
|
||
|
||
## The expected behavior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
name: 🛠 Feature request | ||
about: If you have a feature request for the Nexus, file it here. | ||
labels: 'type: enhancement' | ||
--- | ||
|
||
**Feature description** | ||
Clearly and concisely describe the feature. | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Bug description | ||
Clearly and concisely describe the problem. | ||
|
||
## Solution description | ||
Describe your code changes in detail for reviewers. Explain the technical solution you have provided and how it fixes the issue case. | ||
|
||
## Covered unit test cases | ||
- [x] yes | ||
- [x] no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Feature description | ||
Clearly and concisely describe the feature. | ||
|
||
## Solution description | ||
Describe your code changes in detail for reviewers. | ||
|
||
## Areas affected and ensured | ||
List out the areas affected by your code changes. | ||
|
||
## Covered unit test cases | ||
- [x] yes | ||
- [x] no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,18 @@ on: | |
branches: | ||
- main | ||
- dev | ||
paths: | ||
- ".github/workflows/**" | ||
- "Package.swift" | ||
- "Source/**" | ||
- "Tests/**" | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '.swiftlint.yml' | ||
- ".github/workflows/**" | ||
- "Package.swift" | ||
- "Source/**" | ||
- "Tests/**" | ||
|
||
concurrency: | ||
group: ci | ||
|
@@ -26,10 +36,18 @@ jobs: | |
- destination: "OS=16.1,name=iPhone 14 Pro" | ||
name: "iOS" | ||
scheme: "Nexus" | ||
sdk: iphonesimulator | ||
- destination: "OS=9.1,name=Apple Watch Series 8 (45mm)" | ||
name: "watchOS" | ||
scheme: "Nexus" | ||
sdk: watchsimulator | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: ${{ matrix.name }} | ||
run: xcodebuild test -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" clean | ||
run: xcodebuild test -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "./${{ matrix.sdk }}.xcresult" | xcpretty -r junit | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
xcode: true | ||
xcode_archive_path: "./${{ matrix.sdk }}.xcresult" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1410" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "Nexus" | ||
BuildableName = "Nexus" | ||
BlueprintName = "Nexus" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "NexusTests" | ||
BuildableName = "NexusTests" | ||
BlueprintName = "NexusTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
codeCoverageEnabled = "YES" | ||
onlyGenerateCoverageForSpecifiedTargets = "YES"> | ||
<CodeCoverageTargets> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "Nexus" | ||
BuildableName = "Nexus" | ||
BlueprintName = "Nexus" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</CodeCoverageTargets> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "NexusTests" | ||
BuildableName = "NexusTests" | ||
BlueprintName = "NexusTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "Nexus" | ||
BuildableName = "Nexus" | ||
BlueprintName = "Nexus" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
<a href="https://developer.apple.com/swift"><img alt="Swift5.7" src="https://img.shields.io/badge/language-Swift5.7-orange.svg"/></a> | ||
<a href="https://github.com/space-code/concurrency"><img alt="CI" src="https://github.com/space-code/nexus/actions/workflows/ci.yml/badge.svg?branch=main"></a> | ||
<a href="https://github.com/apple/swift-package-manager" alt="Nexus on Swift Package Manager"><img src="https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg" /></a> | ||
<a href="https://codecov.io/gh/space-code/nexus"><img alt="CodeCov" src="https://codecov.io/github/space-code/nexus/graph/badge.svg?token=4MP7MPTQS5"></a> | ||
</p> | ||
|
||
## Description | ||
|
@@ -23,7 +24,7 @@ Nexus is a wrapper around `WatchConnectivity` that simplifies the interaction be | |
|
||
## Usage | ||
|
||
1. Define a message model, like this: | ||
1. Define a message model like this: | ||
```swift | ||
import Nexus | ||
|
||
|
@@ -51,7 +52,7 @@ communicationService.receiveMessage(TestMessage.self) | |
.store(in: &disposables) | ||
``` | ||
|
||
3. Send a message to Apple Watch or iPhone | ||
3. Send a message to Apple Watch or iPhone: | ||
```swift | ||
import Nexus | ||
|
||
|
@@ -73,7 +74,7 @@ Once you have your Swift package set up, adding `nexus` as a dependency is as ea | |
|
||
```swift | ||
dependencies: [ | ||
.package(url: "https://github.com/space-code/nexus.git", .upToNextMajor(from: "1.0.0")) | ||
.package(url: "https://github.com/space-code/nexus.git", .upToNextMajor(from: "2.0.0")) | ||
] | ||
``` | ||
|
||
|
@@ -95,4 +96,4 @@ Please feel free to help out with this project! If you see something that could | |
Nikita Vasilev, [email protected] | ||
|
||
## License | ||
nexus is available under the MIT license. See the LICENSE file for more info. | ||
nexus is available under the MIT license. See the LICENSE file for more info. |
34 changes: 34 additions & 0 deletions
34
Sources/Nexus/Classes/Core/Interfaces/INotificationCenter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Nexus | ||
// Copyright © 2023 Space Code. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - INotificationCenter | ||
|
||
/// A notification dispatch mechanism that enables the broadcast of information to registered observers. | ||
public protocol INotificationCenter { | ||
/// Creates a notification with a given name and sender and posts it to the notification center. | ||
/// | ||
/// - Parameters: | ||
/// - aName: The name of the notification. | ||
/// - anObject: The object posting the notification. | ||
func post(name aName: NSNotification.Name, object anObject: Any?) | ||
|
||
/// Returns a publisher that emits events when broadcasting notifications. | ||
/// | ||
/// - Parameters: | ||
/// - name: The name of the notification to publish. | ||
/// - object: The object posting the named notification. If nil, the publisher emits elements | ||
/// for any object producing a notification with the given name. | ||
/// | ||
/// - Returns: A Publisher that emits events when broadcasting notifications. | ||
func publisher(for name: Notification.Name, object: AnyObject?) -> NotificationCenter.Publisher | ||
} | ||
|
||
extension INotificationCenter { | ||
func publisher(for name: Notification.Name) -> NotificationCenter.Publisher { | ||
publisher(for: name, object: nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Nexus | ||
// Copyright © 2023 Space Code. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import WatchConnectivity | ||
|
||
// MARK: - IWCSession | ||
|
||
/// A type that initiates communication between a WatchKit extension and its companion iOS app. | ||
public protocol IWCSession: AnyObject { | ||
/// The current activation state of the session. | ||
var activationState: WCSessionActivationState { get } | ||
|
||
#if os(iOS) | ||
/// A Boolean value indicating whether the currently paired and active Apple Watch has installed the app. | ||
var isWatchAppInstalled: Bool { get } | ||
#else | ||
/// A Boolean value indicating whether the companion has installed the app. | ||
var isCompanionAppInstalled: Bool { get } | ||
#endif | ||
|
||
/// The delegate for the session object. | ||
var delegate: WCSessionDelegate? { get set } | ||
|
||
/// Activates the session asynchronously. | ||
func activate() | ||
|
||
/// Sends a message immediately to the paired and active device and optionally handles a response. | ||
/// | ||
/// - Parameters: | ||
/// - message: A dictionary of property list values that you want to send. | ||
/// You define the contents of the dictionary that your counterpart supports. | ||
/// This parameter must not be nil. | ||
/// - replyHandler: A reply handler for receiving a response from the counterpart. | ||
/// Specify nil if you do not want to receive a reply. | ||
/// - errorHandler: A block that is executed when an error occurs. | ||
/// Specify nil if you do not care about error information. | ||
func sendMessage(_ message: [String: Any], replyHandler: (([String: Any]) -> Void)?, errorHandler: ((Error) -> Void)?) | ||
} | ||
|
||
// MARK: - WCSession + IWCSession | ||
|
||
extension WCSession: IWCSession {} |
12 changes: 12 additions & 0 deletions
12
...s/Nexus/Classes/Core/Providers/SessionCompatibleProvider/ISessionCompatibleProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Nexus | ||
// Copyright © 2023 Space Code. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A type that identifies compatible session communication. | ||
public protocol ISessionCompatibleProvider { | ||
/// A Boolean value indicating whether the current iOS device is able to use a session object. | ||
var isSupported: Bool { get } | ||
} |
Oops, something went wrong.