Skip to content

Kddimitrov/fix splashscreen generation #4274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
05ce8d0
fix: fire the debugger attached event only when the app is restarted …
DimitarTachev Dec 20, 2018
89dd3aa
fix: fix unhandled promise rejection error thrown from sidekick
Fatme Jan 2, 2019
4db5bb3
chore: emit correctly PREVIEW_APP_LIVE_SYNC_ERROR
Fatme Jan 2, 2019
65eeeeb
Merge pull request #4251 from NativeScript/fatme/fix-unhandled-rejection
Jan 3, 2019
e37e9f8
Merge pull request #4246 from NativeScript/tachev/fix-debugger-attach…
Jan 3, 2019
9ae9343
fix: log the proxy port even when returning a cached proxy instead of…
DimitarTachev Dec 19, 2018
4683e50
Merge pull request #4241 from NativeScript/tachev/fix-ios-debug-proxy
Jan 3, 2019
c8defbb
fix: fix stopApplication on Simulator while the app is on a breakpoint
DimitarTachev Jan 4, 2019
7b4d2b7
Merge pull request #4254 from NativeScript/tachev/fix-stop-app-simulator
Jan 4, 2019
acc5a42
fix: suggest manual app start instead of crashing on ios debug socket…
DimitarTachev Jan 4, 2019
59ccd8f
fix: require user interaction for developer disk image only in debug
DimitarTachev Jan 4, 2019
674918b
Merge pull request #4258 from NativeScript/tachev/fix-sidekick-issues
Jan 5, 2019
988575f
Merge pull request #4259 from NativeScript/tachev/fix-dev-disk-image-…
Jan 5, 2019
d1517e3
fix(preview-publicApi): Don't persist the plugin's warnings when comp…
Fatme Jan 7, 2019
0842ab6
Merge pull request #4267 from NativeScript/fatme/force-option
Jan 7, 2019
f7a4437
fix: do not show error from preview initialization when stop is called
rosen-vladimirov Jan 7, 2019
7c07d2e
fix: handle `previewAppLiveSyncError` event in CLI
rosen-vladimirov Jan 7, 2019
9834826
Merge pull request #4271 from NativeScript/vladimirov/fix-error-previ…
rosen-vladimirov Jan 8, 2019
b87d619
fix: fix splashscreen generation
KristianDD Jan 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@ export class PreviewCommand implements ICommand {
this.$logger.info(message);
});

await this.$liveSyncService.liveSync([], {
syncToPreviewApp: true,
projectDir: this.$projectData.projectDir,
skipWatcher: !this.$options.watch,
watchAllFiles: this.$options.syncAllFiles,
clean: this.$options.clean,
await this.$liveSyncService.liveSyncToPreviewApp({
bundle: !!this.$options.bundle,
release: this.$options.release,
env: this.$options.env,
timeout: this.$options.timeout,
useHotModuleReload: this.$options.hmr
useHotModuleReload: this.$options.hmr,
projectDir: this.$projectData.projectDir,
env: this.$options.env
});

await this.$previewQrCodeService.printLiveSyncQrCode({ useHotModuleReload: this.$options.hmr, link: this.$options.link });
Expand Down
9 changes: 6 additions & 3 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,14 @@ interface IGenerateOptions {
collection?: string;
}

interface IDebugInformation extends IPort, Mobile.IDeviceIdentifier {
interface IDebugInformation extends IPort, Mobile.IDeviceIdentifier, IHasHasReconnected {
url: string;
}

interface IHasHasReconnected {
hasReconnected: boolean;
}

interface IPort {
port: Number;
}
Expand Down Expand Up @@ -735,8 +739,7 @@ interface IAppDebugSocketProxyFactory extends NodeJS.EventEmitter {
getTCPSocketProxy(deviceIdentifier: string, appId: string): any;
addTCPSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<any>;

getWebSocketProxy(deviceIdentifier: string, appId: string): any;
addWebSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<any>;
ensureWebSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<any>;

removeAllProxies(): void;
}
Expand Down
10 changes: 9 additions & 1 deletion lib/definitions/debug.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ interface IDebugOptions {
* Defines if the handshake(AppLaunching notification) between CLI and runtime should be executed. The handshake is not needed when CLI retries to attach to the debugger.
*/
skipHandshake?: boolean;
/**
* Forces the debugger attach event to be emitted.
*/
forceDebuggerAttachedEvent?: boolean;
}

/**
Expand Down Expand Up @@ -161,5 +165,9 @@ interface IDeviceDebugService extends IPlatform, NodeJS.EventEmitter {
* @param {IDebugOptions} debugOptions Describe possible options to modify the behaivor of the debug operation, for example stop on the first line.
* @returns {Promise<string>} Full url where the frontend client may be connected.
*/
debug(debugData: IAppDebugData, debugOptions: IDebugOptions): Promise<string>;
debug(debugData: IAppDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo>;
}

interface IDebugResultInfo extends IHasHasReconnected {
debugUrl: string;
}
26 changes: 19 additions & 7 deletions lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ interface ILiveSyncEventData {
applicationIdentifier?: string,
projectDir: string,
syncedFiles?: string[],
error? : Error,
error?: Error,
notification?: string,
isFullSync?: boolean
}
Expand Down Expand Up @@ -242,6 +242,13 @@ interface ILiveSyncService {
*/
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void>;

/**
* Starts LiveSync operation to Preview app.
* @param {IPreviewAppLiveSyncData} data Describes information about the current operation.
* @returns {Promise<IQrCodeImageData>} Data of the QR code that should be used to start the LiveSync operation.
*/
liveSyncToPreviewApp(data: IPreviewAppLiveSyncData): Promise<IQrCodeImageData>;

/**
* Stops LiveSync operation for specified directory.
* @param {string} projectDir The directory for which to stop the operation.
Expand Down Expand Up @@ -330,11 +337,9 @@ interface IEnableDebuggingDeviceOptions extends Mobile.IDeviceIdentifier, IOptio
/**
* Describes settings passed to livesync service in order to control event emitting during refresh application.
*/
interface IShouldSkipEmitLiveSyncNotification {
/**
* Whether to skip emitting an event during refresh. Default is false.
*/
interface IRefreshApplicationSettings {
shouldSkipEmitLiveSyncNotification: boolean;
shouldCheckDeveloperDiscImage: boolean;
}

/**
Expand Down Expand Up @@ -390,11 +395,18 @@ interface ITransferFilesOptions {
interface IPlatformLiveSyncService {
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<IRefreshApplicationInfo>;
prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir, liveSyncInfo: ILiveSyncInfo, debugOptions: IDebugOptions): Promise<void>;
getDeviceLiveSyncService(device: Mobile.IDevice, projectData: IProjectData): INativeScriptDeviceLiveSyncService;
}

interface IHasDidRestart {
didRestart: boolean;
}

interface IRefreshApplicationInfo extends IHasDidRestart {
}

interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {
/**
* Refreshes the application's content on a device
Expand All @@ -405,7 +417,7 @@ interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase
* @return {Promise<void>}
*/
refreshApplication(projectData: IProjectData,
liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
liveSyncInfo: ILiveSyncResultInfo): Promise<IRefreshApplicationInfo>;

/**
* Removes specified files from a connected device
Expand Down
32 changes: 19 additions & 13 deletions lib/device-sockets/ios/app-debug-socket-proxy-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebu
return this.deviceTcpServers[`${deviceIdentifier}-${appId}`];
}

public getWebSocketProxy(deviceIdentifier: string, appId: string): ws.Server {
return this.deviceWebServers[`${deviceIdentifier}-${appId}`];
}

public async addTCPSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<net.Server> {
const cacheKey = `${device.deviceInfo.identifier}-${appId}`;
const existingServer = this.deviceTcpServers[cacheKey];
Expand Down Expand Up @@ -84,7 +80,17 @@ export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebu
return server;
}

public async addWebSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<ws.Server> {
public async ensureWebSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<ws.Server> {
const existingWebProxy = this.deviceWebServers[`${device.deviceInfo.identifier}-${appId}`];
const result = existingWebProxy || await this.addWebSocketProxy(device, appId);

// TODO: do not remove till VSCode waits for this message in order to reattach
this.$logger.info("Opened localhost " + result.options.port);

return result;
}

private async addWebSocketProxy(device: Mobile.IiOSDevice, appId: string): Promise<ws.Server> {
const cacheKey = `${device.deviceInfo.identifier}-${appId}`;
const existingServer = this.deviceWebServers[cacheKey];
if (existingServer) {
Expand All @@ -104,21 +110,23 @@ export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebu
const server = new ws.Server(<any>{
port: localPort,
host: "localhost",
verifyClient: async (info: any, callback: Function) => {
verifyClient: async (info: any, callback: (res: boolean, code?: number, message?: string) => void) => {
let acceptHandshake = true;
this.$logger.info("Frontend client connected.");
let appDebugSocket;
try {
appDebugSocket = await device.getDebugSocket(appId);
this.$logger.info("Backend socket created.");
info.req["__deviceSocket"] = appDebugSocket;
} catch (err) {
err.deviceIdentifier = device.deviceInfo.identifier;
this.$logger.trace(err);
this.emit(CONNECTION_ERROR_EVENT_NAME, err);
this.$errors.failWithoutHelp(`Cannot connect to device socket.The error message is ${err.message} `);
acceptHandshake = false;
this.$logger.warn(`Cannot connect to device socket. The error message is '${err.message}'. Try starting the application manually.`);
}

this.$logger.info("Backend socket created.");
info.req["__deviceSocket"] = appDebugSocket;
callback(true);
callback(acceptHandshake);
}
});
this.deviceWebServers[cacheKey] = server;
Expand Down Expand Up @@ -152,12 +160,11 @@ export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebu
appDebugSocket.on("close", () => {
this.$logger.info("Backend socket closed!");
webSocket.close();
server.close();
delete this.deviceWebServers[cacheKey];
});

webSocket.on("close", () => {
this.$logger.info('Frontend socket closed!');
appDebugSocket.unpipe(packets);
packets.destroy();
device.destroyDebugSocket(appId);
if (!this.$options.watch) {
Expand All @@ -167,7 +174,6 @@ export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebu

});

this.$logger.info("Opened localhost " + localPort);
return server;
}

Expand Down
19 changes: 12 additions & 7 deletions lib/services/android-device-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi
this.deviceIdentifier = device.deviceInfo.identifier;
}

public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo> {
this._packageName = debugData.applicationIdentifier;
const result = this.device.isEmulator
? await this.debugOnEmulator(debugData, debugOptions)
Expand Down Expand Up @@ -59,7 +59,7 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi
return this.removePortForwarding();
}

private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo> {
// Assure we've detected the emulator as device
// For example in case deployOnEmulator had stated new emulator instance
// we need some time to detect it. Let's force detection.
Expand Down Expand Up @@ -97,7 +97,7 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi
return this.device.adb.executeCommand(["forward", `tcp:${local}`, `localabstract:${remote}`]);
}

private async debugOnDevice(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
private async debugOnDevice(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo> {
let packageFile = "";

if (!debugOptions.start && !this.device.isEmulator) {
Expand All @@ -113,27 +113,32 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi
projectName
};

const action = (device: Mobile.IAndroidDevice): Promise<string> => this.debugCore(device, packageFile, appData, debugOptions);
const action = (device: Mobile.IAndroidDevice): Promise<IDebugResultInfo> => this.debugCore(device, packageFile, appData, debugOptions);

const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(this.deviceIdentifier));
return deviceActionResult[0].result;
}

private async debugCore(device: Mobile.IAndroidDevice, packageFile: string, appData: Mobile.IApplicationData, debugOptions: IDebugOptions): Promise<string> {
private async debugCore(device: Mobile.IAndroidDevice, packageFile: string, appData: Mobile.IApplicationData, debugOptions: IDebugOptions): Promise<IDebugResultInfo> {
const result: IDebugResultInfo = { hasReconnected: false, debugUrl: null };

if (debugOptions.stop) {
await this.removePortForwarding();
return null;
return result;
}

if (!debugOptions.start) {
await this.debugStartCore(appData, debugOptions);
result.hasReconnected = true;
}

await this.validateRunningApp(device.deviceInfo.identifier, appData.appId);
const debugPort = await this.getForwardedDebugPort(device.deviceInfo.identifier, appData.appId);
await this.printDebugPort(device.deviceInfo.identifier, debugPort);

return this.getChromeDebugUrl(debugOptions, debugPort);
result.debugUrl = this.getChromeDebugUrl(debugOptions, debugPort);

return result;
}

private async printDebugPort(deviceId: string, port: number): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/debug-service-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe

public abstract get platform(): string;

public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string>;
public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo>;

public abstract async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void>;

Expand Down
21 changes: 8 additions & 13 deletions lib/services/debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ export class DebugService extends EventEmitter implements IDebugService {
}

const debugOptions: IDebugOptions = _.cloneDeep(options);

// TODO: Check if app is running.
// For now we can only check if app is running on Android.
// After we find a way to check on iOS we should use it here.
let result: string;

const debugService = this.getDeviceDebugService(device);
if (!debugService) {
this.$errors.failWithoutHelp(`Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.`);
Expand All @@ -62,9 +56,9 @@ export class DebugService extends EventEmitter implements IDebugService {
}
}

result = await debugService.debug(debugData, debugOptions);
const debugResultInfo = await debugService.debug(debugData, debugOptions);

return this.getDebugInformation(result, device.deviceInfo.identifier);
return this.getDebugInformation(debugResultInfo, device.deviceInfo.identifier);
}

public debugStop(deviceIdentifier: string): Promise<void> {
Expand Down Expand Up @@ -100,16 +94,17 @@ export class DebugService extends EventEmitter implements IDebugService {
platformDebugService.on(CONNECTION_ERROR_EVENT_NAME, connectionErrorHandler);
}

private getDebugInformation(fullUrl: string, deviceIdentifier: string): IDebugInformation {
private getDebugInformation(debugResultInfo: IDebugResultInfo, deviceIdentifier: string): IDebugInformation {
const debugInfo: IDebugInformation = {
url: fullUrl,
url: debugResultInfo.debugUrl,
port: 0,
deviceIdentifier
deviceIdentifier,
hasReconnected: debugResultInfo.hasReconnected
};

if (fullUrl) {
if (debugResultInfo.debugUrl) {
const parseQueryString = true;
const wsQueryParam = <string>parse(fullUrl, parseQueryString).query.ws;
const wsQueryParam = <string>parse(debugResultInfo.debugUrl, parseQueryString).query.ws;
const hostPortSplit = wsQueryParam && wsQueryParam.split(":");
debugInfo.port = hostPortSplit && +hostPortSplit[1];
}
Expand Down
11 changes: 7 additions & 4 deletions lib/services/ios-device-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,21 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
return "ios";
}

public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo> {
const result: IDebugResultInfo = { hasReconnected: false, debugUrl: null };
this.validateOptions(debugOptions);

await this.startDeviceLogProcess(debugData, debugOptions);
await this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(this.device, debugData, debugOptions);

if (!debugOptions.start) {
await this.startApp(debugData, debugOptions);
result.hasReconnected = true;
}

return this.wireDebuggerClient(debugData, debugOptions);
result.debugUrl = await this.wireDebuggerClient(debugData, debugOptions);

return result;
}

public async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void> {
Expand Down Expand Up @@ -160,8 +164,7 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
if (debugOptions.chrome) {
this.$logger.info("'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector.");
}
const existingWebProxy = this.$appDebugSocketProxyFactory.getWebSocketProxy(this.deviceIdentifier, debugData.applicationIdentifier);
const webSocketProxy = existingWebProxy || await this.$appDebugSocketProxyFactory.addWebSocketProxy(this.device, debugData.applicationIdentifier);
const webSocketProxy = await this.$appDebugSocketProxyFactory.ensureWebSocketProxy(this.device, debugData.applicationIdentifier);

return this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port);
}
Expand Down
Loading