Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ece015

Browse files
committed
workaround xcode linking bug
1 parentf6a851a commit5ece015

File tree

4 files changed

+68
-63
lines changed

4 files changed

+68
-63
lines changed
Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
importURLRouting
2+
importVPNLib
33

44
@MainActor
55
classURLHandler{
@@ -13,7 +13,7 @@ class URLHandler {
1313
router=CoderRouter()
1414
}
1515

16-
func handle(_ url:URL)throws(URLError){
16+
func handle(_ url:URL)throws(RouterError){
1717
guard state.hasSession,let deployment= state.baseAccessURLelse{
1818
throw.noSession
1919
}
@@ -29,69 +29,11 @@ class URLHandler {
2929
}
3030
}
3131
}catch{
32-
throw.routerError(url: url)
32+
throw.matchError(url: url)
3333
}
3434

3535
func handleRDP(workspace _:String, agent _:String, creds _:RDPCredentials){
3636
// TODO: Handle RDP
3737
}
3838
}
3939
}
40-
41-
structCoderRouter:ParserPrinter{
42-
publicvarbody:someParserPrinter<URLRequestData,CoderRoute>{
43-
Route(.case(CoderRoute.open(workspace:agent:route:))){
44-
// v0/open/ws/<workspace>/agent/<agent>/<openType>
45-
Path{"v0";"open";"ws";Parse(.string);"agent";Parse(.string)}
46-
openRouter
47-
}
48-
}
49-
50-
varopenRouter:someParserPrinter<URLRequestData,OpenRoute>{
51-
OneOf{
52-
Route(.memberwise(OpenRoute.rdp)){
53-
Path{"rdp"}
54-
Query{
55-
Parse(.memberwise(RDPCredentials.init)){
56-
Optionally{Field("username")}
57-
Optionally{Field("password")}
58-
}
59-
}
60-
}
61-
}
62-
}
63-
}
64-
65-
enumURLError:Error{
66-
case invalidAuthority(String)
67-
case routerError(url:URL)
68-
case noSession
69-
70-
vardescription:String{
71-
switchself{
72-
caselet.invalidAuthority(authority):
73-
"Authority '\(authority)' does not match the host of the current Coder deployment."
74-
caselet.routerError(url):
75-
"Failed to handle\(url.absoluteString) because the format is unsupported."
76-
case.noSession:
77-
"Not logged in."
78-
}
79-
}
80-
81-
varlocalizedDescription:String{ description}
82-
}
83-
84-
publicenumCoderRoute:Equatable,Sendable{
85-
case open(workspace:String, agent:String, route:OpenRoute)
86-
}
87-
88-
publicenumOpenRoute:Equatable,Sendable{
89-
case rdp(RDPCredentials)
90-
}
91-
92-
// Due to a Swift Result builder limitation, we can't flatten this out to `case rdp(String?, String?)`
93-
// https://github.com/pointfreeco/swift-url-routing/issues/50
94-
publicstructRDPCredentials:Equatable,Sendable{
95-
letusername:String?
96-
letpassword:String?
97-
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import Foundation
2+
import URLRouting
3+
4+
// This is in VPNLib to avoid depending on `swift-collections` in both the app & extension.
5+
publicstructCoderRouter:ParserPrinter{
6+
publicinit(){}
7+
8+
publicvarbody:someParserPrinter<URLRequestData,CoderRoute>{
9+
Route(.case(CoderRoute.open(workspace:agent:route:))){
10+
// v0/open/ws/<workspace>/agent/<agent>/<openType>
11+
Path{"v0";"open";"ws";Parse(.string);"agent";Parse(.string)}
12+
openRouter
13+
}
14+
}
15+
16+
varopenRouter:someParserPrinter<URLRequestData,OpenRoute>{
17+
OneOf{
18+
Route(.memberwise(OpenRoute.rdp)){
19+
Path{"rdp"}
20+
Query{
21+
Parse(.memberwise(RDPCredentials.init)){
22+
Optionally{Field("username")}
23+
Optionally{Field("password")}
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
31+
publicenumRouterError:Error{
32+
case invalidAuthority(String)
33+
case matchError(url:URL)
34+
case noSession
35+
36+
publicvardescription:String{
37+
switchself{
38+
caselet.invalidAuthority(authority):
39+
"Authority '\(authority)' does not match the host of the current Coder deployment."
40+
caselet.matchError(url):
41+
"Failed to handle\(url.absoluteString) because the format is unsupported."
42+
case.noSession:
43+
"Not logged in."
44+
}
45+
}
46+
47+
publicvarlocalizedDescription:String{ description}
48+
}
49+
50+
publicenumCoderRoute:Equatable,Sendable{
51+
case open(workspace:String, agent:String, route:OpenRoute)
52+
}
53+
54+
publicenumOpenRoute:Equatable,Sendable{
55+
case rdp(RDPCredentials)
56+
}
57+
58+
// Due to a Swift Result builder limitation, we can't flatten this out to `case rdp(String?, String?)`
59+
// https://github.com/pointfreeco/swift-url-routing/issues/50
60+
publicstructRDPCredentials:Equatable,Sendable{
61+
publicletusername:String?
62+
publicletpassword:String?
63+
}

‎Coder-Desktop/Coder-DesktopTests/CoderRouterTests.swiftrenamed to‎Coder-Desktop/VPNLibTests/CoderRouterTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@testableimport Coder_Desktop
21
import Foundation
32
import Testing
43
import URLRouting
4+
@testableimport VPNLib
55

66
@MainActor
77
@Suite(.timeLimit(.minutes(1)))

‎Coder-Desktop/project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ targets:
189189
-package:LaunchAtLogin
190190
-package:SDWebImageSwiftUI
191191
-package:SDWebImageSVGCoder
192-
-package:URLRouting
193192
scheme:
194193
testPlans:
195194
-path:Coder-Desktop.xctestplan
@@ -295,6 +294,7 @@ targets:
295294
-package:GRPC
296295
-package:Subprocess
297296
-package:Semaphore
297+
-package:URLRouting
298298
-target:CoderSDK
299299
embed:false
300300

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp