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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-dev-menu",
3
- "version": "4.2.0",
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.4.0",
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.7.0",
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.4",
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": "ee2c866ba3c7fbc35ff2a3e896041cf15d3bd7c5"
75
+ "gitHead": "da25937e2a99661cbe5eb60ca1d8d6245fc96a50"
75
76
  }
@@ -1,3 +1,2 @@
1
- import { ConfigPlugin } from 'expo/config-plugins';
2
- declare const _default: ConfigPlugin<unknown>;
1
+ declare const _default: import("expo/config-plugins").ConfigPlugin<void>;
3
2
  export default _default;
@@ -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
- const DEV_MENU_ANDROID_IMPORT = 'expo.modules.devmenu.react.DevMenuAwareReactActivity';
14
- const DEV_MENU_ACTIVITY_CLASS = 'public class MainActivity extends DevMenuAwareReactActivity {';
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);
@@ -1 +1 @@
1
- module.exports = require('expo-module-scripts/jest-preset-plugin');
1
+ module.exports = {};
@@ -1,132 +1,6 @@
1
- import { ExpoConfig } from 'expo/config';
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
- const DEV_MENU_ANDROID_IMPORT = 'expo.modules.devmenu.react.DevMenuAwareReactActivity';
20
- const DEV_MENU_ACTIVITY_CLASS = 'public class MainActivity extends DevMenuAwareReactActivity {';
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);
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "expo-module-scripts/tsconfig.base",
3
+ "include": ["./app"],
4
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
5
+ }
@@ -1 +0,0 @@
1
- export declare const InstallationPage = "https://github.com/expo/expo/blob/main/packages/expo-dev-menu/README.md";
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InstallationPage = void 0;
4
- exports.InstallationPage = 'https://github.com/expo/expo/blob/main/packages/expo-dev-menu/README.md';
@@ -1,3 +0,0 @@
1
- import { ConfigPlugin } from 'expo/config-plugins';
2
- export declare function modifyAppDelegate(appDelegate: string): string;
3
- export declare const withDevMenuAppDelegate: ConfigPlugin;
@@ -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;
@@ -1,2 +0,0 @@
1
- export const InstallationPage =
2
- 'https://github.com/expo/expo/blob/main/packages/expo-dev-menu/README.md';
@@ -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
- };