expo-dev-menu 4.2.0 → 4.3.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.
- package/.eslintignore +1 -0
- package/CHANGELOG.md +31 -0
- package/android/build.gradle +21 -14
- package/android/src/main/java/com/facebook/react/devsupport/DevMenuReactInternalSettings.kt +7 -0
- package/android/src/main/java/expo/modules/devmenu/devtools/DevMenuDevToolsDelegate.kt +2 -6
- package/android/src/main/java/expo/modules/devmenu/extensions/DevMenuExtension.kt +15 -1
- package/app/App.tsx +0 -1
- package/app/components/LoadInitialData.tsx +1 -1
- package/app/components/Main.tsx +20 -19
- package/app/hooks/useClipboard.tsx +1 -1
- package/app/hooks/useDevSettings.tsx +1 -1
- package/assets/EXDevMenuApp.android.js +65 -67
- package/assets/EXDevMenuApp.ios.js +65 -67
- package/package.json +7 -6
- package/plugin/build/withDevMenu.d.ts +1 -2
- package/plugin/build/withDevMenu.js +2 -97
- package/plugin/jest.config.js +1 -1
- package/plugin/src/withDevMenu.ts +3 -129
- package/tsconfig.app.json +5 -0
- package/plugin/build/constants.d.ts +0 -1
- package/plugin/build/constants.js +0 -4
- package/plugin/build/withDevMenuAppDelegate.d.ts +0 -3
- package/plugin/build/withDevMenuAppDelegate.js +0 -50
- package/plugin/src/constants.ts +0 -2
- package/plugin/src/withDevMenuAppDelegate.ts +0 -63
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-dev-menu",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Expo/React Native module with the developer menu.",
|
|
5
5
|
"main": "build/DevMenu.js",
|
|
6
6
|
"types": "build/DevMenu.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "expo-module build",
|
|
10
10
|
"clean": "expo-module clean",
|
|
11
|
-
"lint": "expo-module lint",
|
|
11
|
+
"lint": "expo-module lint ./app/*",
|
|
12
|
+
"ts:check": "expo-module tsc --project tsconfig.app.json --noEmit & expo-module tsc --noEmit",
|
|
12
13
|
"test": "expo-module test",
|
|
13
14
|
"prepare": "expo-module prepare && ./scripts/reset-dev-menu-packager-host.sh",
|
|
14
15
|
"prepublishOnly": "expo-module prepublishOnly",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
]
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"expo-dev-menu-interface": "1.
|
|
52
|
+
"expo-dev-menu-interface": "1.5.0",
|
|
52
53
|
"semver": "^7.5.3"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
@@ -57,19 +58,19 @@
|
|
|
57
58
|
"@testing-library/jest-native": "^4.0.4",
|
|
58
59
|
"@testing-library/react-native": "^8.0.0",
|
|
59
60
|
"babel-plugin-module-resolver": "^5.0.0",
|
|
60
|
-
"babel-preset-expo": "~9.
|
|
61
|
+
"babel-preset-expo": "~9.8.0",
|
|
61
62
|
"expo-dev-client-components": "1.6.1",
|
|
62
63
|
"expo-module-scripts": "^3.0.0",
|
|
63
64
|
"fuse.js": "^6.4.6",
|
|
64
65
|
"graphql": "^15.3.0",
|
|
65
66
|
"graphql-tag": "^2.10.1",
|
|
66
67
|
"react": "18.2.0",
|
|
67
|
-
"react-native": "0.72.
|
|
68
|
+
"react-native": "0.72.5",
|
|
68
69
|
"use-subscription": "^1.8.0",
|
|
69
70
|
"url": "^0.11.0"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
73
|
"expo": "*"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "da25937e2a99661cbe5eb60ca1d8d6245fc96a50"
|
|
75
76
|
}
|
|
@@ -1,101 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const config_plugins_1 = require("expo/config-plugins");
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const semver_1 = __importDefault(require("semver"));
|
|
10
|
-
const constants_1 = require("./constants");
|
|
11
|
-
const withDevMenuAppDelegate_1 = require("./withDevMenuAppDelegate");
|
|
12
4
|
const pkg = require('expo-dev-menu/package.json');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
async function readFileAsync(path) {
|
|
16
|
-
return fs_1.default.promises.readFile(path, 'utf8');
|
|
17
|
-
}
|
|
18
|
-
async function saveFileAsync(path, content) {
|
|
19
|
-
return fs_1.default.promises.writeFile(path, content, 'utf8');
|
|
20
|
-
}
|
|
21
|
-
function addJavaImports(javaSource, javaImports) {
|
|
22
|
-
const lines = javaSource.split('\n');
|
|
23
|
-
const lineIndexWithPackageDeclaration = lines.findIndex((line) => line.match(/^package .*;$/));
|
|
24
|
-
for (const javaImport of javaImports) {
|
|
25
|
-
if (!javaSource.includes(javaImport)) {
|
|
26
|
-
const importStatement = `import ${javaImport};`;
|
|
27
|
-
lines.splice(lineIndexWithPackageDeclaration + 1, 0, importStatement);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return lines.join('\n');
|
|
31
|
-
}
|
|
32
|
-
function addLines(content, find, offset, toAdd) {
|
|
33
|
-
const lines = content.split('\n');
|
|
34
|
-
let lineIndex = lines.findIndex((line) => line.match(find));
|
|
35
|
-
for (const newLine of toAdd) {
|
|
36
|
-
if (!content.includes(newLine)) {
|
|
37
|
-
lines.splice(lineIndex + offset, 0, newLine);
|
|
38
|
-
lineIndex++;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return lines.join('\n');
|
|
42
|
-
}
|
|
43
|
-
async function editPodfile(config, action) {
|
|
44
|
-
const podfilePath = path_1.default.join(config.modRequest.platformProjectRoot, 'Podfile');
|
|
45
|
-
try {
|
|
46
|
-
const podfile = action(await readFileAsync(podfilePath));
|
|
47
|
-
return await saveFileAsync(podfilePath, podfile);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
config_plugins_1.WarningAggregator.addWarningIOS('expo-dev-menu', `Couldn't modified AppDelegate.m - ${e}.
|
|
51
|
-
See the expo-dev-client installation instructions to modify your AppDelegate manually: ${constants_1.InstallationPage}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const withDevMenuActivity = (config) => {
|
|
55
|
-
return (0, config_plugins_1.withMainActivity)(config, (config) => {
|
|
56
|
-
if (config.modResults.language === 'java') {
|
|
57
|
-
let content = config.modResults.contents;
|
|
58
|
-
content = addJavaImports(content, [DEV_MENU_ANDROID_IMPORT]);
|
|
59
|
-
content = content.replace('public class MainActivity extends ReactActivity {', DEV_MENU_ACTIVITY_CLASS);
|
|
60
|
-
config.modResults.contents = content;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
config_plugins_1.WarningAggregator.addWarningAndroid('expo-dev-menu', `Cannot automatically configure MainActivity if it's not java.
|
|
64
|
-
See the expo-dev-client installation instructions to modify your MainActivity manually: ${constants_1.InstallationPage}`);
|
|
65
|
-
}
|
|
66
|
-
return config;
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
const withDevMenuPodfile = (config) => {
|
|
70
|
-
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
71
|
-
'ios',
|
|
72
|
-
async (config) => {
|
|
73
|
-
await editPodfile(config, (podfile) => {
|
|
74
|
-
podfile = podfile.replace("platform :ios, '10.0'", "platform :ios, '11.0'");
|
|
75
|
-
// Match both variations of Ruby config:
|
|
76
|
-
// unknown: pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', :configurations => :debug
|
|
77
|
-
// Rubocop: pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', configurations: :debug
|
|
78
|
-
if (!podfile.match(/pod ['"]expo-dev-menu['"],\s?path: ['"][^'"]*node_modules\/expo-dev-menu['"],\s?:?configurations:?\s(?:=>\s)?:debug/)) {
|
|
79
|
-
const packagePath = path_1.default.dirname(require.resolve('expo-dev-menu/package.json'));
|
|
80
|
-
const relativePath = path_1.default.relative(config.modRequest.platformProjectRoot, packagePath);
|
|
81
|
-
podfile = addLines(podfile, 'use_react_native', 0, [
|
|
82
|
-
` pod 'expo-dev-menu', path: '${relativePath}', :configurations => :debug`,
|
|
83
|
-
]);
|
|
84
|
-
}
|
|
85
|
-
return podfile;
|
|
86
|
-
});
|
|
87
|
-
return config;
|
|
88
|
-
},
|
|
89
|
-
]);
|
|
90
|
-
};
|
|
91
|
-
const withDevMenu = (config) => {
|
|
92
|
-
// projects using SDKs before 45 need the old regex-based integration
|
|
93
|
-
// TODO: remove this config plugin once we drop support for SDK 44
|
|
94
|
-
if (config.sdkVersion && semver_1.default.lt(config.sdkVersion, '45.0.0')) {
|
|
95
|
-
config = withDevMenuActivity(config);
|
|
96
|
-
config = withDevMenuPodfile(config);
|
|
97
|
-
config = (0, withDevMenuAppDelegate_1.withDevMenuAppDelegate)(config);
|
|
98
|
-
}
|
|
99
|
-
return config;
|
|
100
|
-
};
|
|
101
|
-
exports.default = (0, config_plugins_1.createRunOncePlugin)(withDevMenu, pkg.name, pkg.version);
|
|
5
|
+
// no-op after SDK 44
|
|
6
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)((config) => config, pkg.name, pkg.version);
|
package/plugin/jest.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports =
|
|
1
|
+
module.exports = {};
|
|
@@ -1,132 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
ConfigPlugin,
|
|
4
|
-
createRunOncePlugin,
|
|
5
|
-
ExportedConfigWithProps,
|
|
6
|
-
WarningAggregator,
|
|
7
|
-
withDangerousMod,
|
|
8
|
-
withMainActivity,
|
|
9
|
-
} from 'expo/config-plugins';
|
|
10
|
-
import fs from 'fs';
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import semver from 'semver';
|
|
13
|
-
|
|
14
|
-
import { InstallationPage } from './constants';
|
|
15
|
-
import { withDevMenuAppDelegate } from './withDevMenuAppDelegate';
|
|
1
|
+
import { createRunOncePlugin } from 'expo/config-plugins';
|
|
16
2
|
|
|
17
3
|
const pkg = require('expo-dev-menu/package.json');
|
|
18
4
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async function readFileAsync(path: string): Promise<string> {
|
|
23
|
-
return fs.promises.readFile(path, 'utf8');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function saveFileAsync(path: string, content: string): Promise<void> {
|
|
27
|
-
return fs.promises.writeFile(path, content, 'utf8');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function addJavaImports(javaSource: string, javaImports: string[]): string {
|
|
31
|
-
const lines = javaSource.split('\n');
|
|
32
|
-
const lineIndexWithPackageDeclaration = lines.findIndex((line) => line.match(/^package .*;$/));
|
|
33
|
-
for (const javaImport of javaImports) {
|
|
34
|
-
if (!javaSource.includes(javaImport)) {
|
|
35
|
-
const importStatement = `import ${javaImport};`;
|
|
36
|
-
lines.splice(lineIndexWithPackageDeclaration + 1, 0, importStatement);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return lines.join('\n');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function addLines(content: string, find: string | RegExp, offset: number, toAdd: string[]) {
|
|
43
|
-
const lines = content.split('\n');
|
|
44
|
-
|
|
45
|
-
let lineIndex = lines.findIndex((line) => line.match(find));
|
|
46
|
-
|
|
47
|
-
for (const newLine of toAdd) {
|
|
48
|
-
if (!content.includes(newLine)) {
|
|
49
|
-
lines.splice(lineIndex + offset, 0, newLine);
|
|
50
|
-
lineIndex++;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return lines.join('\n');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function editPodfile(config: ExportedConfigWithProps, action: (podfile: string) => string) {
|
|
58
|
-
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
|
|
59
|
-
try {
|
|
60
|
-
const podfile = action(await readFileAsync(podfilePath));
|
|
61
|
-
|
|
62
|
-
return await saveFileAsync(podfilePath, podfile);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
WarningAggregator.addWarningIOS(
|
|
65
|
-
'expo-dev-menu',
|
|
66
|
-
`Couldn't modified AppDelegate.m - ${e}.
|
|
67
|
-
See the expo-dev-client installation instructions to modify your AppDelegate manually: ${InstallationPage}`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const withDevMenuActivity: ConfigPlugin = (config) => {
|
|
73
|
-
return withMainActivity(config, (config) => {
|
|
74
|
-
if (config.modResults.language === 'java') {
|
|
75
|
-
let content = config.modResults.contents;
|
|
76
|
-
content = addJavaImports(content, [DEV_MENU_ANDROID_IMPORT]);
|
|
77
|
-
content = content.replace(
|
|
78
|
-
'public class MainActivity extends ReactActivity {',
|
|
79
|
-
DEV_MENU_ACTIVITY_CLASS
|
|
80
|
-
);
|
|
81
|
-
config.modResults.contents = content;
|
|
82
|
-
} else {
|
|
83
|
-
WarningAggregator.addWarningAndroid(
|
|
84
|
-
'expo-dev-menu',
|
|
85
|
-
`Cannot automatically configure MainActivity if it's not java.
|
|
86
|
-
See the expo-dev-client installation instructions to modify your MainActivity manually: ${InstallationPage}`
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return config;
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const withDevMenuPodfile: ConfigPlugin = (config) => {
|
|
95
|
-
return withDangerousMod(config, [
|
|
96
|
-
'ios',
|
|
97
|
-
async (config) => {
|
|
98
|
-
await editPodfile(config, (podfile) => {
|
|
99
|
-
podfile = podfile.replace("platform :ios, '10.0'", "platform :ios, '11.0'");
|
|
100
|
-
// Match both variations of Ruby config:
|
|
101
|
-
// unknown: pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', :configurations => :debug
|
|
102
|
-
// Rubocop: pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', configurations: :debug
|
|
103
|
-
if (
|
|
104
|
-
!podfile.match(
|
|
105
|
-
/pod ['"]expo-dev-menu['"],\s?path: ['"][^'"]*node_modules\/expo-dev-menu['"],\s?:?configurations:?\s(?:=>\s)?:debug/
|
|
106
|
-
)
|
|
107
|
-
) {
|
|
108
|
-
const packagePath = path.dirname(require.resolve('expo-dev-menu/package.json'));
|
|
109
|
-
const relativePath = path.relative(config.modRequest.platformProjectRoot, packagePath);
|
|
110
|
-
podfile = addLines(podfile, 'use_react_native', 0, [
|
|
111
|
-
` pod 'expo-dev-menu', path: '${relativePath}', :configurations => :debug`,
|
|
112
|
-
]);
|
|
113
|
-
}
|
|
114
|
-
return podfile;
|
|
115
|
-
});
|
|
116
|
-
return config;
|
|
117
|
-
},
|
|
118
|
-
]);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const withDevMenu = (config: ExpoConfig) => {
|
|
122
|
-
// projects using SDKs before 45 need the old regex-based integration
|
|
123
|
-
// TODO: remove this config plugin once we drop support for SDK 44
|
|
124
|
-
if (config.sdkVersion && semver.lt(config.sdkVersion, '45.0.0')) {
|
|
125
|
-
config = withDevMenuActivity(config);
|
|
126
|
-
config = withDevMenuPodfile(config);
|
|
127
|
-
config = withDevMenuAppDelegate(config);
|
|
128
|
-
}
|
|
129
|
-
return config;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export default createRunOncePlugin(withDevMenu, pkg.name, pkg.version);
|
|
5
|
+
// no-op after SDK 44
|
|
6
|
+
export default createRunOncePlugin<void>((config) => config, pkg.name, pkg.version);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const InstallationPage = "https://github.com/expo/expo/blob/main/packages/expo-dev-menu/README.md";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withDevMenuAppDelegate = exports.modifyAppDelegate = void 0;
|
|
4
|
-
const config_plugins_1 = require("expo/config-plugins");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
const DEV_MENU_IOS_IMPORT = `
|
|
7
|
-
#if defined(EX_DEV_MENU_ENABLED)
|
|
8
|
-
@import EXDevMenu;
|
|
9
|
-
#endif`;
|
|
10
|
-
const DEV_MENU_IOS_INIT = `
|
|
11
|
-
#if defined(EX_DEV_MENU_ENABLED)
|
|
12
|
-
[DevMenuManager configureWithBridge:bridge];
|
|
13
|
-
#endif`;
|
|
14
|
-
const DEV_LAUNCHER_IMPORT = `#include <EXDevLauncher/EXDevLauncherController.h>`;
|
|
15
|
-
function modifyAppDelegate(appDelegate) {
|
|
16
|
-
if (!appDelegate.includes(DEV_MENU_IOS_IMPORT)) {
|
|
17
|
-
const lines = appDelegate.split('\n');
|
|
18
|
-
lines.splice(1, 0, DEV_MENU_IOS_IMPORT);
|
|
19
|
-
appDelegate = lines.join('\n');
|
|
20
|
-
}
|
|
21
|
-
if (!appDelegate.includes(DEV_LAUNCHER_IMPORT)) {
|
|
22
|
-
// expo-dev-launcher isn't present - we need to init expo-dev-menu
|
|
23
|
-
if (!appDelegate.includes(DEV_MENU_IOS_INIT)) {
|
|
24
|
-
const lines = appDelegate.split('\n');
|
|
25
|
-
const initializeReactNativeAppIndex = lines.findIndex((line) => line.includes('- (RCTBridge *)initializeReactNativeApp'));
|
|
26
|
-
const rootViewControllerIndex = lines.findIndex((line, index) => initializeReactNativeAppIndex < index && line.includes('rootViewController'));
|
|
27
|
-
lines.splice(rootViewControllerIndex - 1, 0, DEV_MENU_IOS_INIT);
|
|
28
|
-
appDelegate = lines.join('\n');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
// expo-dev-launcher is present - we need to remove expo-dev-menu init block
|
|
33
|
-
appDelegate = appDelegate.replace(DEV_MENU_IOS_INIT, '');
|
|
34
|
-
}
|
|
35
|
-
return appDelegate;
|
|
36
|
-
}
|
|
37
|
-
exports.modifyAppDelegate = modifyAppDelegate;
|
|
38
|
-
const withDevMenuAppDelegate = (config) => {
|
|
39
|
-
return (0, config_plugins_1.withAppDelegate)(config, (config) => {
|
|
40
|
-
if (config.modResults.language === 'objc') {
|
|
41
|
-
config.modResults.contents = modifyAppDelegate(config.modResults.contents);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
config_plugins_1.WarningAggregator.addWarningIOS('expo-dev-menu', `Swift AppDelegate files are not supported yet.
|
|
45
|
-
See the expo-dev-client installation instructions to modify your AppDelegate manually: ${constants_1.InstallationPage}`);
|
|
46
|
-
}
|
|
47
|
-
return config;
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
exports.withDevMenuAppDelegate = withDevMenuAppDelegate;
|
package/plugin/src/constants.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { ConfigPlugin, WarningAggregator, withAppDelegate } from 'expo/config-plugins';
|
|
2
|
-
|
|
3
|
-
import { InstallationPage } from './constants';
|
|
4
|
-
|
|
5
|
-
const DEV_MENU_IOS_IMPORT = `
|
|
6
|
-
#if defined(EX_DEV_MENU_ENABLED)
|
|
7
|
-
@import EXDevMenu;
|
|
8
|
-
#endif`;
|
|
9
|
-
|
|
10
|
-
const DEV_MENU_IOS_INIT = `
|
|
11
|
-
#if defined(EX_DEV_MENU_ENABLED)
|
|
12
|
-
[DevMenuManager configureWithBridge:bridge];
|
|
13
|
-
#endif`;
|
|
14
|
-
|
|
15
|
-
const DEV_LAUNCHER_IMPORT = `#include <EXDevLauncher/EXDevLauncherController.h>`;
|
|
16
|
-
export function modifyAppDelegate(appDelegate: string) {
|
|
17
|
-
if (!appDelegate.includes(DEV_MENU_IOS_IMPORT)) {
|
|
18
|
-
const lines = appDelegate.split('\n');
|
|
19
|
-
lines.splice(1, 0, DEV_MENU_IOS_IMPORT);
|
|
20
|
-
|
|
21
|
-
appDelegate = lines.join('\n');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!appDelegate.includes(DEV_LAUNCHER_IMPORT)) {
|
|
25
|
-
// expo-dev-launcher isn't present - we need to init expo-dev-menu
|
|
26
|
-
if (!appDelegate.includes(DEV_MENU_IOS_INIT)) {
|
|
27
|
-
const lines = appDelegate.split('\n');
|
|
28
|
-
|
|
29
|
-
const initializeReactNativeAppIndex = lines.findIndex((line) =>
|
|
30
|
-
line.includes('- (RCTBridge *)initializeReactNativeApp')
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const rootViewControllerIndex = lines.findIndex(
|
|
34
|
-
(line, index) =>
|
|
35
|
-
initializeReactNativeAppIndex < index && line.includes('rootViewController')
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
lines.splice(rootViewControllerIndex - 1, 0, DEV_MENU_IOS_INIT);
|
|
39
|
-
|
|
40
|
-
appDelegate = lines.join('\n');
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
// expo-dev-launcher is present - we need to remove expo-dev-menu init block
|
|
44
|
-
appDelegate = appDelegate.replace(DEV_MENU_IOS_INIT, '');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return appDelegate;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const withDevMenuAppDelegate: ConfigPlugin = (config) => {
|
|
51
|
-
return withAppDelegate(config, (config) => {
|
|
52
|
-
if (config.modResults.language === 'objc') {
|
|
53
|
-
config.modResults.contents = modifyAppDelegate(config.modResults.contents);
|
|
54
|
-
} else {
|
|
55
|
-
WarningAggregator.addWarningIOS(
|
|
56
|
-
'expo-dev-menu',
|
|
57
|
-
`Swift AppDelegate files are not supported yet.
|
|
58
|
-
See the expo-dev-client installation instructions to modify your AppDelegate manually: ${InstallationPage}`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return config;
|
|
62
|
-
});
|
|
63
|
-
};
|