@capgo/inappbrowser 8.0.0 → 8.0.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.
Files changed (50) hide show
  1. package/CapgoInappbrowser.podspec +2 -2
  2. package/LICENSE +373 -21
  3. package/Package.swift +28 -0
  4. package/README.md +600 -74
  5. package/android/build.gradle +17 -16
  6. package/android/src/main/AndroidManifest.xml +14 -2
  7. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +952 -204
  8. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +478 -81
  9. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +10 -4
  10. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +3023 -226
  11. package/android/src/main/res/drawable/ic_refresh.xml +9 -0
  12. package/android/src/main/res/drawable/ic_share.xml +10 -0
  13. package/android/src/main/res/layout/activity_browser.xml +10 -0
  14. package/android/src/main/res/layout/content_browser.xml +3 -2
  15. package/android/src/main/res/layout/tool_bar.xml +44 -7
  16. package/android/src/main/res/values/strings.xml +4 -0
  17. package/android/src/main/res/values/themes.xml +27 -0
  18. package/android/src/main/res/xml/file_paths.xml +14 -0
  19. package/dist/docs.json +1289 -149
  20. package/dist/esm/definitions.d.ts +614 -25
  21. package/dist/esm/definitions.js +17 -1
  22. package/dist/esm/definitions.js.map +1 -1
  23. package/dist/esm/index.d.ts +2 -2
  24. package/dist/esm/index.js +4 -4
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/web.d.ts +16 -3
  27. package/dist/esm/web.js +43 -7
  28. package/dist/esm/web.js.map +1 -1
  29. package/dist/plugin.cjs.js +60 -8
  30. package/dist/plugin.cjs.js.map +1 -1
  31. package/dist/plugin.js +60 -8
  32. package/dist/plugin.js.map +1 -1
  33. package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +952 -0
  34. package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +2006 -0
  35. package/package.json +30 -30
  36. package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
  37. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
  38. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
  39. package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
  40. package/ios/Plugin/Assets.xcassets/Contents.json +0 -6
  41. package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
  42. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
  43. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
  44. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
  45. package/ios/Plugin/InAppBrowserPlugin.h +0 -10
  46. package/ios/Plugin/InAppBrowserPlugin.m +0 -17
  47. package/ios/Plugin/InAppBrowserPlugin.swift +0 -203
  48. package/ios/Plugin/Info.plist +0 -24
  49. package/ios/Plugin/WKWebViewController.swift +0 -784
  50. /package/ios/{Plugin → Sources/InAppBrowserPlugin}/Enums.swift +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -10,11 +10,12 @@
10
10
  "android/src/main/",
11
11
  "android/build.gradle",
12
12
  "dist/",
13
- "ios/Plugin/",
13
+ "ios/Sources/",
14
+ "Package.swift",
14
15
  "CapgoInappbrowser.podspec"
15
16
  ],
16
- "author": "Martin Donadieu",
17
- "license": "MIT",
17
+ "author": "Martin Donadieu <martin@capgo.app>",
18
+ "license": "MPL-2.0",
18
19
  "repository": {
19
20
  "type": "git",
20
21
  "url": "git+https://github.com/Cap-go/capacitor-inappbrowser.git"
@@ -30,13 +31,13 @@
30
31
  ],
31
32
  "scripts": {
32
33
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
33
- "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
34
+ "verify:ios": "xcodebuild -scheme CapgoInappbrowser -destination generic/platform=iOS",
34
35
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
35
36
  "verify:web": "npm run build",
36
37
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
37
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
38
- "eslint": "eslint . --ext ts",
39
- "prettier": "prettier --config .prettierrc.js \"**/*.{css,html,ts,js,java}\"",
38
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
39
+ "eslint": "eslint .",
40
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
40
41
  "swiftlint": "node-swiftlint",
41
42
  "docgen": "docgen --api InAppBrowserPlugin --output-readme README.md --output-json dist/docs.json",
42
43
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
@@ -45,34 +46,33 @@
45
46
  "prepublishOnly": "npm run build"
46
47
  },
47
48
  "devDependencies": {
48
- "@capacitor/android": "^5.0.3",
49
- "@capacitor/cli": "^5.0.3",
50
- "@capacitor/core": "^5.0.3",
51
- "@capacitor/docgen": "^0.2.1",
52
- "@capacitor/ios": "^5.0.3",
53
- "@ionic/eslint-config": "^0.3.0",
54
- "@ionic/prettier-config": "^3.0.0",
55
- "@ionic/swiftlint-config": "^1.1.2",
56
- "@typescript-eslint/eslint-plugin": "^5.59.7",
57
- "@typescript-eslint/parser": "^5.59.7",
58
- "eslint": "^8.41.0",
59
- "eslint-plugin-import": "^2.27.5",
60
- "husky": "^8.0.3",
61
- "prettier": "^2.8.8",
62
- "prettier-plugin-java": "^2.1.0",
63
- "rimraf": "^5.0.1",
64
- "rollup": "^3.23.0",
65
- "swiftlint": "^1.0.2",
66
- "typescript": "^5.0.4"
49
+ "@capacitor/android": "^8.0.0",
50
+ "@capacitor/cli": "^8.0.0",
51
+ "@capacitor/core": "^8.0.0",
52
+ "@capacitor/docgen": "^0.3.1",
53
+ "@capacitor/ios": "^8.0.0",
54
+ "@ionic/eslint-config": "^0.4.0",
55
+ "@ionic/prettier-config": "^4.0.0",
56
+ "@ionic/swiftlint-config": "^2.0.0",
57
+ "@types/node": "^24.10.1",
58
+ "eslint": "^8.57.1",
59
+ "eslint-plugin-import": "^2.31.0",
60
+ "husky": "^9.1.7",
61
+ "prettier": "^3.6.2",
62
+ "prettier-plugin-java": "^2.7.7",
63
+ "rimraf": "^6.1.0",
64
+ "rollup": "^4.53.2",
65
+ "swiftlint": "^2.0.0",
66
+ "typescript": "^5.9.3"
67
67
  },
68
68
  "peerDependencies": {
69
- "@capacitor/core": "^5.0.0"
69
+ "@capacitor/core": ">=8.0.0"
70
70
  },
71
- "prettier": "@ionic/prettier-config",
72
- "swiftlint": "@ionic/swiftlint-config",
73
71
  "eslintConfig": {
74
72
  "extends": "@ionic/eslint-config/recommended"
75
73
  },
74
+ "prettier": "@ionic/prettier-config",
75
+ "swiftlint": "@ionic/swiftlint-config",
76
76
  "capacitor": {
77
77
  "ios": {
78
78
  "src": "ios"
@@ -1,26 +0,0 @@
1
- {
2
- "images" : [
3
- {
4
- "idiom" : "universal",
5
- "filename" : "Back.png",
6
- "scale" : "1x"
7
- },
8
- {
9
- "idiom" : "universal",
10
- "filename" : "Back@2x.png",
11
- "scale" : "2x"
12
- },
13
- {
14
- "idiom" : "universal",
15
- "filename" : "Back@3x.png",
16
- "scale" : "3x"
17
- }
18
- ],
19
- "info" : {
20
- "version" : 1,
21
- "author" : "xcode"
22
- },
23
- "properties" : {
24
- "template-rendering-intent" : "template"
25
- }
26
- }
@@ -1,6 +0,0 @@
1
- {
2
- "info" : {
3
- "version" : 1,
4
- "author" : "xcode"
5
- }
6
- }
@@ -1,26 +0,0 @@
1
- {
2
- "images" : [
3
- {
4
- "idiom" : "universal",
5
- "filename" : "Forward.png",
6
- "scale" : "1x"
7
- },
8
- {
9
- "idiom" : "universal",
10
- "filename" : "Forward@2x.png",
11
- "scale" : "2x"
12
- },
13
- {
14
- "idiom" : "universal",
15
- "filename" : "Forward@3x.png",
16
- "scale" : "3x"
17
- }
18
- ],
19
- "info" : {
20
- "version" : 1,
21
- "author" : "xcode"
22
- },
23
- "properties" : {
24
- "template-rendering-intent" : "template"
25
- }
26
- }
@@ -1,10 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- //! Project version number for Plugin.
4
- FOUNDATION_EXPORT double PluginVersionNumber;
5
-
6
- //! Project version string for Plugin.
7
- FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
-
9
- // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
-
@@ -1,17 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <Capacitor/Capacitor.h>
3
-
4
- // Define the plugin using the CAP_PLUGIN Macro, and
5
- // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
- CAP_PLUGIN(InAppBrowserPlugin, "InAppBrowser",
7
- CAP_PLUGIN_METHOD(openWebView, CAPPluginReturnPromise);
8
- CAP_PLUGIN_METHOD(clearCookies, CAPPluginReturnPromise);
9
- CAP_PLUGIN_METHOD(open, CAPPluginReturnPromise);
10
- CAP_PLUGIN_METHOD(setUrl, CAPPluginReturnPromise);
11
- CAP_PLUGIN_METHOD(show, CAPPluginReturnPromise);
12
- CAP_PLUGIN_METHOD(close, CAPPluginReturnPromise);
13
- CAP_PLUGIN_METHOD(hide, CAPPluginReturnPromise);
14
- CAP_PLUGIN_METHOD(executeScript, CAPPluginReturnPromise);
15
- CAP_PLUGIN_METHOD(insertCSS, CAPPluginReturnPromise);
16
- CAP_PLUGIN_METHOD(removeAllListeners, CAPPluginReturnPromise);
17
- )
@@ -1,203 +0,0 @@
1
- import Foundation
2
- import Capacitor
3
-
4
- /**
5
- * Please read the Capacitor iOS Plugin Development Guide
6
- * here: https://capacitorjs.com/docs/plugins/ios
7
- */
8
- @objc(InAppBrowserPlugin)
9
- public class InAppBrowserPlugin: CAPPlugin {
10
- var navigationWebViewController: UINavigationController?
11
- private var privacyScreen: UIImageView?
12
- private var isSetupDone = false
13
- var currentPluginCall: CAPPluginCall?
14
- var isPresentAfterPageLoad = false
15
- var webViewController: WKWebViewController?
16
-
17
- private func setup() {
18
- self.isSetupDone = true
19
-
20
- #if swift(>=4.2)
21
- NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: UIApplication.didBecomeActiveNotification, object: nil)
22
- NotificationCenter.default.addObserver(self, selector: #selector(appWillResignActive(_:)), name: UIApplication.willResignActiveNotification, object: nil)
23
- #else
24
- NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: .UIApplicationDidBecomeActive, object: nil)
25
- NotificationCenter.default.addObserver(self, selector: #selector(appWillResignActive(_:)), name: .UIApplicationWillResignActive, object: nil)
26
- #endif
27
- }
28
-
29
- func presentView() {
30
- self.bridge?.viewController?.present(self.navigationWebViewController!, animated: true, completion: {
31
- self.currentPluginCall?.resolve()
32
- })
33
- }
34
-
35
- func clearCookies() {
36
- HTTPCookieStorage.shared.cookies?.forEach(HTTPCookieStorage.shared.deleteCookie)
37
- }
38
-
39
- @objc func openWebView(_ call: CAPPluginCall) {
40
- if !self.isSetupDone {
41
- self.setup()
42
- }
43
- self.currentPluginCall = call
44
-
45
- guard let urlString = call.getString("url") else {
46
- call.reject("Must provide a URL to open")
47
- return
48
- }
49
-
50
- if urlString.isEmpty {
51
- call.reject("URL must not be empty")
52
- return
53
- }
54
-
55
- let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
56
-
57
- var disclaimerContent = call.getObject("shareDisclaimer")
58
- let toolbarType = call.getString("toolbarType", "")
59
- let backgroundColor = call.getString("backgroundColor", "black") == "white" ? UIColor.white : UIColor.black
60
- if toolbarType != "activity" {
61
- disclaimerContent = nil
62
- }
63
-
64
- self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
65
-
66
- DispatchQueue.main.async {
67
- let url = URL(string: urlString)
68
-
69
- if self.isPresentAfterPageLoad {
70
- self.webViewController = WKWebViewController.init(url: url!, headers: headers)
71
- } else {
72
- self.webViewController = WKWebViewController.init()
73
- self.webViewController?.setHeaders(headers: headers)
74
- }
75
-
76
- self.webViewController?.source = .remote(url!)
77
- self.webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType)
78
- self.webViewController?.toolbarItemTypes = []
79
- self.webViewController?.doneBarButtonItemPosition = .right
80
- self.webViewController?.capBrowserPlugin = self
81
- self.webViewController?.title = call.getString("title", "New Window")
82
- self.webViewController?.shareSubject = call.getString("shareSubject")
83
- self.webViewController?.shareDisclaimer = disclaimerContent
84
- self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
85
- self.navigationWebViewController?.navigationBar.isTranslucent = false
86
- self.navigationWebViewController?.toolbar.isTranslucent = false
87
- self.navigationWebViewController?.navigationBar.backgroundColor = backgroundColor
88
- self.navigationWebViewController?.toolbar.backgroundColor = backgroundColor
89
- self.navigationWebViewController?.modalPresentationStyle = .fullScreen
90
- if toolbarType == "blank" {
91
- self.navigationWebViewController?.navigationBar.isHidden = true
92
- }
93
- if !self.isPresentAfterPageLoad {
94
- self.presentView()
95
- }
96
- }
97
- }
98
-
99
- func getToolbarItems(toolbarType: String) -> [BarButtonItemType] {
100
- var result: [BarButtonItemType] = []
101
- if toolbarType == "activity" {
102
- result.append(.activity)
103
- } else if toolbarType == "navigation" {
104
- result.append(.back)
105
- result.append(.forward)
106
- }
107
- return result
108
- }
109
-
110
- @objc func setUrl(_ call: CAPPluginCall) {
111
- guard let url = call.getString("url") else {
112
- call.reject("Cannot get new url to set")
113
- return
114
- }
115
- self.webViewController?.load(remote: URL(string: url)!)
116
- call.resolve()
117
- }
118
-
119
- @objc func open(_ call: CAPPluginCall) {
120
- if !self.isSetupDone {
121
- self.setup()
122
- }
123
-
124
- self.currentPluginCall = call
125
-
126
- guard let urlString = call.getString("url") else {
127
- call.reject("Must provide a URL to open")
128
- return
129
- }
130
-
131
- if urlString.isEmpty {
132
- call.reject("URL must not be empty")
133
- return
134
- }
135
-
136
- let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
137
-
138
- self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
139
-
140
- DispatchQueue.main.async {
141
- let url = URL(string: urlString)
142
-
143
- if self.isPresentAfterPageLoad {
144
- self.webViewController = WKWebViewController.init(url: url!, headers: headers)
145
- } else {
146
- self.webViewController = WKWebViewController.init()
147
- self.webViewController?.setHeaders(headers: headers)
148
- }
149
-
150
- self.webViewController?.source = .remote(url!)
151
- self.webViewController?.leftNavigaionBarItemTypes = [.reload]
152
- self.webViewController?.toolbarItemTypes = [.back, .forward, .activity]
153
- self.webViewController?.capBrowserPlugin = self
154
- self.webViewController?.hasDynamicTitle = true
155
- self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
156
- self.navigationWebViewController?.navigationBar.isTranslucent = false
157
- self.navigationWebViewController?.toolbar.isTranslucent = false
158
- self.navigationWebViewController?.navigationBar.backgroundColor = .white
159
- self.navigationWebViewController?.toolbar.backgroundColor = .white
160
- self.navigationWebViewController?.modalPresentationStyle = .fullScreen
161
- if !self.isPresentAfterPageLoad {
162
- self.presentView()
163
- }
164
- }
165
- }
166
-
167
- @objc func close(_ call: CAPPluginCall) {
168
- DispatchQueue.main.async {
169
- self.navigationWebViewController?.dismiss(animated: true, completion: nil)
170
- call.resolve()
171
- }
172
- }
173
-
174
- private func showPrivacyScreen() {
175
- if privacyScreen == nil {
176
- self.privacyScreen = UIImageView()
177
- if let launchImage = UIImage(named: "LaunchImage") {
178
- privacyScreen!.image = launchImage
179
- privacyScreen!.frame = UIScreen.main.bounds
180
- privacyScreen!.contentMode = .scaleAspectFill
181
- privacyScreen!.isUserInteractionEnabled = false
182
- } else if let launchImage = UIImage(named: "Splash") {
183
- privacyScreen!.image = launchImage
184
- privacyScreen!.frame = UIScreen.main.bounds
185
- privacyScreen!.contentMode = .scaleAspectFill
186
- privacyScreen!.isUserInteractionEnabled = false
187
- }
188
- }
189
- self.navigationWebViewController?.view.addSubview(self.privacyScreen!)
190
- }
191
-
192
- private func hidePrivacyScreen() {
193
- self.privacyScreen?.removeFromSuperview()
194
- }
195
-
196
- @objc func appDidBecomeActive(_ notification: NSNotification) {
197
- self.hidePrivacyScreen()
198
- }
199
-
200
- @objc func appWillResignActive(_ notification: NSNotification) {
201
- self.showPrivacyScreen()
202
- }
203
- }
@@ -1,24 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>$(DEVELOPMENT_LANGUAGE)</string>
7
- <key>CFBundleExecutable</key>
8
- <string>$(EXECUTABLE_NAME)</string>
9
- <key>CFBundleIdentifier</key>
10
- <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
- <key>CFBundleInfoDictionaryVersion</key>
12
- <string>6.0</string>
13
- <key>CFBundleName</key>
14
- <string>$(PRODUCT_NAME)</string>
15
- <key>CFBundlePackageType</key>
16
- <string>FMWK</string>
17
- <key>CFBundleShortVersionString</key>
18
- <string>1.0</string>
19
- <key>CFBundleVersion</key>
20
- <string>$(CURRENT_PROJECT_VERSION)</string>
21
- <key>NSPrincipalClass</key>
22
- <string></string>
23
- </dict>
24
- </plist>