@capacitor-plus/ios 8.0.0-beta.0

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.
Files changed (106) hide show
  1. package/Capacitor/Capacitor/AppUUID.swift +51 -0
  2. package/Capacitor/Capacitor/Array+Capacitor.swift +31 -0
  3. package/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift +32 -0
  4. package/Capacitor/Capacitor/CAPBridge.swift +25 -0
  5. package/Capacitor/Capacitor/CAPBridgeDelegate.swift +6 -0
  6. package/Capacitor/Capacitor/CAPBridgeProtocol.swift +148 -0
  7. package/Capacitor/Capacitor/CAPBridgeViewController+CDVScreenOrientationDelegate.h +6 -0
  8. package/Capacitor/Capacitor/CAPBridgeViewController+CDVScreenOrientationDelegate.m +5 -0
  9. package/Capacitor/Capacitor/CAPBridgeViewController.swift +384 -0
  10. package/Capacitor/Capacitor/CAPBridgedJSTypes.h +18 -0
  11. package/Capacitor/Capacitor/CAPBridgedJSTypes.m +43 -0
  12. package/Capacitor/Capacitor/CAPBridgedPlugin+getMethod.swift +13 -0
  13. package/Capacitor/Capacitor/CAPBridgedPlugin.h +41 -0
  14. package/Capacitor/Capacitor/CAPFile.swift +14 -0
  15. package/Capacitor/Capacitor/CAPInstanceConfiguration.h +38 -0
  16. package/Capacitor/Capacitor/CAPInstanceConfiguration.m +93 -0
  17. package/Capacitor/Capacitor/CAPInstanceConfiguration.swift +78 -0
  18. package/Capacitor/Capacitor/CAPInstanceDescriptor.h +167 -0
  19. package/Capacitor/Capacitor/CAPInstanceDescriptor.m +56 -0
  20. package/Capacitor/Capacitor/CAPInstanceDescriptor.swift +198 -0
  21. package/Capacitor/Capacitor/CAPInstancePlugin.swift +10 -0
  22. package/Capacitor/Capacitor/CAPLog.swift +11 -0
  23. package/Capacitor/Capacitor/CAPNotifications.swift +69 -0
  24. package/Capacitor/Capacitor/CAPPlugin+LoadInstance.swift +20 -0
  25. package/Capacitor/Capacitor/CAPPlugin.h +60 -0
  26. package/Capacitor/Capacitor/CAPPlugin.m +180 -0
  27. package/Capacitor/Capacitor/CAPPluginCall.h +25 -0
  28. package/Capacitor/Capacitor/CAPPluginCall.m +36 -0
  29. package/Capacitor/Capacitor/CAPPluginCall.swift +97 -0
  30. package/Capacitor/Capacitor/CAPPluginMethod.h +36 -0
  31. package/Capacitor/Capacitor/CAPPluginMethod.m +44 -0
  32. package/Capacitor/Capacitor/CAPPluginMethod.swift +17 -0
  33. package/Capacitor/Capacitor/Capacitor.h +15 -0
  34. package/Capacitor/Capacitor/Capacitor.modulemap +8 -0
  35. package/Capacitor/Capacitor/CapacitorBridge.swift +768 -0
  36. package/Capacitor/Capacitor/CapacitorExtension.swift +24 -0
  37. package/Capacitor/Capacitor/Codable/JSValueDecoder.swift +479 -0
  38. package/Capacitor/Capacitor/Codable/JSValueEncoder.swift +671 -0
  39. package/Capacitor/Capacitor/Data+Capacitor.swift +22 -0
  40. package/Capacitor/Capacitor/DocLinks.swift +8 -0
  41. package/Capacitor/Capacitor/Info.plist +24 -0
  42. package/Capacitor/Capacitor/JS.swift +122 -0
  43. package/Capacitor/Capacitor/JSExport.swift +218 -0
  44. package/Capacitor/Capacitor/JSTypes.swift +254 -0
  45. package/Capacitor/Capacitor/KeyPath.swift +60 -0
  46. package/Capacitor/Capacitor/KeyValueStore.swift +303 -0
  47. package/Capacitor/Capacitor/NotificationHandlerProtocol.swift +6 -0
  48. package/Capacitor/Capacitor/NotificationRouter.swift +60 -0
  49. package/Capacitor/Capacitor/PluginCallResult.swift +106 -0
  50. package/Capacitor/Capacitor/PluginConfig.swift +56 -0
  51. package/Capacitor/Capacitor/Plugins/CapacitorCookieManager.swift +141 -0
  52. package/Capacitor/Capacitor/Plugins/CapacitorCookies.swift +57 -0
  53. package/Capacitor/Capacitor/Plugins/CapacitorHttp.swift +57 -0
  54. package/Capacitor/Capacitor/Plugins/CapacitorUrlRequest.swift +225 -0
  55. package/Capacitor/Capacitor/Plugins/Console.swift +16 -0
  56. package/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift +236 -0
  57. package/Capacitor/Capacitor/Plugins/SystemBars.swift +133 -0
  58. package/Capacitor/Capacitor/Plugins/WebView.swift +44 -0
  59. package/Capacitor/Capacitor/PrivacyInfo.xcprivacy +14 -0
  60. package/Capacitor/Capacitor/Router.swift +29 -0
  61. package/Capacitor/Capacitor/TmpViewController.swift +8 -0
  62. package/Capacitor/Capacitor/UIColor.swift +55 -0
  63. package/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m +37 -0
  64. package/Capacitor/Capacitor/WKWebView+Capacitor.m +15 -0
  65. package/Capacitor/Capacitor/WKWebView+Capacitor.swift +80 -0
  66. package/Capacitor/Capacitor/WebViewAssetHandler.swift +550 -0
  67. package/Capacitor/Capacitor/WebViewDelegationHandler.swift +361 -0
  68. package/Capacitor/Capacitor/assets/native-bridge.js +1029 -0
  69. package/Capacitor.podspec +23 -0
  70. package/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +25 -0
  71. package/CapacitorCordova/CapacitorCordova/CapacitorCordova.modulemap +6 -0
  72. package/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.h +8 -0
  73. package/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.m +5 -0
  74. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h +28 -0
  75. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVAvailability.h +109 -0
  76. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVAvailabilityDeprecated.h +21 -0
  77. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h +49 -0
  78. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.h +39 -0
  79. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m +149 -0
  80. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.h +31 -0
  81. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.m +81 -0
  82. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.h +52 -0
  83. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.m +116 -0
  84. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin+Resources.h +39 -0
  85. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin+Resources.m +38 -0
  86. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.h +76 -0
  87. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.m +136 -0
  88. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.h +25 -0
  89. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.m +77 -0
  90. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.h +82 -0
  91. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m +216 -0
  92. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
  93. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.h +27 -0
  94. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.m +74 -0
  95. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.h +30 -0
  96. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m +37 -0
  97. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.h +34 -0
  98. package/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.m +55 -0
  99. package/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
  100. package/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
  101. package/CapacitorCordova/CapacitorCordova/Info.plist +26 -0
  102. package/CapacitorCordova/CapacitorCordova/PrivacyInfo.xcprivacy +14 -0
  103. package/CapacitorCordova.podspec +26 -0
  104. package/LICENSE +21 -0
  105. package/package.json +33 -0
  106. package/scripts/pods_helpers.rb +12 -0
@@ -0,0 +1,550 @@
1
+ import Foundation
2
+ import UniformTypeIdentifiers
3
+
4
+ @objc(CAPWebViewAssetHandler)
5
+ // swiftlint:disable type_body_length
6
+ open class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
7
+ private var router: Router
8
+ private var serverUrl: URL?
9
+
10
+ public init(router: Router) {
11
+ self.router = router
12
+ super.init()
13
+ }
14
+
15
+ open func setAssetPath(_ assetPath: String) {
16
+ router.basePath = assetPath
17
+ }
18
+
19
+ open func setServerUrl(_ serverUrl: URL?) {
20
+ self.serverUrl = serverUrl
21
+ }
22
+
23
+ private func isUsingLiveReload(_ localUrl: URL) -> Bool {
24
+ return self.serverUrl != nil && self.serverUrl?.scheme != localUrl.scheme
25
+ }
26
+
27
+ open func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
28
+ let startPath: String
29
+ let url = urlSchemeTask.request.url!
30
+ let stringToLoad = url.path
31
+ let localUrl = URL.init(string: url.absoluteString)!
32
+
33
+ if url.path.starts(with: CapacitorBridge.httpInterceptorStartIdentifier) {
34
+ handleCapacitorHttpRequest(urlSchemeTask, localUrl, false)
35
+ return
36
+ }
37
+
38
+ if stringToLoad.starts(with: CapacitorBridge.fileStartIdentifier) {
39
+ startPath = stringToLoad.replacingOccurrences(of: CapacitorBridge.fileStartIdentifier, with: "")
40
+ } else {
41
+ startPath = router.route(for: stringToLoad)
42
+ }
43
+
44
+ let fileUrl = URL.init(fileURLWithPath: startPath)
45
+
46
+ do {
47
+ var data = Data()
48
+ let mimeType = mimeTypeForExtension(pathExtension: url.pathExtension)
49
+ var headers = [
50
+ "Content-Type": mimeType,
51
+ "Cache-Control": "no-cache"
52
+ ]
53
+
54
+ // if using live reload, then set CORS headers
55
+ if isUsingLiveReload(localUrl) {
56
+ headers["Access-Control-Allow-Origin"] = self.serverUrl?.absoluteString
57
+ headers["Access-Control-Allow-Methods"] = "GET, HEAD, OPTIONS, TRACE"
58
+ }
59
+
60
+ if let rangeString = urlSchemeTask.request.value(forHTTPHeaderField: "Range"),
61
+ let totalSize = try fileUrl.resourceValues(forKeys: [.fileSizeKey]).fileSize {
62
+ let fileHandle = try FileHandle(forReadingFrom: fileUrl)
63
+ let parts = rangeString.components(separatedBy: "=")
64
+ let streamParts = parts[1].components(separatedBy: "-")
65
+ let fromRange = Int(streamParts[0]) ?? 0
66
+ var toRange = totalSize - 1
67
+ if streamParts.count > 1 {
68
+ toRange = Int(streamParts[1]) ?? toRange
69
+ }
70
+ let rangeLength = toRange - fromRange + 1
71
+ try fileHandle.seek(toOffset: UInt64(fromRange))
72
+ data = fileHandle.readData(ofLength: rangeLength)
73
+ headers["Accept-Ranges"] = "bytes"
74
+ headers["Content-Range"] = "bytes \(fromRange)-\(toRange)/\(totalSize)"
75
+ headers["Content-Length"] = String(data.count)
76
+ let response = HTTPURLResponse(url: localUrl, statusCode: 206, httpVersion: nil, headerFields: headers)
77
+ urlSchemeTask.didReceive(response!)
78
+ try fileHandle.close()
79
+ } else {
80
+ if !stringToLoad.contains("cordova.js") {
81
+ if isMediaExtension(pathExtension: url.pathExtension) {
82
+ data = try Data(contentsOf: fileUrl, options: Data.ReadingOptions.mappedIfSafe)
83
+ } else {
84
+ data = try Data(contentsOf: fileUrl)
85
+ }
86
+ }
87
+ let urlResponse = URLResponse(url: localUrl, mimeType: mimeType, expectedContentLength: data.count, textEncodingName: nil)
88
+ let httpResponse = HTTPURLResponse(url: localUrl, statusCode: 200, httpVersion: nil, headerFields: headers)
89
+ if isMediaExtension(pathExtension: url.pathExtension) {
90
+ urlSchemeTask.didReceive(urlResponse)
91
+ } else {
92
+ urlSchemeTask.didReceive(httpResponse!)
93
+ }
94
+ }
95
+ urlSchemeTask.didReceive(data)
96
+ } catch let error as NSError {
97
+ urlSchemeTask.didFailWithError(error)
98
+ return
99
+ }
100
+ urlSchemeTask.didFinish()
101
+ }
102
+
103
+ open func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) {
104
+ urlSchemeTask.stopped = true
105
+ }
106
+
107
+ open func mimeTypeForExtension(pathExtension: String) -> String {
108
+ if !pathExtension.isEmpty {
109
+ if let uti = UTType(filenameExtension: pathExtension) {
110
+ if let mimetype = uti.preferredMIMEType {
111
+ return mimetype
112
+ }
113
+ }
114
+ // TODO: Remove when deployment target is set to iOS 17
115
+ if let mimeType = mimeTypes[pathExtension] {
116
+ return mimeType
117
+ }
118
+ return "application/octet-stream"
119
+ }
120
+ return "text/html"
121
+ }
122
+
123
+ open func isMediaExtension(pathExtension: String) -> Bool {
124
+ let mediaExtensions = ["m4v", "mov", "mp4",
125
+ "aac", "ac3", "aiff", "au", "flac", "m4a", "mp3", "wav"]
126
+ if mediaExtensions.contains(pathExtension.lowercased()) {
127
+ return true
128
+ }
129
+ return false
130
+ }
131
+
132
+ func handleCapacitorHttpRequest(_ urlSchemeTask: WKURLSchemeTask, _ localUrl: URL, _ isHttpsRequest: Bool) {
133
+ var urlRequest = urlSchemeTask.request
134
+ guard let url = urlRequest.url else { return }
135
+
136
+ let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
137
+ if let targetUrl = urlComponents?.queryItems?.first(where: { $0.name == CapacitorBridge.httpInterceptorUrlParam })?.value,
138
+ !targetUrl.isEmpty {
139
+ urlRequest.url = URL(string: targetUrl)
140
+ }
141
+
142
+ let urlSession = URLSession.shared
143
+ let task = urlSession.dataTask(with: urlRequest) { (data, response, error) in
144
+ DispatchQueue.main.async {
145
+ guard !urlSchemeTask.stopped else { return }
146
+ if let error = error {
147
+ urlSchemeTask.didFailWithError(error)
148
+ return
149
+ }
150
+
151
+ if let response = response as? HTTPURLResponse {
152
+ let existingHeaders = response.allHeaderFields
153
+ var newHeaders: [AnyHashable: Any] = [:]
154
+
155
+ // if using live reload, then set CORS headers
156
+ if self.isUsingLiveReload(url) {
157
+ newHeaders = [
158
+ "Access-Control-Allow-Origin": self.serverUrl?.absoluteString ?? "",
159
+ "Access-Control-Allow-Methods": "GET, HEAD, OPTIONS, TRACE"
160
+ ]
161
+ }
162
+
163
+ if let mergedHeaders = existingHeaders.merging(newHeaders, uniquingKeysWith: { (_, newHeaders) in newHeaders }) as? [String: String] {
164
+
165
+ if let responseUrl = response.url {
166
+ if let modifiedResponse = HTTPURLResponse(
167
+ url: responseUrl,
168
+ statusCode: response.statusCode,
169
+ httpVersion: nil,
170
+ headerFields: mergedHeaders
171
+ ) {
172
+ urlSchemeTask.didReceive(modifiedResponse)
173
+ }
174
+ }
175
+
176
+ if let data = data {
177
+ urlSchemeTask.didReceive(data)
178
+ }
179
+ }
180
+ }
181
+ urlSchemeTask.didFinish()
182
+ return
183
+ }
184
+ }
185
+
186
+ task.resume()
187
+ }
188
+
189
+ public let mimeTypes = [
190
+ "aaf": "application/octet-stream",
191
+ "aca": "application/octet-stream",
192
+ "accdb": "application/msaccess",
193
+ "accde": "application/msaccess",
194
+ "accdt": "application/msaccess",
195
+ "acx": "application/internet-property-stream",
196
+ "afm": "application/octet-stream",
197
+ "ai": "application/postscript",
198
+ "aif": "audio/x-aiff",
199
+ "aifc": "audio/aiff",
200
+ "aiff": "audio/aiff",
201
+ "application": "application/x-ms-application",
202
+ "art": "image/x-jg",
203
+ "asd": "application/octet-stream",
204
+ "asf": "video/x-ms-asf",
205
+ "asi": "application/octet-stream",
206
+ "asm": "text/plain",
207
+ "asr": "video/x-ms-asf",
208
+ "asx": "video/x-ms-asf",
209
+ "atom": "application/atom+xml",
210
+ "au": "audio/basic",
211
+ "avi": "video/x-msvideo",
212
+ "axs": "application/olescript",
213
+ "bas": "text/plain",
214
+ "bcpio": "application/x-bcpio",
215
+ "bin": "application/octet-stream",
216
+ "bmp": "image/bmp",
217
+ "c": "text/plain",
218
+ "cab": "application/octet-stream",
219
+ "calx": "application/vnd.ms-office.calx",
220
+ "cat": "application/vnd.ms-pki.seccat",
221
+ "cdf": "application/x-cdf",
222
+ "chm": "application/octet-stream",
223
+ "class": "application/x-java-applet",
224
+ "clp": "application/x-msclip",
225
+ "cmx": "image/x-cmx",
226
+ "cnf": "text/plain",
227
+ "cod": "image/cis-cod",
228
+ "cpio": "application/x-cpio",
229
+ "cpp": "text/plain",
230
+ "crd": "application/x-mscardfile",
231
+ "crl": "application/pkix-crl",
232
+ "crt": "application/x-x509-ca-cert",
233
+ "csh": "application/x-csh",
234
+ "css": "text/css",
235
+ "csv": "application/octet-stream",
236
+ "cur": "application/octet-stream",
237
+ "dcr": "application/x-director",
238
+ "deploy": "application/octet-stream",
239
+ "der": "application/x-x509-ca-cert",
240
+ "dib": "image/bmp",
241
+ "dir": "application/x-director",
242
+ "disco": "text/xml",
243
+ "dll": "application/x-msdownload",
244
+ "dll.config": "text/xml",
245
+ "dlm": "text/dlm",
246
+ "doc": "application/msword",
247
+ "docm": "application/vnd.ms-word.document.macroEnabled.12",
248
+ "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
249
+ "dot": "application/msword",
250
+ "dotm": "application/vnd.ms-word.template.macroEnabled.12",
251
+ "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
252
+ "dsp": "application/octet-stream",
253
+ "dtd": "text/xml",
254
+ "dvi": "application/x-dvi",
255
+ "dwf": "drawing/x-dwf",
256
+ "dwp": "application/octet-stream",
257
+ "dxr": "application/x-director",
258
+ "eml": "message/rfc822",
259
+ "emz": "application/octet-stream",
260
+ "eot": "application/octet-stream",
261
+ "eps": "application/postscript",
262
+ "etx": "text/x-setext",
263
+ "evy": "application/envoy",
264
+ "exe": "application/octet-stream",
265
+ "exe.config": "text/xml",
266
+ "fdf": "application/vnd.fdf",
267
+ "fif": "application/fractals",
268
+ "fla": "application/octet-stream",
269
+ "flr": "x-world/x-vrml",
270
+ "flv": "video/x-flv",
271
+ "gif": "image/gif",
272
+ "gtar": "application/x-gtar",
273
+ "gz": "application/x-gzip",
274
+ "h": "text/plain",
275
+ "hdf": "application/x-hdf",
276
+ "hdml": "text/x-hdml",
277
+ "hhc": "application/x-oleobject",
278
+ "hhk": "application/octet-stream",
279
+ "hhp": "application/octet-stream",
280
+ "hlp": "application/winhlp",
281
+ "hqx": "application/mac-binhex40",
282
+ "hta": "application/hta",
283
+ "htc": "text/x-component",
284
+ "htm": "text/html",
285
+ "html": "text/html",
286
+ "htt": "text/webviewhtml",
287
+ "hxt": "text/html",
288
+ "ico": "image/x-icon",
289
+ "ics": "application/octet-stream",
290
+ "ief": "image/ief",
291
+ "iii": "application/x-iphone",
292
+ "inf": "application/octet-stream",
293
+ "ins": "application/x-internet-signup",
294
+ "isp": "application/x-internet-signup",
295
+ "IVF": "video/x-ivf",
296
+ "jar": "application/java-archive",
297
+ "java": "application/octet-stream",
298
+ "jck": "application/liquidmotion",
299
+ "jcz": "application/liquidmotion",
300
+ "jfif": "image/pjpeg",
301
+ "jpb": "application/octet-stream",
302
+ "jpe": "image/jpeg",
303
+ "jpeg": "image/jpeg",
304
+ "jpg": "image/jpeg",
305
+ "js": "application/x-javascript",
306
+ "jsx": "text/jscript",
307
+ "latex": "application/x-latex",
308
+ "lit": "application/x-ms-reader",
309
+ "lpk": "application/octet-stream",
310
+ "lsf": "video/x-la-asf",
311
+ "lsx": "video/x-la-asf",
312
+ "lzh": "application/octet-stream",
313
+ "m13": "application/x-msmediaview",
314
+ "m14": "application/x-msmediaview",
315
+ "m1v": "video/mpeg",
316
+ "m3u": "audio/x-mpegurl",
317
+ "man": "application/x-troff-man",
318
+ "manifest": "application/x-ms-manifest",
319
+ "map": "text/plain",
320
+ "mdb": "application/x-msaccess",
321
+ "mdp": "application/octet-stream",
322
+ "me": "application/x-troff-me",
323
+ "mht": "message/rfc822",
324
+ "mhtml": "message/rfc822",
325
+ "mid": "audio/mid",
326
+ "midi": "audio/mid",
327
+ "mix": "application/octet-stream",
328
+ "mmf": "application/x-smaf",
329
+ "mno": "text/xml",
330
+ "mny": "application/x-msmoney",
331
+ "mov": "video/quicktime",
332
+ "movie": "video/x-sgi-movie",
333
+ "mp2": "video/mpeg",
334
+ "mp3": "audio/mpeg",
335
+ "mpa": "video/mpeg",
336
+ "mpe": "video/mpeg",
337
+ "mpeg": "video/mpeg",
338
+ "mpg": "video/mpeg",
339
+ "mpp": "application/vnd.ms-project",
340
+ "mpv2": "video/mpeg",
341
+ "ms": "application/x-troff-ms",
342
+ "msi": "application/octet-stream",
343
+ "mso": "application/octet-stream",
344
+ "mvb": "application/x-msmediaview",
345
+ "mvc": "application/x-miva-compiled",
346
+ "nc": "application/x-netcdf",
347
+ "nsc": "video/x-ms-asf",
348
+ "nws": "message/rfc822",
349
+ "ocx": "application/octet-stream",
350
+ "oda": "application/oda",
351
+ "odc": "text/x-ms-odc",
352
+ "ods": "application/oleobject",
353
+ "one": "application/onenote",
354
+ "onea": "application/onenote",
355
+ "onetoc": "application/onenote",
356
+ "onetoc2": "application/onenote",
357
+ "onetmp": "application/onenote",
358
+ "onepkg": "application/onenote",
359
+ "osdx": "application/opensearchdescription+xml",
360
+ "p10": "application/pkcs10",
361
+ "p12": "application/x-pkcs12",
362
+ "p7b": "application/x-pkcs7-certificates",
363
+ "p7c": "application/pkcs7-mime",
364
+ "p7m": "application/pkcs7-mime",
365
+ "p7r": "application/x-pkcs7-certreqresp",
366
+ "p7s": "application/pkcs7-signature",
367
+ "pbm": "image/x-portable-bitmap",
368
+ "pcx": "application/octet-stream",
369
+ "pcz": "application/octet-stream",
370
+ "pdf": "application/pdf",
371
+ "pfb": "application/octet-stream",
372
+ "pfm": "application/octet-stream",
373
+ "pfx": "application/x-pkcs12",
374
+ "pgm": "image/x-portable-graymap",
375
+ "pko": "application/vnd.ms-pki.pko",
376
+ "pma": "application/x-perfmon",
377
+ "pmc": "application/x-perfmon",
378
+ "pml": "application/x-perfmon",
379
+ "pmr": "application/x-perfmon",
380
+ "pmw": "application/x-perfmon",
381
+ "png": "image/png",
382
+ "pnm": "image/x-portable-anymap",
383
+ "pnz": "image/png",
384
+ "pot": "application/vnd.ms-powerpoint",
385
+ "potm": "application/vnd.ms-powerpoint.template.macroEnabled.12",
386
+ "potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
387
+ "ppam": "application/vnd.ms-powerpoint.addin.macroEnabled.12",
388
+ "ppm": "image/x-portable-pixmap",
389
+ "pps": "application/vnd.ms-powerpoint",
390
+ "ppsm": "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
391
+ "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
392
+ "ppt": "application/vnd.ms-powerpoint",
393
+ "pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
394
+ "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
395
+ "prf": "application/pics-rules",
396
+ "prm": "application/octet-stream",
397
+ "prx": "application/octet-stream",
398
+ "ps": "application/postscript",
399
+ "psd": "application/octet-stream",
400
+ "psm": "application/octet-stream",
401
+ "psp": "application/octet-stream",
402
+ "pub": "application/x-mspublisher",
403
+ "qt": "video/quicktime",
404
+ "qtl": "application/x-quicktimeplayer",
405
+ "qxd": "application/octet-stream",
406
+ "ra": "audio/x-pn-realaudio",
407
+ "ram": "audio/x-pn-realaudio",
408
+ "rar": "application/octet-stream",
409
+ "ras": "image/x-cmu-raster",
410
+ "rf": "image/vnd.rn-realflash",
411
+ "rgb": "image/x-rgb",
412
+ "rm": "application/vnd.rn-realmedia",
413
+ "rmi": "audio/mid",
414
+ "roff": "application/x-troff",
415
+ "rpm": "audio/x-pn-realaudio-plugin",
416
+ "rtf": "application/rtf",
417
+ "rtx": "text/richtext",
418
+ "scd": "application/x-msschedule",
419
+ "sct": "text/scriptlet",
420
+ "sea": "application/octet-stream",
421
+ "setpay": "application/set-payment-initiation",
422
+ "setreg": "application/set-registration-initiation",
423
+ "sgml": "text/sgml",
424
+ "sh": "application/x-sh",
425
+ "shar": "application/x-shar",
426
+ "sit": "application/x-stuffit",
427
+ "sldm": "application/vnd.ms-powerpoint.slide.macroEnabled.12",
428
+ "sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide",
429
+ "smd": "audio/x-smd",
430
+ "smi": "application/octet-stream",
431
+ "smx": "audio/x-smd",
432
+ "smz": "audio/x-smd",
433
+ "snd": "audio/basic",
434
+ "snp": "application/octet-stream",
435
+ "spc": "application/x-pkcs7-certificates",
436
+ "spl": "application/futuresplash",
437
+ "src": "application/x-wais-source",
438
+ "ssm": "application/streamingmedia",
439
+ "sst": "application/vnd.ms-pki.certstore",
440
+ "stl": "application/vnd.ms-pki.stl",
441
+ "sv4cpio": "application/x-sv4cpio",
442
+ "sv4crc": "application/x-sv4crc",
443
+ "svg": "image/svg+xml",
444
+ "swf": "application/x-shockwave-flash",
445
+ "t": "application/x-troff",
446
+ "tar": "application/x-tar",
447
+ "tcl": "application/x-tcl",
448
+ "tex": "application/x-tex",
449
+ "texi": "application/x-texinfo",
450
+ "texinfo": "application/x-texinfo",
451
+ "tgz": "application/x-compressed",
452
+ "thmx": "application/vnd.ms-officetheme",
453
+ "thn": "application/octet-stream",
454
+ "tif": "image/tiff",
455
+ "tiff": "image/tiff",
456
+ "toc": "application/octet-stream",
457
+ "tr": "application/x-troff",
458
+ "trm": "application/x-msterminal",
459
+ "tsv": "text/tab-separated-values",
460
+ "ttf": "application/octet-stream",
461
+ "txt": "text/plain",
462
+ "u32": "application/octet-stream",
463
+ "uls": "text/iuls",
464
+ "ustar": "application/x-ustar",
465
+ "vbs": "text/vbscript",
466
+ "vcf": "text/x-vcard",
467
+ "vcs": "text/plain",
468
+ "vdx": "application/vnd.ms-visio.viewer",
469
+ "vml": "text/xml",
470
+ "vsd": "application/vnd.visio",
471
+ "vss": "application/vnd.visio",
472
+ "vst": "application/vnd.visio",
473
+ "vsto": "application/x-ms-vsto",
474
+ "vsw": "application/vnd.visio",
475
+ "vsx": "application/vnd.visio",
476
+ "vtx": "application/vnd.visio",
477
+ "wasm": "application/wasm",
478
+ "wav": "audio/wav",
479
+ "wax": "audio/x-ms-wax",
480
+ "wbmp": "image/vnd.wap.wbmp",
481
+ "wcm": "application/vnd.ms-works",
482
+ "wdb": "application/vnd.ms-works",
483
+ "wks": "application/vnd.ms-works",
484
+ "wm": "video/x-ms-wm",
485
+ "wma": "audio/x-ms-wma",
486
+ "wmd": "application/x-ms-wmd",
487
+ "wmf": "application/x-msmetafile",
488
+ "wml": "text/vnd.wap.wml",
489
+ "wmlc": "application/vnd.wap.wmlc",
490
+ "wmls": "text/vnd.wap.wmlscript",
491
+ "wmlsc": "application/vnd.wap.wmlscriptc",
492
+ "wmp": "video/x-ms-wmp",
493
+ "wmv": "video/x-ms-wmv",
494
+ "wmx": "video/x-ms-wmx",
495
+ "wmz": "application/x-ms-wmz",
496
+ "wps": "application/vnd.ms-works",
497
+ "wri": "application/x-mswrite",
498
+ "wrl": "x-world/x-vrml",
499
+ "wrz": "x-world/x-vrml",
500
+ "wsdl": "text/xml",
501
+ "wvx": "video/x-ms-wvx",
502
+ "x": "application/directx",
503
+ "xaf": "x-world/x-vrml",
504
+ "xaml": "application/xaml+xml",
505
+ "xap": "application/x-silverlight-app",
506
+ "xbap": "application/x-ms-xbap",
507
+ "xbm": "image/x-xbitmap",
508
+ "xdr": "text/plain",
509
+ "xht": "application/xhtml+xml",
510
+ "xhtml": "application/xhtml+xml",
511
+ "xla": "application/vnd.ms-excel",
512
+ "xlam": "application/vnd.ms-excel.addin.macroEnabled.12",
513
+ "xlc": "application/vnd.ms-excel",
514
+ "xlm": "application/vnd.ms-excel",
515
+ "xls": "application/vnd.ms-excel",
516
+ "xlsb": "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
517
+ "xlsm": "application/vnd.ms-excel.sheet.macroEnabled.12",
518
+ "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
519
+ "xlt": "application/vnd.ms-excel",
520
+ "xltm": "application/vnd.ms-excel.template.macroEnabled.12",
521
+ "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
522
+ "xlw": "application/vnd.ms-excel",
523
+ "xml": "text/xml",
524
+ "xof": "x-world/x-vrml",
525
+ "xpm": "image/x-xpixmap",
526
+ "xps": "application/vnd.ms-xpsdocument",
527
+ "xsd": "text/xml",
528
+ "xsf": "text/xml",
529
+ "xsl": "text/xml",
530
+ "xslt": "text/xml",
531
+ "xsn": "application/octet-stream",
532
+ "xtp": "application/octet-stream",
533
+ "xwd": "image/x-xwindowdump",
534
+ "z": "application/x-compress",
535
+ "zip": "application/x-zip-compressed"
536
+ ]
537
+ }
538
+
539
+ private var stoppedKey = malloc(1)
540
+
541
+ private extension WKURLSchemeTask {
542
+ var stopped: Bool {
543
+ get {
544
+ return objc_getAssociatedObject(self, &stoppedKey) as? Bool ?? false
545
+ }
546
+ set {
547
+ objc_setAssociatedObject(self, &stoppedKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
548
+ }
549
+ }
550
+ }