@capacitor-community/camera-preview 5.0.0-0 → 5.0.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 (100) hide show
  1. package/README.md +19 -13
  2. package/android/.gradle/8.0.2/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.0.2/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/8.0.2/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/8.0.2/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/8.0.2/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/8.0.2/fileHashes/fileHashes.bin +0 -0
  8. package/android/.gradle/8.0.2/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/8.0.2/fileHashes/resourceHashesCache.bin +0 -0
  10. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  11. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  12. package/android/.gradle/file-system.probe +0 -0
  13. package/android/build.gradle +3 -2
  14. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +3 -3
  15. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +5 -7
  16. package/dist/esm/definitions.d.ts +2 -0
  17. package/dist/esm/index.d.ts +1 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/web.d.ts +3 -3
  20. package/dist/esm/web.js +14 -10
  21. package/dist/esm/web.js.map +1 -1
  22. package/dist/plugin.cjs.js +155 -0
  23. package/dist/plugin.cjs.js.map +1 -0
  24. package/dist/plugin.js +158 -0
  25. package/dist/plugin.js.map +1 -0
  26. package/ios/Plugin/CameraController.swift +1 -1
  27. package/ios/Plugin/Plugin.swift +5 -5
  28. package/ios/Podfile +7 -4
  29. package/ios/Podfile.lock +9 -10
  30. package/ios/Pods/CapacitorCordova/LICENSE +23 -0
  31. package/ios/Pods/CapacitorCordova/README.md +39 -0
  32. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +21 -0
  33. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.h +8 -0
  34. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.m +5 -0
  35. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h +28 -0
  36. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVAvailability.h +109 -0
  37. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h +51 -0
  38. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.h +39 -0
  39. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m +154 -0
  40. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.h +31 -0
  41. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.m +81 -0
  42. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.h +52 -0
  43. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.m +116 -0
  44. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.h +81 -0
  45. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.m +154 -0
  46. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.h +25 -0
  47. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.m +77 -0
  48. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.h +82 -0
  49. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m +216 -0
  50. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
  51. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUIWebViewDelegate.h +41 -0
  52. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUIWebViewDelegate.m +399 -0
  53. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.h +27 -0
  54. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.m +74 -0
  55. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUserAgentUtil.h +27 -0
  56. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUserAgentUtil.m +156 -0
  57. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.h +30 -0
  58. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m +34 -0
  59. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
  60. package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
  61. package/ios/Pods/Local Podspecs/Capacitor.podspec.json +34 -0
  62. package/ios/Pods/Local Podspecs/CapacitorCordova.podspec.json +26 -0
  63. package/ios/Pods/Manifest.lock +22 -0
  64. package/ios/Pods/Pods.xcodeproj/project.pbxproj +1374 -0
  65. package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Capacitor.xcscheme +58 -0
  66. package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +58 -0
  67. package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +58 -0
  68. package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +58 -0
  69. package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
  70. package/ios/Pods/Target Support Files/Capacitor/Capacitor-Info.plist +26 -0
  71. package/ios/Pods/Target Support Files/Capacitor/Capacitor-dummy.m +5 -0
  72. package/ios/Pods/Target Support Files/Capacitor/Capacitor-prefix.pch +12 -0
  73. package/ios/Pods/Target Support Files/Capacitor/Capacitor.debug.xcconfig +15 -0
  74. package/ios/Pods/Target Support Files/Capacitor/Capacitor.modulemap +8 -0
  75. package/ios/Pods/Target Support Files/Capacitor/Capacitor.release.xcconfig +15 -0
  76. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-Info.plist +26 -0
  77. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-dummy.m +5 -0
  78. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-prefix.pch +12 -0
  79. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-umbrella.h +32 -0
  80. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.debug.xcconfig +12 -0
  81. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.modulemap +6 -0
  82. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.release.xcconfig +12 -0
  83. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-Info.plist +26 -0
  84. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.markdown +53 -0
  85. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.plist +91 -0
  86. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-dummy.m +5 -0
  87. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-umbrella.h +16 -0
  88. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig +14 -0
  89. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.modulemap +6 -0
  90. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig +14 -0
  91. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-Info.plist +26 -0
  92. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.markdown +53 -0
  93. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.plist +91 -0
  94. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-dummy.m +5 -0
  95. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh +188 -0
  96. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-umbrella.h +16 -0
  97. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig +15 -0
  98. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.modulemap +6 -0
  99. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.release.xcconfig +15 -0
  100. package/package.json +17 -7
@@ -0,0 +1,25 @@
1
+ //
2
+ // CDVPluginManager.h
3
+ // CapacitorCordova
4
+ //
5
+ // Created by Julio Cesar Sanchez Hernandez on 26/2/18.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "CDVPlugin.h"
10
+ #import "CDVConfigParser.h"
11
+ #import "CDVCommandDelegate.h"
12
+
13
+ @interface CDVPluginManager : NSObject
14
+
15
+ @property (nonatomic, strong) NSMutableDictionary * pluginsMap;
16
+ @property (nonatomic, strong) NSMutableDictionary * pluginObjects;
17
+ @property (nonatomic, strong) NSMutableDictionary * settings;
18
+ @property (nonatomic, strong) UIViewController * viewController;
19
+ @property (nonatomic, strong) WKWebView * webView;
20
+ @property (nonatomic, strong) id <CDVCommandDelegate> commandDelegate;
21
+
22
+ - (id)initWithParser:(CDVConfigParser*)parser viewController:(UIViewController*)viewController webView:(WKWebView *)webview;
23
+ - (CDVPlugin *)getCommandInstance:(NSString*)pluginName;
24
+
25
+ @end
@@ -0,0 +1,77 @@
1
+ #import "CDVPluginManager.h"
2
+ #import "CDVPlugin.h"
3
+ #import "CDVCommandDelegateImpl.h"
4
+
5
+ @implementation CDVPluginManager
6
+
7
+ - (id)initWithParser:(CDVConfigParser*)parser viewController:(UIViewController*)viewController webView:(WKWebView *)webview
8
+ {
9
+ self = [super init];
10
+ if (self != nil) {
11
+ _pluginsMap = parser.pluginsDict;
12
+ _settings = parser.settings;
13
+ _viewController = viewController;
14
+ _webView = webview;
15
+ _pluginObjects = [[NSMutableDictionary alloc] init];
16
+ _commandDelegate = [[CDVCommandDelegateImpl alloc] initWithWebView:_webView pluginManager:self];
17
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:)
18
+ name:UIApplicationDidEnterBackgroundNotification object:nil];
19
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillEnterForeground:)
20
+ name:UIApplicationWillEnterForegroundNotification object:nil];
21
+ }
22
+ return self;
23
+ }
24
+
25
+ /**
26
+ Returns an instance of a CordovaCommand object, based on its name. If one exists already, it is returned.
27
+ */
28
+ - (CDVPlugin *)getCommandInstance:(NSString*)pluginName
29
+ {
30
+ NSString* className = [self.pluginsMap objectForKey:[pluginName lowercaseString]];
31
+
32
+ if (className == nil) {
33
+ return nil;
34
+ }
35
+
36
+ id obj = [self.pluginObjects objectForKey:className];
37
+ if (!obj) {
38
+ obj = [[NSClassFromString(className)alloc] init];
39
+ if (!obj) {
40
+ NSString* fullClassName = [NSString stringWithFormat:@"%@.%@",
41
+ NSBundle.mainBundle.infoDictionary[@"CFBundleExecutable"],
42
+ className];
43
+ obj = [[NSClassFromString(fullClassName)alloc] init];
44
+ }
45
+
46
+ if (obj != nil) {
47
+ [self registerPlugin:obj withClassName:className];
48
+ } else {
49
+ NSLog(@"CDVPlugin class %@ (pluginName: %@) does not exist.", className, pluginName);
50
+ }
51
+ }
52
+ [obj setClassName:className];
53
+
54
+ return obj;
55
+ }
56
+
57
+
58
+ - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
59
+ {
60
+ [self.pluginObjects setObject:plugin forKey:className];
61
+ plugin.viewController = self.viewController;
62
+ plugin.webView = self.webView;
63
+ plugin.commandDelegate = self.commandDelegate;
64
+ [plugin pluginInitialize];
65
+ }
66
+
67
+ - (void)onAppDidEnterBackground:(NSNotification*)notification
68
+ {
69
+ [self.commandDelegate evalJsHelper2:@"window.Capacitor.triggerEvent('pause', 'document');"];
70
+ }
71
+
72
+ - (void)onAppWillEnterForeground:(NSNotification*)notification
73
+ {
74
+ [self.commandDelegate evalJsHelper2:@"window.Capacitor.triggerEvent('resume', 'document');"];
75
+ }
76
+
77
+ @end
@@ -0,0 +1,82 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import <Foundation/Foundation.h>
21
+
22
+ typedef NS_ENUM(NSUInteger, CDVCommandStatus) {
23
+ CDVCommandStatus_NO_RESULT NS_SWIFT_NAME(noResult) = 0,
24
+ CDVCommandStatus_OK NS_SWIFT_NAME(ok),
25
+ CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION NS_SWIFT_NAME(classNotFoundException),
26
+ CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION NS_SWIFT_NAME(illegalAccessException),
27
+ CDVCommandStatus_INSTANTIATION_EXCEPTION NS_SWIFT_NAME(instantiationException),
28
+ CDVCommandStatus_MALFORMED_URL_EXCEPTION NS_SWIFT_NAME(malformedUrlException),
29
+ CDVCommandStatus_IO_EXCEPTION NS_SWIFT_NAME(ioException),
30
+ CDVCommandStatus_INVALID_ACTION NS_SWIFT_NAME(invalidAction),
31
+ CDVCommandStatus_JSON_EXCEPTION NS_SWIFT_NAME(jsonException),
32
+ CDVCommandStatus_ERROR NS_SWIFT_NAME(error)
33
+ };
34
+
35
+ // This exists to preserve compatibility with early Swift plugins, who are
36
+ // using CDVCommandStatus as ObjC-style constants rather than as Swift enum
37
+ // values.
38
+ // This declares extern'ed constants (implemented in CDVPluginResult.m)
39
+ #define SWIFT_ENUM_COMPAT_HACK(enumVal) extern const CDVCommandStatus SWIFT_##enumVal NS_SWIFT_NAME(enumVal)
40
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_NO_RESULT);
41
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_OK);
42
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION);
43
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION);
44
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_INSTANTIATION_EXCEPTION);
45
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_MALFORMED_URL_EXCEPTION);
46
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_IO_EXCEPTION);
47
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_INVALID_ACTION);
48
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_JSON_EXCEPTION);
49
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_ERROR);
50
+ #undef SWIFT_ENUM_COMPAT_HACK
51
+
52
+ @interface CDVPluginResult : NSObject {}
53
+
54
+ @property (nonatomic, strong, readonly) NSNumber* status;
55
+ @property (nonatomic, strong, readonly) id message;
56
+ @property (nonatomic, strong) NSNumber* keepCallback;
57
+ // This property can be used to scope the lifetime of another object. For example,
58
+ // Use it to store the associated NSData when `message` is created using initWithBytesNoCopy.
59
+ @property (nonatomic, strong) id associatedObject;
60
+
61
+ - (CDVPluginResult*)init;
62
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal;
63
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage;
64
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage;
65
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage;
66
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSInteger:(NSInteger)theMessage;
67
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)theMessage;
68
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage;
69
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage;
70
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage;
71
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage;
72
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages;
73
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode;
74
+
75
+ + (void)setVerbose:(BOOL)verbose;
76
+ + (BOOL)isVerbose;
77
+
78
+ - (void)setKeepCallbackAsBool:(BOOL)bKeepCallback;
79
+
80
+ - (NSString*)argumentsAsJSON;
81
+
82
+ @end
@@ -0,0 +1,216 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import "CDVPluginResult.h"
21
+
22
+ // This exists to preserve compatibility with early Swift plugins, who are
23
+ // using CDVCommandStatus as ObjC-style constants rather than as Swift enum
24
+ // values.
25
+ // These constants alias the enum values back to their previous names.
26
+ #define SWIFT_ENUM_COMPAT_HACK(enumVal) const CDVCommandStatus SWIFT_##enumVal NS_SWIFT_NAME(enumVal) = enumVal
27
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_NO_RESULT);
28
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_OK);
29
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION);
30
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION);
31
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_INSTANTIATION_EXCEPTION);
32
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_MALFORMED_URL_EXCEPTION);
33
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_IO_EXCEPTION);
34
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_INVALID_ACTION);
35
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_JSON_EXCEPTION);
36
+ SWIFT_ENUM_COMPAT_HACK(CDVCommandStatus_ERROR);
37
+ #undef SWIFT_ENUM_COMPAT_HACK
38
+
39
+ @interface CDVPluginResult ()
40
+
41
+ - (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage;
42
+
43
+ @end
44
+
45
+ @implementation CDVPluginResult
46
+ @synthesize status, message, keepCallback, associatedObject;
47
+
48
+ static NSArray* org_apache_cordova_CommandStatusMsgs;
49
+
50
+ id messageFromArrayBuffer(NSData* data)
51
+ {
52
+ return @{
53
+ @"CDVType" : @"ArrayBuffer",
54
+ @"data" :[data base64EncodedStringWithOptions:0]
55
+ };
56
+ }
57
+
58
+ id massageMessage(id message)
59
+ {
60
+ if ([message isKindOfClass:[NSData class]]) {
61
+ return messageFromArrayBuffer(message);
62
+ }
63
+ return message;
64
+ }
65
+
66
+ id messageFromMultipart(NSArray* theMessages)
67
+ {
68
+ NSMutableArray* messages = [NSMutableArray arrayWithArray:theMessages];
69
+
70
+ for (NSUInteger i = 0; i < messages.count; ++i) {
71
+ [messages replaceObjectAtIndex:i withObject:massageMessage([messages objectAtIndex:i])];
72
+ }
73
+
74
+ return @{
75
+ @"CDVType" : @"MultiPart",
76
+ @"messages" : messages
77
+ };
78
+ }
79
+
80
+ + (void)initialize
81
+ {
82
+ org_apache_cordova_CommandStatusMsgs = [[NSArray alloc] initWithObjects:@"No result",
83
+ @"OK",
84
+ @"Class not found",
85
+ @"Illegal access",
86
+ @"Instantiation error",
87
+ @"Malformed url",
88
+ @"IO error",
89
+ @"Invalid action",
90
+ @"JSON error",
91
+ @"Error",
92
+ nil];
93
+ }
94
+
95
+ - (CDVPluginResult*)init
96
+ {
97
+ return [self initWithStatus:CDVCommandStatus_NO_RESULT message:nil];
98
+ }
99
+
100
+ - (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage
101
+ {
102
+ self = [super init];
103
+ if (self) {
104
+ status = [NSNumber numberWithInt:statusOrdinal];
105
+ message = theMessage;
106
+ keepCallback = [NSNumber numberWithBool:NO];
107
+ }
108
+ return self;
109
+ }
110
+
111
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal
112
+ {
113
+ return [[self alloc] initWithStatus:statusOrdinal message:nil];
114
+ }
115
+
116
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage
117
+ {
118
+ return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
119
+ }
120
+
121
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage
122
+ {
123
+ return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
124
+ }
125
+
126
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage
127
+ {
128
+ return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInt:theMessage]];
129
+ }
130
+
131
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSInteger:(NSInteger)theMessage
132
+ {
133
+ return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInteger:theMessage]];
134
+ }
135
+
136
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)theMessage
137
+ {
138
+ return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithUnsignedInteger:theMessage]];
139
+ }
140
+
141
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage
142
+ {
143
+ return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithDouble:theMessage]];
144
+ }
145
+
146
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage
147
+ {
148
+ return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithBool:theMessage]];
149
+ }
150
+
151
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage
152
+ {
153
+ return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
154
+ }
155
+
156
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage
157
+ {
158
+ return [[self alloc] initWithStatus:statusOrdinal message:messageFromArrayBuffer(theMessage)];
159
+ }
160
+
161
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages
162
+ {
163
+ return [[self alloc] initWithStatus:statusOrdinal message:messageFromMultipart(theMessages)];
164
+ }
165
+
166
+ + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode
167
+ {
168
+ NSDictionary* errDict = @{@"code" :[NSNumber numberWithInt:errorCode]};
169
+
170
+ return [[self alloc] initWithStatus:statusOrdinal message:errDict];
171
+ }
172
+
173
+ - (void)setKeepCallbackAsBool:(BOOL)bKeepCallback
174
+ {
175
+ [self setKeepCallback:[NSNumber numberWithBool:bKeepCallback]];
176
+ }
177
+
178
+ - (NSString*)argumentsAsJSON
179
+ {
180
+ id arguments = (self.message == nil ? [NSNull null] : self.message);
181
+ NSArray* argumentsWrappedInArray = [NSArray arrayWithObject:arguments];
182
+
183
+ NSString* argumentsJSON = [self JSONStringFromArray:argumentsWrappedInArray];
184
+
185
+ argumentsJSON = [argumentsJSON substringWithRange:NSMakeRange(1, [argumentsJSON length] - 2)];
186
+
187
+ return argumentsJSON;
188
+ }
189
+
190
+ static BOOL gIsVerbose = NO;
191
+ + (void)setVerbose:(BOOL)verbose
192
+ {
193
+ gIsVerbose = verbose;
194
+ }
195
+
196
+ + (BOOL)isVerbose
197
+ {
198
+ return gIsVerbose;
199
+ }
200
+
201
+ - (NSString*)JSONStringFromArray:(NSArray *) array
202
+ {
203
+ NSError* error = nil;
204
+ NSData* jsonData = [NSJSONSerialization dataWithJSONObject:array
205
+ options:0
206
+ error:&error];
207
+
208
+ if (error != nil) {
209
+ NSLog(@"NSArray JSONString error: %@", [error localizedDescription]);
210
+ return nil;
211
+ } else {
212
+ return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
213
+ }
214
+ }
215
+
216
+ @end
@@ -0,0 +1,33 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import <Foundation/Foundation.h>
21
+
22
+ @protocol CDVScreenOrientationDelegate <NSObject>
23
+
24
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
25
+ - (NSUInteger)supportedInterfaceOrientations;
26
+ #else
27
+ - (UIInterfaceOrientationMask)supportedInterfaceOrientations;
28
+ #endif
29
+
30
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
31
+ - (BOOL)shouldAutorotate;
32
+
33
+ @end
@@ -0,0 +1,41 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import <UIKit/UIKit.h>
21
+ #import "CDVAvailability.h"
22
+
23
+ /**
24
+ * Distinguishes top-level navigations from sub-frame navigations.
25
+ * shouldStartLoadWithRequest is called for every request, but didStartLoad
26
+ * and didFinishLoad is called only for top-level navigations.
27
+ * Relevant bug: CB-2389
28
+ */
29
+ @interface CDVUIWebViewDelegate : NSObject <UIWebViewDelegate>{
30
+ __weak NSObject <UIWebViewDelegate>* _delegate;
31
+ NSInteger _loadCount;
32
+ NSInteger _state;
33
+ NSInteger _curLoadToken;
34
+ NSInteger _loadStartPollCount;
35
+ }
36
+
37
+ - (id)initWithDelegate:(NSObject <UIWebViewDelegate>*)delegate;
38
+
39
+ - (BOOL)request:(NSURLRequest*)newRequest isEqualToRequestAfterStrippingFragments:(NSURLRequest*)originalRequest;
40
+
41
+ @end