expo-web-browser 15.0.11-canary-20251210-1f163e3 → 15.0.11-canary-20251212-acb11f2

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 (46) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/android/build.gradle +2 -2
  3. package/expo-module.config.json +1 -1
  4. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.module → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.module} +7 -7
  5. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.module.md5 +1 -0
  6. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.module.sha1 +1 -0
  7. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.module.sha256 +1 -0
  8. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.module.sha512 +1 -0
  9. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.pom → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.pom} +1 -1
  10. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.pom.md5 +1 -0
  11. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.pom.sha1 +1 -0
  12. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.pom.sha256 +1 -0
  13. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.pom.sha512 +1 -0
  14. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/maven-metadata.xml +4 -4
  15. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/maven-metadata.xml.md5 +1 -1
  16. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/maven-metadata.xml.sha1 +1 -1
  17. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/maven-metadata.xml.sha256 +1 -1
  18. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/maven-metadata.xml.sha512 +1 -1
  19. package/package.json +4 -3
  20. package/plugin/build/withWebBrowser.d.ts +3 -1
  21. package/plugin/build/withWebBrowser.js +3 -6
  22. package/plugin/src/withWebBrowser.ts +8 -7
  23. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.module.md5 +0 -1
  24. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.module.sha1 +0 -1
  25. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.module.sha256 +0 -1
  26. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.module.sha512 +0 -1
  27. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.pom.md5 +0 -1
  28. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.pom.sha1 +0 -1
  29. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.pom.sha256 +0 -1
  30. package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.pom.sha512 +0 -1
  31. package/plugin/build/utils.d.ts +0 -9
  32. package/plugin/build/utils.js +0 -98
  33. package/plugin/build/withWebBrowserAndroid.d.ts +0 -5
  34. package/plugin/build/withWebBrowserAndroid.js +0 -128
  35. package/plugin/src/utils.ts +0 -113
  36. package/plugin/src/withWebBrowserAndroid.ts +0 -166
  37. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar} +0 -0
  38. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar.md5 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar.md5} +0 -0
  39. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar.sha1 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar.sha1} +0 -0
  40. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar.sha256 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar.sha256} +0 -0
  41. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar.sha512 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar.sha512} +0 -0
  42. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar} +0 -0
  43. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar.md5 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar.md5} +0 -0
  44. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar.sha1 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar.sha1} +0 -0
  45. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar.sha256 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar.sha256} +0 -0
  46. /package/local-maven-repo/host/exp/exponent/expo.modules.webbrowser/{15.0.11-canary-20251210-1f163e3/expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar.sha512 → 15.0.11-canary-20251212-acb11f2/expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,7 +10,9 @@
10
10
 
11
11
  - [Android] Fix the browser closing after the app is backgrounded by adding a new option to use a proxy activity to launch custom tabs. ([#41457](https://github.com/expo/expo/pull/41457) by [@lukmccall](https://github.com/lukmccall))
12
12
 
13
- ### 💡 Others
13
+ ### 💡 Others
14
+
15
+ - [Android] Remove `experimentalLauncherActivity` config plugin option as it was replaced with the `useProxyActivity` option on `openBrowserAsync` and `openAuthSessionAsync` methods. ([#41535](https://github.com/expo/expo/pull/41535) by [@lukmccall](https://github.com/lukmccall))
14
16
 
15
17
  ## 15.0.10 - 2025-12-05
16
18
 
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '15.0.11-canary-20251210-1f163e3'
7
+ version = '15.0.11-canary-20251212-acb11f2'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.webbrowser"
11
11
  defaultConfig {
12
12
  versionCode 18
13
- versionName '15.0.11-canary-20251210-1f163e3'
13
+ versionName '15.0.11-canary-20251212-acb11f2'
14
14
  }
15
15
  }
16
16
 
@@ -8,7 +8,7 @@
8
8
  "publication": {
9
9
  "groupId": "host.exp.exponent",
10
10
  "artifactId": "expo.modules.webbrowser",
11
- "version": "15.0.11-canary-20251210-1f163e3",
11
+ "version": "15.0.11-canary-20251212-acb11f2",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.webbrowser",
6
- "version": "15.0.11-canary-20251210-1f163e3",
6
+ "version": "15.0.11-canary-20251212-acb11f2",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar",
28
- "url": "expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar",
27
+ "name": "expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar",
28
+ "url": "expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar",
29
29
  "size": 47915,
30
30
  "sha512": "aca79a51b71120142b71d86145b797ac9f79cabcb828363d6360033352ad5bd7d9b059aca87d926134c26cf2216fc1dd1c6d40a2665d64c2ab4fefb55f23aa82",
31
31
  "sha256": "58b8e61082aedada6f2a6f2fd5c4db4f2fb55c1a501277c6e78a443d67e1ce7e",
@@ -67,8 +67,8 @@
67
67
  ],
68
68
  "files": [
69
69
  {
70
- "name": "expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar",
71
- "url": "expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3.aar",
70
+ "name": "expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar",
71
+ "url": "expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2.aar",
72
72
  "size": 47915,
73
73
  "sha512": "aca79a51b71120142b71d86145b797ac9f79cabcb828363d6360033352ad5bd7d9b059aca87d926134c26cf2216fc1dd1c6d40a2665d64c2ab4fefb55f23aa82",
74
74
  "sha256": "58b8e61082aedada6f2a6f2fd5c4db4f2fb55c1a501277c6e78a443d67e1ce7e",
@@ -87,8 +87,8 @@
87
87
  },
88
88
  "files": [
89
89
  {
90
- "name": "expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar",
91
- "url": "expo.modules.webbrowser-15.0.11-canary-20251210-1f163e3-sources.jar",
90
+ "name": "expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar",
91
+ "url": "expo.modules.webbrowser-15.0.11-canary-20251212-acb11f2-sources.jar",
92
92
  "size": 8169,
93
93
  "sha512": "076da63f70370cb210d0ce7fd9144f1706f75f9023e46d085c8aae046179aea53884cb0029d7a46b305a91594d4f7e0b2de49da36f94b6a6354388bc9c25f3c2",
94
94
  "sha256": "a8f81a06ac9192351958fded7442498bb32dd54eea11e31046c909bc7230ec03",
@@ -0,0 +1 @@
1
+ 94942492d081b59677f611a8778d62433041843080f204780b467d7b7d81b6a12f6c715deb1d8e41147cb8dd440047a27dd34d45931ba02377e9b8ed156831b2
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.webbrowser</artifactId>
12
- <version>15.0.11-canary-20251210-1f163e3</version>
12
+ <version>15.0.11-canary-20251212-acb11f2</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.webbrowser</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 3e49b627497c007d4d5f16efcc700b0ae5b414bc80ad846661067724b7efbded7b79d5d9f75d7673e3e37e1122b3d0f6499b7d4c234317d19375e0e123013897
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.webbrowser</artifactId>
5
5
  <versioning>
6
- <latest>15.0.11-canary-20251210-1f163e3</latest>
7
- <release>15.0.11-canary-20251210-1f163e3</release>
6
+ <latest>15.0.11-canary-20251212-acb11f2</latest>
7
+ <release>15.0.11-canary-20251212-acb11f2</release>
8
8
  <versions>
9
- <version>15.0.11-canary-20251210-1f163e3</version>
9
+ <version>15.0.11-canary-20251212-acb11f2</version>
10
10
  </versions>
11
- <lastUpdated>20251210173244</lastUpdated>
11
+ <lastUpdated>20251212085705</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 9a34336b2a5cfaea21142f45e6bee021
1
+ 4f3133e55295d638c12208e9426d9171
@@ -1 +1 @@
1
- 21559e89486ddb73baba754172aa081f7c0c408f
1
+ ef4e1f95effffff1cec71199bd3dd5abfe14533c
@@ -1 +1 @@
1
- 2713b7d339a55b31afc145612e0adafbef9c6024d6f11a540e5cd952f4233c54
1
+ 16a8a89d9c06ec8b3785441e8fcb66adb8e833e08a593fd6cecdd7d7fb684651
@@ -1 +1 @@
1
- d9e454af833cf05e98364f4687867cbc6626deea006aceeeb47a34fa5d8fcdf8a357a2e04744762c7b7e6a30d8942f6b5dba547caf36acffb742a01d08df49da
1
+ 21e71f5785c5b1bceafbeb929c0e0da7b30693088907520a347cefe56549f1d0473668ef43e46549ca206bfdbb51f504b8f562ac1a73c038807e6533378b7866
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "expo-web-browser",
3
- "version": "15.0.11-canary-20251210-1f163e3",
3
+ "version": "15.0.11-canary-20251212-acb11f2",
4
4
  "description": "Provides access to the system's web browser and supports handling redirects. On iOS, it uses SFSafariViewController or ASWebAuthenticationSession, depending on the method you call, and on Android it uses ChromeCustomTabs. As of iOS 11, SFSafariViewController no longer shares cookies with Safari, so if you are using WebBrowser for authentication you will want to use WebBrowser.openAuthSessionAsync, and if you just want to open a webpage (such as your app privacy policy), then use WebBrowser.openBrowserAsync.",
5
5
  "main": "build/WebBrowser.js",
6
6
  "types": "build/WebBrowser.d.ts",
7
7
  "sideEffects": false,
8
8
  "scripts": {
9
9
  "build": "expo-module build",
10
+ "build:plugin": "expo-module build plugin",
10
11
  "clean": "expo-module clean",
11
12
  "lint": "expo-module lint",
12
13
  "test": "expo-module test",
@@ -36,10 +37,10 @@
36
37
  "preset": "expo-module-scripts"
37
38
  },
38
39
  "devDependencies": {
39
- "expo-module-scripts": "5.1.0-canary-20251210-1f163e3"
40
+ "expo-module-scripts": "5.1.0-canary-20251212-acb11f2"
40
41
  },
41
42
  "peerDependencies": {
42
- "expo": "55.0.0-canary-20251210-1f163e3",
43
+ "expo": "55.0.0-canary-20251212-acb11f2",
43
44
  "react-native": "*"
44
45
  }
45
46
  }
@@ -1,4 +1,6 @@
1
1
  import { ConfigPlugin } from 'expo/config-plugins';
2
- import { PluginConfig } from './withWebBrowserAndroid';
2
+ type PluginConfig = {
3
+ experimentalLauncherActivity?: boolean;
4
+ };
3
5
  declare const _default: ConfigPlugin<PluginConfig | null>;
4
6
  export default _default;
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_plugins_1 = require("expo/config-plugins");
4
- const withWebBrowserAndroid_1 = require("./withWebBrowserAndroid");
5
4
  const pkg = require('expo-web-browser/package.json');
6
5
  const withWebBrowser = (config, props) => {
7
- if (!props) {
6
+ if (props?.experimentalLauncherActivity) {
7
+ console.warn('The `experimentalLauncherActivity` option has been removed. To achieve similar behaviour, set both `createTask` and `useProxyActivity` to true when using `openBrowserAsync` or `openAuthSessionAsync`.');
8
8
  return config;
9
9
  }
10
- if (!props.experimentalLauncherActivity) {
11
- return config;
12
- }
13
- return (0, withWebBrowserAndroid_1.withWebBrowserAndroid)(config);
10
+ return config;
14
11
  };
15
12
  exports.default = (0, config_plugins_1.createRunOncePlugin)(withWebBrowser, pkg.name, pkg.version);
@@ -1,19 +1,20 @@
1
1
  import { ConfigPlugin, createRunOncePlugin } from 'expo/config-plugins';
2
2
 
3
- import { withWebBrowserAndroid, PluginConfig } from './withWebBrowserAndroid';
3
+ type PluginConfig = {
4
+ experimentalLauncherActivity?: boolean;
5
+ };
4
6
 
5
7
  const pkg = require('expo-web-browser/package.json');
6
8
 
7
9
  const withWebBrowser: ConfigPlugin<PluginConfig | null> = (config, props) => {
8
- if (!props) {
9
- return config;
10
- }
11
-
12
- if (!props.experimentalLauncherActivity) {
10
+ if (props?.experimentalLauncherActivity) {
11
+ console.warn(
12
+ 'The `experimentalLauncherActivity` option has been removed. To achieve similar behaviour, set both `createTask` and `useProxyActivity` to true when using `openBrowserAsync` or `openAuthSessionAsync`.'
13
+ );
13
14
  return config;
14
15
  }
15
16
 
16
- return withWebBrowserAndroid(config);
17
+ return config;
17
18
  };
18
19
 
19
20
  export default createRunOncePlugin(withWebBrowser, pkg.name, pkg.version);
@@ -1 +0,0 @@
1
- 8d8a880feea2feff11f0f5d20e85dea9650b2252aeb75200ad1f3203884f6cb87d3c3601d2d36ac4a03054fd1e57cab317a24220d5d0752164183229091cc9ae
@@ -1 +0,0 @@
1
- 1c8217a57ae4aa80c16be0086bd4b441e6a21b999d725fb370b483912ac6b5965679b1468c17a184f2f678af99ab8a41528d092514cdd497566500de454737c8
@@ -1,9 +0,0 @@
1
- export declare function addImports(source: string, imports: string[], isJava: boolean): string;
2
- export declare function appendContentsInsideDeclarationBlock(srcContents: string, declaration: string, insertion: string): string;
3
- type LeftBrackets = ['(', '{'];
4
- type RightBrackets = [')', '}'];
5
- type LeftBracket = LeftBrackets[number];
6
- type RightBracket = RightBrackets[number];
7
- type Bracket = LeftBracket | RightBracket;
8
- export declare function findMatchingBracketPosition(contents: string, bracket: Bracket, offset?: number): number;
9
- export {};
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addImports = addImports;
4
- exports.appendContentsInsideDeclarationBlock = appendContentsInsideDeclarationBlock;
5
- exports.findMatchingBracketPosition = findMatchingBracketPosition;
6
- function addImports(source, imports, isJava) {
7
- const lines = source.split('\n');
8
- const lineIndexWithPackageDeclaration = lines.findIndex((line) => line.match(/^package .*;?$/));
9
- for (const javaImport of imports) {
10
- if (!source.includes(javaImport)) {
11
- const importStatement = `import ${javaImport}${isJava ? ';' : ''}`;
12
- lines.splice(lineIndexWithPackageDeclaration + 2, 0, importStatement);
13
- }
14
- }
15
- return lines.join('\n');
16
- }
17
- function appendContentsInsideDeclarationBlock(srcContents, declaration, insertion) {
18
- const start = srcContents.search(new RegExp(`\\s*${declaration}.*?[\\(\\{]`));
19
- if (start < 0) {
20
- throw new Error(`Unable to find code block - declaration[${declaration}]`);
21
- }
22
- const end = findMatchingBracketPosition(srcContents, '{', start);
23
- return insertContentsAtOffset(srcContents, insertion, end);
24
- }
25
- function insertContentsAtOffset(srcContents, insertion, offset) {
26
- const srcContentsLength = srcContents.length;
27
- if (offset < 0 || offset > srcContentsLength) {
28
- throw new Error('Invalid parameters.');
29
- }
30
- if (offset === 0) {
31
- return `${insertion}${srcContents}`;
32
- }
33
- else if (offset === srcContentsLength) {
34
- return `${srcContents}${insertion}`;
35
- }
36
- const prefix = srcContents.substring(0, offset);
37
- const suffix = srcContents.substring(offset);
38
- return `${prefix}${insertion}${suffix}`;
39
- }
40
- function findMatchingBracketPosition(contents, bracket, offset = 0) {
41
- // search first occurrence of `bracket`
42
- const firstBracketPos = contents.indexOf(bracket, offset);
43
- if (firstBracketPos < 0) {
44
- return -1;
45
- }
46
- let stackCounter = 0;
47
- const matchingBracket = getMatchingBracket(bracket);
48
- if (isLeftBracket(bracket)) {
49
- const contentsLength = contents.length;
50
- // search forward
51
- for (let i = firstBracketPos + 1; i < contentsLength; ++i) {
52
- const c = contents[i];
53
- if (c === bracket) {
54
- stackCounter += 1;
55
- }
56
- else if (c === matchingBracket) {
57
- if (stackCounter === 0) {
58
- return i;
59
- }
60
- stackCounter -= 1;
61
- }
62
- }
63
- }
64
- else {
65
- // search backward
66
- for (let i = firstBracketPos - 1; i >= 0; --i) {
67
- const c = contents[i];
68
- if (c === bracket) {
69
- stackCounter += 1;
70
- }
71
- else if (c === matchingBracket) {
72
- if (stackCounter === 0) {
73
- return i;
74
- }
75
- stackCounter -= 1;
76
- }
77
- }
78
- }
79
- return -1;
80
- }
81
- function isLeftBracket(bracket) {
82
- const leftBracketList = ['(', '{'];
83
- return leftBracketList.includes(bracket);
84
- }
85
- function getMatchingBracket(bracket) {
86
- switch (bracket) {
87
- case '(':
88
- return ')';
89
- case ')':
90
- return '(';
91
- case '{':
92
- return '}';
93
- case '}':
94
- return '{';
95
- default:
96
- throw new Error(`Unsupported bracket - ${bracket}`);
97
- }
98
- }
@@ -1,5 +0,0 @@
1
- import { ConfigPlugin } from 'expo/config-plugins';
2
- export type PluginConfig = {
3
- experimentalLauncherActivity?: boolean;
4
- };
5
- export declare const withWebBrowserAndroid: ConfigPlugin;
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withWebBrowserAndroid = void 0;
7
- const config_plugins_1 = require("expo/config-plugins");
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const utils_1 = require("./utils");
11
- const withWebBrowserAndroid = (config) => {
12
- config = addActivityToManifest(config);
13
- config = modifyMainApplication(config);
14
- config = addLauncherClassToProject(config);
15
- return config;
16
- };
17
- exports.withWebBrowserAndroid = withWebBrowserAndroid;
18
- function addActivityToManifest(config) {
19
- return (0, config_plugins_1.withAndroidManifest)(config, (config) => {
20
- const manifest = config.modResults.manifest;
21
- const application = manifest?.application?.[0];
22
- for (const activity of application?.activity ?? []) {
23
- if (activity.$['android:name'] === '.BrowserLauncherActivity') {
24
- return config;
25
- }
26
- }
27
- const theme = application?.activity?.[0]?.$['android:theme'];
28
- application?.activity?.[0]['intent-filter']?.splice(0, 1);
29
- const launcherActivity = {
30
- $: {
31
- 'android:name': '.BrowserLauncherActivity',
32
- 'android:theme': theme,
33
- 'android:exported': 'true',
34
- },
35
- 'intent-filter': [
36
- {
37
- action: [{ $: { 'android:name': 'android.intent.action.MAIN' } }],
38
- category: [{ $: { 'android:name': 'android.intent.category.LAUNCHER' } }],
39
- },
40
- ],
41
- };
42
- application?.activity?.push(launcherActivity);
43
- return config;
44
- });
45
- }
46
- function addLauncherClassToProject(config) {
47
- return (0, config_plugins_1.withDangerousMod)(config, [
48
- 'android',
49
- async (config) => {
50
- const fileName = 'BrowserLauncherActivity.kt';
51
- const dir = path_1.default.dirname(config_plugins_1.AndroidConfig.Paths.getProjectFilePath(config.modRequest.projectRoot, 'MainApplication'));
52
- const fullPath = path_1.default.join(dir, fileName);
53
- if (fs_1.default.existsSync(fullPath)) {
54
- return config;
55
- }
56
- const classTemplate = `package ${config.android?.package || ''};
57
-
58
- import android.app.Activity
59
- import android.content.Intent
60
- import android.os.Bundle
61
-
62
- class BrowserLauncherActivity : Activity() {
63
- override fun onCreate(savedInstanceState: Bundle?) {
64
- super.onCreate(savedInstanceState)
65
- val application = application as MainApplication
66
- if (!application.isActivityInBackStack(MainActivity::class.java)) {
67
- val intent = Intent(this, MainActivity::class.java)
68
- startActivity(intent)
69
- }
70
- finish()
71
- }
72
- }
73
- `;
74
- await fs_1.default.promises.writeFile(fullPath, classTemplate);
75
- return config;
76
- },
77
- ]);
78
- }
79
- function modifyMainApplication(config) {
80
- return (0, config_plugins_1.withMainApplication)(config, (config) => {
81
- const mainApplication = config.modResults;
82
- const importsMod = (0, utils_1.addImports)(mainApplication.contents, ['android.app.Activity', 'android.os.Bundle'], false);
83
- let contents = importsMod;
84
- if (!mainApplication.contents.includes('registerActivityLifecycleCallbacks(lifecycleCallbacks)')) {
85
- contents = (0, utils_1.appendContentsInsideDeclarationBlock)(importsMod, 'onCreate', 'registerActivityLifecycleCallbacks(lifecycleCallbacks)');
86
- }
87
- const result = addMainApplicationMod(contents);
88
- return {
89
- ...config,
90
- modResults: {
91
- ...config.modResults,
92
- contents: result,
93
- },
94
- };
95
- });
96
- }
97
- function addMainApplicationMod(contents) {
98
- if (contents.includes('private val runningActivities = ArrayList<Class<*>>()')) {
99
- return contents;
100
- }
101
- const codeMod = `
102
- private val runningActivities = ArrayList<Class<*>>()
103
-
104
- private val lifecycleCallbacks = object : ActivityLifecycleCallbacks {
105
- override fun onActivityCreated(activity: Activity, p1: Bundle?) {
106
- if (!runningActivities.contains(activity::class.java)) runningActivities.add(activity::class.java)
107
- }
108
-
109
- override fun onActivityStarted(p0: Activity) = Unit
110
- override fun onActivityResumed(p0: Activity) = Unit
111
- override fun onActivityPaused(p0: Activity) = Unit
112
- override fun onActivityStopped(p0: Activity) = Unit
113
- override fun onActivitySaveInstanceState(p0: Activity, p1: Bundle) = Unit
114
-
115
- override fun onActivityDestroyed(activity: Activity) {
116
- if (runningActivities.contains(activity::class.java)) runningActivities.remove(activity::class.java)
117
- }
118
- }
119
-
120
- fun isActivityInBackStack(cls: Class<*>?) = runningActivities.contains(cls)
121
-
122
- override fun onTerminate() {
123
- super.onTerminate()
124
- unregisterActivityLifecycleCallbacks(lifecycleCallbacks)
125
- }
126
- `;
127
- return (0, utils_1.appendContentsInsideDeclarationBlock)(contents, 'class MainApplication', codeMod);
128
- }
@@ -1,113 +0,0 @@
1
- export function addImports(source: string, imports: string[], isJava: boolean): string {
2
- const lines = source.split('\n');
3
- const lineIndexWithPackageDeclaration = lines.findIndex((line) => line.match(/^package .*;?$/));
4
- for (const javaImport of imports) {
5
- if (!source.includes(javaImport)) {
6
- const importStatement = `import ${javaImport}${isJava ? ';' : ''}`;
7
- lines.splice(lineIndexWithPackageDeclaration + 2, 0, importStatement);
8
- }
9
- }
10
- return lines.join('\n');
11
- }
12
-
13
- export function appendContentsInsideDeclarationBlock(
14
- srcContents: string,
15
- declaration: string,
16
- insertion: string
17
- ): string {
18
- const start = srcContents.search(new RegExp(`\\s*${declaration}.*?[\\(\\{]`));
19
- if (start < 0) {
20
- throw new Error(`Unable to find code block - declaration[${declaration}]`);
21
- }
22
- const end = findMatchingBracketPosition(srcContents, '{', start);
23
- return insertContentsAtOffset(srcContents, insertion, end);
24
- }
25
-
26
- function insertContentsAtOffset(srcContents: string, insertion: string, offset: number): string {
27
- const srcContentsLength = srcContents.length;
28
- if (offset < 0 || offset > srcContentsLength) {
29
- throw new Error('Invalid parameters.');
30
- }
31
- if (offset === 0) {
32
- return `${insertion}${srcContents}`;
33
- } else if (offset === srcContentsLength) {
34
- return `${srcContents}${insertion}`;
35
- }
36
-
37
- const prefix = srcContents.substring(0, offset);
38
- const suffix = srcContents.substring(offset);
39
- return `${prefix}${insertion}${suffix}`;
40
- }
41
-
42
- type LeftBrackets = ['(', '{'];
43
- type RightBrackets = [')', '}'];
44
-
45
- type LeftBracket = LeftBrackets[number];
46
- type RightBracket = RightBrackets[number];
47
- type Bracket = LeftBracket | RightBracket;
48
-
49
- export function findMatchingBracketPosition(
50
- contents: string,
51
- bracket: Bracket,
52
- offset: number = 0
53
- ): number {
54
- // search first occurrence of `bracket`
55
- const firstBracketPos = contents.indexOf(bracket, offset);
56
- if (firstBracketPos < 0) {
57
- return -1;
58
- }
59
-
60
- let stackCounter = 0;
61
- const matchingBracket = getMatchingBracket(bracket);
62
-
63
- if (isLeftBracket(bracket)) {
64
- const contentsLength = contents.length;
65
- // search forward
66
- for (let i = firstBracketPos + 1; i < contentsLength; ++i) {
67
- const c = contents[i];
68
- if (c === bracket) {
69
- stackCounter += 1;
70
- } else if (c === matchingBracket) {
71
- if (stackCounter === 0) {
72
- return i;
73
- }
74
- stackCounter -= 1;
75
- }
76
- }
77
- } else {
78
- // search backward
79
- for (let i = firstBracketPos - 1; i >= 0; --i) {
80
- const c = contents[i];
81
- if (c === bracket) {
82
- stackCounter += 1;
83
- } else if (c === matchingBracket) {
84
- if (stackCounter === 0) {
85
- return i;
86
- }
87
- stackCounter -= 1;
88
- }
89
- }
90
- }
91
-
92
- return -1;
93
- }
94
-
95
- function isLeftBracket(bracket: Bracket): boolean {
96
- const leftBracketList: readonly Bracket[] = ['(', '{'];
97
- return leftBracketList.includes(bracket);
98
- }
99
-
100
- function getMatchingBracket(bracket: Bracket): Bracket {
101
- switch (bracket) {
102
- case '(':
103
- return ')';
104
- case ')':
105
- return '(';
106
- case '{':
107
- return '}';
108
- case '}':
109
- return '{';
110
- default:
111
- throw new Error(`Unsupported bracket - ${bracket}`);
112
- }
113
- }
@@ -1,166 +0,0 @@
1
- import type { ManifestActivity } from '@expo/config-plugins/build/android/Manifest';
2
- import type { ExpoConfig } from '@expo/config-types';
3
- import {
4
- AndroidConfig,
5
- ConfigPlugin,
6
- withAndroidManifest,
7
- withDangerousMod,
8
- withMainApplication,
9
- } from 'expo/config-plugins';
10
- import fs from 'fs';
11
- import path from 'path';
12
-
13
- import { appendContentsInsideDeclarationBlock, addImports } from './utils';
14
-
15
- export type PluginConfig = {
16
- experimentalLauncherActivity?: boolean;
17
- };
18
-
19
- export const withWebBrowserAndroid: ConfigPlugin = (config) => {
20
- config = addActivityToManifest(config);
21
- config = modifyMainApplication(config);
22
- config = addLauncherClassToProject(config);
23
-
24
- return config;
25
- };
26
-
27
- function addActivityToManifest(config: ExpoConfig) {
28
- return withAndroidManifest(config, (config) => {
29
- const manifest = config.modResults.manifest;
30
- const application = manifest?.application?.[0];
31
-
32
- for (const activity of application?.activity ?? []) {
33
- if (activity.$['android:name'] === '.BrowserLauncherActivity') {
34
- return config;
35
- }
36
- }
37
-
38
- const theme = application?.activity?.[0]?.$['android:theme'];
39
- application?.activity?.[0]['intent-filter']?.splice(0, 1);
40
-
41
- const launcherActivity: ManifestActivity = {
42
- $: {
43
- 'android:name': '.BrowserLauncherActivity',
44
- 'android:theme': theme,
45
- 'android:exported': 'true',
46
- },
47
- 'intent-filter': [
48
- {
49
- action: [{ $: { 'android:name': 'android.intent.action.MAIN' } }],
50
- category: [{ $: { 'android:name': 'android.intent.category.LAUNCHER' } }],
51
- },
52
- ],
53
- };
54
-
55
- application?.activity?.push(launcherActivity);
56
- return config;
57
- });
58
- }
59
-
60
- function addLauncherClassToProject(config: ExpoConfig) {
61
- return withDangerousMod(config, [
62
- 'android',
63
- async (config) => {
64
- const fileName = 'BrowserLauncherActivity.kt';
65
- const dir = path.dirname(
66
- AndroidConfig.Paths.getProjectFilePath(config.modRequest.projectRoot, 'MainApplication')
67
- );
68
-
69
- const fullPath = path.join(dir, fileName);
70
-
71
- if (fs.existsSync(fullPath)) {
72
- return config;
73
- }
74
-
75
- const classTemplate = `package ${config.android?.package || ''};
76
-
77
- import android.app.Activity
78
- import android.content.Intent
79
- import android.os.Bundle
80
-
81
- class BrowserLauncherActivity : Activity() {
82
- override fun onCreate(savedInstanceState: Bundle?) {
83
- super.onCreate(savedInstanceState)
84
- val application = application as MainApplication
85
- if (!application.isActivityInBackStack(MainActivity::class.java)) {
86
- val intent = Intent(this, MainActivity::class.java)
87
- startActivity(intent)
88
- }
89
- finish()
90
- }
91
- }
92
- `;
93
-
94
- await fs.promises.writeFile(fullPath, classTemplate);
95
- return config;
96
- },
97
- ]);
98
- }
99
-
100
- function modifyMainApplication(config: ExpoConfig) {
101
- return withMainApplication(config, (config) => {
102
- const mainApplication = config.modResults;
103
-
104
- const importsMod = addImports(
105
- mainApplication.contents,
106
- ['android.app.Activity', 'android.os.Bundle'],
107
- false
108
- );
109
-
110
- let contents = importsMod;
111
- if (
112
- !mainApplication.contents.includes('registerActivityLifecycleCallbacks(lifecycleCallbacks)')
113
- ) {
114
- contents = appendContentsInsideDeclarationBlock(
115
- importsMod,
116
- 'onCreate',
117
- 'registerActivityLifecycleCallbacks(lifecycleCallbacks)'
118
- );
119
- }
120
-
121
- const result = addMainApplicationMod(contents);
122
-
123
- return {
124
- ...config,
125
- modResults: {
126
- ...config.modResults,
127
- contents: result,
128
- },
129
- };
130
- });
131
- }
132
-
133
- function addMainApplicationMod(contents: string) {
134
- if (contents.includes('private val runningActivities = ArrayList<Class<*>>()')) {
135
- return contents;
136
- }
137
-
138
- const codeMod = `
139
- private val runningActivities = ArrayList<Class<*>>()
140
-
141
- private val lifecycleCallbacks = object : ActivityLifecycleCallbacks {
142
- override fun onActivityCreated(activity: Activity, p1: Bundle?) {
143
- if (!runningActivities.contains(activity::class.java)) runningActivities.add(activity::class.java)
144
- }
145
-
146
- override fun onActivityStarted(p0: Activity) = Unit
147
- override fun onActivityResumed(p0: Activity) = Unit
148
- override fun onActivityPaused(p0: Activity) = Unit
149
- override fun onActivityStopped(p0: Activity) = Unit
150
- override fun onActivitySaveInstanceState(p0: Activity, p1: Bundle) = Unit
151
-
152
- override fun onActivityDestroyed(activity: Activity) {
153
- if (runningActivities.contains(activity::class.java)) runningActivities.remove(activity::class.java)
154
- }
155
- }
156
-
157
- fun isActivityInBackStack(cls: Class<*>?) = runningActivities.contains(cls)
158
-
159
- override fun onTerminate() {
160
- super.onTerminate()
161
- unregisterActivityLifecycleCallbacks(lifecycleCallbacks)
162
- }
163
- `;
164
-
165
- return appendContentsInsideDeclarationBlock(contents, 'class MainApplication', codeMod);
166
- }