Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expo-dev-launcher

Package Overview
Dependencies
Maintainers
24
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-dev-launcher - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

build/DevLauncherErrorManager.d.ts

2

build/DevLauncher.d.ts

@@ -0,1 +1,3 @@

import './setUpErrorHandler.fx';
export { disableErrorHandling } from './DevLauncherErrorManager';
export declare function registerErrorHandlers(): void;

49

build/DevLauncher.js

@@ -1,49 +0,6 @@

let errorHandlerWasRegistered = false;
const unavailableErrorPossibleSolutions = `Some possible solutions:
- Make sure that the method is available on the current platform.
- Make sure you're using the newest available version of this development client.
- Make sure you're running a compatible version of your JavaScript code.
- If you've installed a new library recently, you may need to make a new development client build.`;
const moduleIsMissingPossibleSolutions = `Some possible solutions:
- Make sure you're using the newest available version of this development client.
- Make sure you're running a compatible version of your JavaScript code.
- If you've installed a new library recently, you may need to make a new development client build.`;
function customizeUnavailableMessage(error) {
error.message += '\n\n' + unavailableErrorPossibleSolutions;
}
function customizeModuleIsMissingMessage(error) {
error.message = `Your JavaScript code tried to access a native module that doesn't exist in this development client.
${moduleIsMissingPossibleSolutions}`;
}
function customizeError(error) {
if ('code' in error) {
// It's a CodedError from expo modules
switch (error.code) {
case 'ERR_UNAVAILABLE': {
customizeUnavailableMessage(error);
break;
}
}
}
else if (error.message.includes('Native module cannot be null')) {
customizeModuleIsMissingMessage(error);
}
}
function errorHandler(fn, error, isFatal) {
if (error instanceof Error) {
customizeError(error);
}
fn(error, isFatal);
}
import './setUpErrorHandler.fx';
export { disableErrorHandling } from './DevLauncherErrorManager';
export function registerErrorHandlers() {
if (errorHandlerWasRegistered) {
return;
}
errorHandlerWasRegistered = true;
const globalHandler = ErrorUtils.getGlobalHandler();
ErrorUtils.setGlobalHandler(function (...args) {
errorHandler(globalHandler, ...args);
});
console.warn('DevLauncher.registerErrorHandlers has been deprecated. To enable error handlers you need to import "expo-dev-launcher" at the top of your index.js.');
}
//# sourceMappingURL=DevLauncher.js.map

@@ -13,2 +13,19 @@ # Changelog

## 0.6.0 — 2021-06-24
### 🛠 Breaking changes
- Reset Updates module state on each dev client load. ([#13346](https://github.com/expo/expo/pull/13346) by [@esamelson](https://github.com/esamelson))
- Ensure error handler is initialized. ([#13384](https://github.com/expo/expo/pull/13384) by [@lukmccall](https://github.com/lukmccall))
### 🎉 New features
- Added expo-updates integration to config plugin. ([#13198](https://github.com/expo/expo/pull/13198) by [@esamelson](https://github.com/esamelson))
### 🐛 Bug fixes
- Fixed switching from published to local bundle loading on Android. ([#13363](https://github.com/expo/expo/pull/13363) by [@esamelson](https://github.com/esamelson))
- [plugin] Use Node module resolution to find package paths for Podfile ([#13382](https://github.com/expo/expo/pull/13382) by [@fson](https://github.com/fson))
- Send expo-updates-environment: DEVELOPMENT header in manifest requests. ([#13375](https://github.com/expo/expo/pull/13375) by [@esamelson](https://github.com/esamelson))
## 0.5.1 — 2021-06-16

@@ -15,0 +32,0 @@

{
"name": "expo-dev-launcher",
"title": "Expo Development Launcher",
"version": "0.5.1",
"version": "0.6.0",
"description": "Pre-release version of the Expo development launcher package for testing.",

@@ -31,3 +31,5 @@ "main": "build/DevLauncher.js",

"dependencies": {
"@expo/config-plugins": "^2.0.0"
"@expo/config-plugins": "^3.0.0",
"resolve-from": "^5.0.0",
"semver": "^7.3.5"
},

@@ -40,3 +42,3 @@ "devDependencies": {

},
"gitHead": "c80d4c938920c5111e34c2dbca3a6bf500dff0e1"
"gitHead": "c1ec93fc138fc342600885c52f2841ea2923f29d"
}

@@ -9,5 +9,8 @@ "use strict";

const path_1 = __importDefault(require("path"));
const semver_1 = __importDefault(require("semver"));
const resolveExpoUpdatesVersion_1 = require("./resolveExpoUpdatesVersion");
const withDevLauncherAppDelegate_1 = require("./withDevLauncherAppDelegate");
const pkg = require('expo-dev-launcher/package.json');
const DEV_LAUNCHER_ANDROID_IMPORT = 'expo.modules.devlauncher.DevLauncherController';
const DEV_LAUNCHER_UPDATES_ANDROID_IMPORT = 'expo.modules.updates.UpdatesDevLauncherController';
const DEV_LAUNCHER_ON_NEW_INTENT = `

@@ -24,5 +27,5 @@ @Override

const DEV_LAUNCHER_ANDROID_INIT = 'DevLauncherController.initialize(this, getReactNativeHost());';
const DEV_LAUNCHER_POD_IMPORT = "pod 'expo-dev-launcher', path: '../node_modules/expo-dev-launcher', :configurations => :debug";
const DEV_LAUNCHER_JS_REGISTER_ERROR_HANDLERS = `import { registerErrorHandlers } from 'expo-dev-launcher';
registerErrorHandlers();`;
const DEV_LAUNCHER_UPDATES_ANDROID_INIT = 'DevLauncherController.getInstance().setUpdatesInterface(UpdatesDevLauncherController.initialize(this));';
const DEV_LAUNCHER_UPDATES_DEVELOPER_SUPPORT = 'return DevLauncherController.getInstance().getUseDeveloperSupport();';
const DEV_LAUNCHER_JS_REGISTER_ERROR_HANDLERS = `import 'expo-dev-client';`;
async function readFileAsync(path) {

@@ -45,2 +48,10 @@ return fs_1.default.promises.readFile(path, 'utf8');

}
function replaceLine(content, find, replace) {
const lines = content.split('\n');
if (!content.includes(replace)) {
const lineIndex = lines.findIndex(line => line.match(find));
lines.splice(lineIndex, 1, replace);
}
return lines.join('\n');
}
function addJavaImports(javaSource, javaImports) {

@@ -93,5 +104,19 @@ const lines = javaSource.split('\n');

mainApplication = addJavaImports(mainApplication, [DEV_LAUNCHER_ANDROID_IMPORT]);
mainApplication = addLines(mainApplication, 'super.onCreate()', 1, [
mainApplication = addLines(mainApplication, 'initializeFlipper\\(this', 0, [
` ${DEV_LAUNCHER_ANDROID_INIT}`,
]);
let expoUpdatesVersion;
try {
expoUpdatesVersion = resolveExpoUpdatesVersion_1.resolveExpoUpdatesVersion(config.modRequest.projectRoot);
}
catch (e) {
config_plugins_1.WarningAggregator.addWarningAndroid('expo-dev-launcher', `Failed to check compatibility with expo-updates - ${e}`);
}
if (expoUpdatesVersion && semver_1.default.gt(expoUpdatesVersion, '0.6.0')) {
mainApplication = addJavaImports(mainApplication, [DEV_LAUNCHER_UPDATES_ANDROID_IMPORT]);
mainApplication = addLines(mainApplication, 'initializeFlipper\\(this', 0, [
` ${DEV_LAUNCHER_UPDATES_ANDROID_INIT}`,
]);
mainApplication = replaceLine(mainApplication, 'return BuildConfig.DEBUG;', ` ${DEV_LAUNCHER_UPDATES_DEVELOPER_SUPPORT}`);
}
return mainApplication;

@@ -136,4 +161,8 @@ });

// Rubocop: pod 'expo-dev-launcher', path: '../node_modules/expo-dev-launcher', configurations: :debug
if (!podfile.match(/pod ['"]expo-dev-launcher['"],\s?path: ['"]\.\.\/node_modules\/expo-dev-launcher['"],\s?:?configurations:?\s(?:=>\s)?:debug/)) {
podfile = addLines(podfile, 'use_react_native', 0, [` ${DEV_LAUNCHER_POD_IMPORT}`]);
if (!podfile.match(/pod ['"]expo-dev-launcher['"],\s?path: ['"][^'"]*node_modules\/expo-dev-launcher['"],\s?:?configurations:?\s(?:=>\s)?:debug/)) {
const packagePath = path_1.default.dirname(require.resolve('expo-dev-launcher/package.json'));
const relativePath = path_1.default.relative(config.modRequest.platformProjectRoot, packagePath);
podfile = addLines(podfile, 'use_react_native', 0, [
` pod 'expo-dev-launcher', path: '${relativePath}', :configurations => :debug`,
]);
}

@@ -140,0 +169,0 @@ return podfile;

import { ConfigPlugin } from '@expo/config-plugins';
export declare function modifyAppDelegate(appDelegate: string): string;
export declare function modifyAppDelegate(appDelegate: string, expoUpdatesVersion?: string | null): string;
export declare const withDevLauncherAppDelegate: ConfigPlugin;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withDevLauncherAppDelegate = exports.modifyAppDelegate = void 0;
const config_plugins_1 = require("@expo/config-plugins");
const semver_1 = __importDefault(require("semver"));
const resolveExpoUpdatesVersion_1 = require("./resolveExpoUpdatesVersion");
const DEV_LAUNCHER_APP_DELEGATE_SOURCE_FOR_URL = ` #if defined(EX_DEV_LAUNCHER_ENABLED)

@@ -20,2 +25,7 @@ return [[EXDevLauncherController sharedInstance] sourceUrl];

#endif`;
const DEV_LAUNCHER_UPDATES_APP_DELEGATE_IOS_IMPORT = `
#if defined(EX_DEV_LAUNCHER_ENABLED)
#include <EXDevLauncher/EXDevLauncherController.h>
#import <EXUpdates/EXUpdatesDevLauncherController.h>
#endif`;
const DEV_LAUNCHER_APP_DELEGATE_CONTROLLER_DELEGATE = `

@@ -42,2 +52,4 @@ #if defined(EX_DEV_LAUNCHER_ENABLED)

#endif`;
const DEV_LAUNCHER_UPDATES_APP_DELEGATE_INIT = `EXDevLauncherController *controller = [EXDevLauncherController sharedInstance];
controller.updatesInterface = [EXUpdatesDevLauncherController sharedInstance];`;
const DEV_LAUNCHER_APP_DELEGATE_BRIDGE = `#if defined(EX_DEV_LAUNCHER_ENABLED)

@@ -55,6 +67,10 @@ NSDictionary *launchOptions = [EXDevLauncherController.sharedInstance getLaunchOptions];

#endif`;
function modifyAppDelegate(appDelegate) {
if (!appDelegate.includes(DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT)) {
function modifyAppDelegate(appDelegate, expoUpdatesVersion = null) {
const shouldAddUpdatesIntegration = expoUpdatesVersion != null && semver_1.default.gt(expoUpdatesVersion, '0.6.0');
if (!appDelegate.includes(DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT) &&
!appDelegate.includes(DEV_LAUNCHER_UPDATES_APP_DELEGATE_IOS_IMPORT)) {
const lines = appDelegate.split('\n');
lines.splice(1, 0, DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT);
lines.splice(1, 0, shouldAddUpdatesIntegration
? DEV_LAUNCHER_UPDATES_APP_DELEGATE_IOS_IMPORT
: DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT);
appDelegate = lines.join('\n');

@@ -65,2 +81,6 @@ }

}
if (shouldAddUpdatesIntegration &&
!appDelegate.includes(DEV_LAUNCHER_UPDATES_APP_DELEGATE_INIT)) {
appDelegate = appDelegate.replace('EXDevLauncherController *controller = [EXDevLauncherController sharedInstance];', DEV_LAUNCHER_UPDATES_APP_DELEGATE_INIT);
}
if (!appDelegate.includes(DEV_LAUNCHER_APP_DELEGATE_BRIDGE)) {

@@ -89,3 +109,10 @@ appDelegate = appDelegate.replace('RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];', DEV_LAUNCHER_APP_DELEGATE_BRIDGE);

if (config.modResults.language === 'objc') {
config.modResults.contents = modifyAppDelegate(config.modResults.contents);
let expoUpdatesVersion;
try {
expoUpdatesVersion = resolveExpoUpdatesVersion_1.resolveExpoUpdatesVersion(config.modRequest.projectRoot);
}
catch (e) {
config_plugins_1.WarningAggregator.addWarningIOS('expo-dev-launcher', `Failed to check compatibility with expo-updates - ${e}`);
}
config.modResults.contents = modifyAppDelegate(config.modResults.contents, expoUpdatesVersion);
}

@@ -92,0 +119,0 @@ else {

@@ -12,3 +12,5 @@ import {

import path from 'path';
import semver from 'semver';
import { resolveExpoUpdatesVersion } from './resolveExpoUpdatesVersion';
import { withDevLauncherAppDelegate } from './withDevLauncherAppDelegate';

@@ -19,2 +21,3 @@

const DEV_LAUNCHER_ANDROID_IMPORT = 'expo.modules.devlauncher.DevLauncherController';
const DEV_LAUNCHER_UPDATES_ANDROID_IMPORT = 'expo.modules.updates.UpdatesDevLauncherController';
const DEV_LAUNCHER_ON_NEW_INTENT = `

@@ -31,9 +34,9 @@ @Override

const DEV_LAUNCHER_ANDROID_INIT = 'DevLauncherController.initialize(this, getReactNativeHost());';
const DEV_LAUNCHER_UPDATES_ANDROID_INIT =
'DevLauncherController.getInstance().setUpdatesInterface(UpdatesDevLauncherController.initialize(this));';
const DEV_LAUNCHER_UPDATES_DEVELOPER_SUPPORT =
'return DevLauncherController.getInstance().getUseDeveloperSupport();';
const DEV_LAUNCHER_POD_IMPORT =
"pod 'expo-dev-launcher', path: '../node_modules/expo-dev-launcher', :configurations => :debug";
const DEV_LAUNCHER_JS_REGISTER_ERROR_HANDLERS = `import 'expo-dev-client';`;
const DEV_LAUNCHER_JS_REGISTER_ERROR_HANDLERS = `import { registerErrorHandlers } from 'expo-dev-launcher';
registerErrorHandlers();`;
async function readFileAsync(path: string): Promise<string> {

@@ -62,2 +65,13 @@ return fs.promises.readFile(path, 'utf8');

function replaceLine(content: string, find: string | RegExp, replace: string) {
const lines = content.split('\n');
if (!content.includes(replace)) {
const lineIndex = lines.findIndex(line => line.match(find));
lines.splice(lineIndex, 1, replace);
}
return lines.join('\n');
}
function addJavaImports(javaSource: string, javaImports: string[]): string {

@@ -127,6 +141,27 @@ const lines = javaSource.split('\n');

mainApplication = addLines(mainApplication, 'super.onCreate()', 1, [
mainApplication = addLines(mainApplication, 'initializeFlipper\\(this', 0, [
` ${DEV_LAUNCHER_ANDROID_INIT}`,
]);
let expoUpdatesVersion;
try {
expoUpdatesVersion = resolveExpoUpdatesVersion(config.modRequest.projectRoot);
} catch (e) {
WarningAggregator.addWarningAndroid(
'expo-dev-launcher',
`Failed to check compatibility with expo-updates - ${e}`
);
}
if (expoUpdatesVersion && semver.gt(expoUpdatesVersion, '0.6.0')) {
mainApplication = addJavaImports(mainApplication, [DEV_LAUNCHER_UPDATES_ANDROID_IMPORT]);
mainApplication = addLines(mainApplication, 'initializeFlipper\\(this', 0, [
` ${DEV_LAUNCHER_UPDATES_ANDROID_INIT}`,
]);
mainApplication = replaceLine(
mainApplication,
'return BuildConfig.DEBUG;',
` ${DEV_LAUNCHER_UPDATES_DEVELOPER_SUPPORT}`
);
}
return mainApplication;

@@ -186,6 +221,10 @@ });

!podfile.match(
/pod ['"]expo-dev-launcher['"],\s?path: ['"]\.\.\/node_modules\/expo-dev-launcher['"],\s?:?configurations:?\s(?:=>\s)?:debug/
/pod ['"]expo-dev-launcher['"],\s?path: ['"][^'"]*node_modules\/expo-dev-launcher['"],\s?:?configurations:?\s(?:=>\s)?:debug/
)
) {
podfile = addLines(podfile, 'use_react_native', 0, [` ${DEV_LAUNCHER_POD_IMPORT}`]);
const packagePath = path.dirname(require.resolve('expo-dev-launcher/package.json'));
const relativePath = path.relative(config.modRequest.platformProjectRoot, packagePath);
podfile = addLines(podfile, 'use_react_native', 0, [
` pod 'expo-dev-launcher', path: '${relativePath}', :configurations => :debug`,
]);
}

@@ -192,0 +231,0 @@ return podfile;

import { ConfigPlugin, WarningAggregator, withAppDelegate } from '@expo/config-plugins';
import semver from 'semver';
import { resolveExpoUpdatesVersion } from './resolveExpoUpdatesVersion';
const DEV_LAUNCHER_APP_DELEGATE_SOURCE_FOR_URL = ` #if defined(EX_DEV_LAUNCHER_ENABLED)

@@ -18,2 +21,7 @@ return [[EXDevLauncherController sharedInstance] sourceUrl];

#endif`;
const DEV_LAUNCHER_UPDATES_APP_DELEGATE_IOS_IMPORT = `
#if defined(EX_DEV_LAUNCHER_ENABLED)
#include <EXDevLauncher/EXDevLauncherController.h>
#import <EXUpdates/EXUpdatesDevLauncherController.h>
#endif`;
const DEV_LAUNCHER_APP_DELEGATE_CONTROLLER_DELEGATE = `

@@ -40,2 +48,4 @@ #if defined(EX_DEV_LAUNCHER_ENABLED)

#endif`;
const DEV_LAUNCHER_UPDATES_APP_DELEGATE_INIT = `EXDevLauncherController *controller = [EXDevLauncherController sharedInstance];
controller.updatesInterface = [EXUpdatesDevLauncherController sharedInstance];`;

@@ -56,6 +66,18 @@ const DEV_LAUNCHER_APP_DELEGATE_BRIDGE = `#if defined(EX_DEV_LAUNCHER_ENABLED)

export function modifyAppDelegate(appDelegate: string) {
if (!appDelegate.includes(DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT)) {
export function modifyAppDelegate(appDelegate: string, expoUpdatesVersion: string | null = null) {
const shouldAddUpdatesIntegration =
expoUpdatesVersion != null && semver.gt(expoUpdatesVersion, '0.6.0');
if (
!appDelegate.includes(DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT) &&
!appDelegate.includes(DEV_LAUNCHER_UPDATES_APP_DELEGATE_IOS_IMPORT)
) {
const lines = appDelegate.split('\n');
lines.splice(1, 0, DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT);
lines.splice(
1,
0,
shouldAddUpdatesIntegration
? DEV_LAUNCHER_UPDATES_APP_DELEGATE_IOS_IMPORT
: DEV_LAUNCHER_APP_DELEGATE_IOS_IMPORT
);

@@ -72,2 +94,12 @@ appDelegate = lines.join('\n');

if (
shouldAddUpdatesIntegration &&
!appDelegate.includes(DEV_LAUNCHER_UPDATES_APP_DELEGATE_INIT)
) {
appDelegate = appDelegate.replace(
'EXDevLauncherController *controller = [EXDevLauncherController sharedInstance];',
DEV_LAUNCHER_UPDATES_APP_DELEGATE_INIT
);
}
if (!appDelegate.includes(DEV_LAUNCHER_APP_DELEGATE_BRIDGE)) {

@@ -110,3 +142,15 @@ appDelegate = appDelegate.replace(

if (config.modResults.language === 'objc') {
config.modResults.contents = modifyAppDelegate(config.modResults.contents);
let expoUpdatesVersion;
try {
expoUpdatesVersion = resolveExpoUpdatesVersion(config.modRequest.projectRoot);
} catch (e) {
WarningAggregator.addWarningIOS(
'expo-dev-launcher',
`Failed to check compatibility with expo-updates - ${e}`
);
}
config.modResults.contents = modifyAppDelegate(
config.modResults.contents,
expoUpdatesVersion
);
} else {

@@ -113,0 +157,0 @@ WarningAggregator.addWarningIOS(

@@ -1,61 +0,8 @@

import { ErrorUtils } from 'react-native';
import './setUpErrorHandler.fx';
export { disableErrorHandling } from './DevLauncherErrorManager';
// Similar interface to the one used in expo modules.
type CodedError = Error & { code?: string };
let errorHandlerWasRegistered = false;
const unavailableErrorPossibleSolutions = `Some possible solutions:
- Make sure that the method is available on the current platform.
- Make sure you're using the newest available version of this development client.
- Make sure you're running a compatible version of your JavaScript code.
- If you've installed a new library recently, you may need to make a new development client build.`;
const moduleIsMissingPossibleSolutions = `Some possible solutions:
- Make sure you're using the newest available version of this development client.
- Make sure you're running a compatible version of your JavaScript code.
- If you've installed a new library recently, you may need to make a new development client build.`;
function customizeUnavailableMessage(error: CodedError) {
error.message += '\n\n' + unavailableErrorPossibleSolutions;
}
function customizeModuleIsMissingMessage(error: Error) {
error.message = `Your JavaScript code tried to access a native module that doesn't exist in this development client.
${moduleIsMissingPossibleSolutions}`;
}
function customizeError(error: Error | CodedError) {
if ('code' in error) {
// It's a CodedError from expo modules
switch (error.code) {
case 'ERR_UNAVAILABLE': {
customizeUnavailableMessage(error);
break;
}
}
} else if (error.message.includes('Native module cannot be null')) {
customizeModuleIsMissingMessage(error);
}
}
function errorHandler(fn, error, isFatal) {
if (error instanceof Error) {
customizeError(error);
}
fn(error, isFatal);
}
export function registerErrorHandlers() {
if (errorHandlerWasRegistered) {
return;
}
errorHandlerWasRegistered = true;
const globalHandler = ErrorUtils.getGlobalHandler();
ErrorUtils.setGlobalHandler(function(...args) {
errorHandler(globalHandler, ...args);
});
console.warn(
'DevLauncher.registerErrorHandlers has been deprecated. To enable error handlers you need to import "expo-dev-launcher" at the top of your index.js.'
);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc