microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/common/exponent/exponentPlatform.ts
43lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import {ErrorHelper} from "../error/errorHelper"; |
| 5 | import {InternalErrorCode} from "../error/internalErrorCode"; |
| 6 | import {IRunOptions} from "../launchArgs"; |
| 7 | import {Log} from "../log/log"; |
| 8 | import {GeneralMobilePlatform} from "../generalMobilePlatform"; |
| 9 | |
| 10 | import * as Q from "q"; |
| 11 | |
| 12 | export class ExponentPlatform extends GeneralMobilePlatform { |
| 13 | private exponentTunnelPath: string; |
| 14 | |
| 15 | constructor(runOptions: IRunOptions, { remoteExtension = null } = {}) { |
| 16 | super(runOptions, { remoteExtension: remoteExtension }); |
| 17 | this.exponentTunnelPath = null; |
| 18 | } |
| 19 | |
| 20 | public runApp(): Q.Promise<void> { |
| 21 | const outputMessage = `Application is running on Exponent. Open your exponent app at ${this.exponentTunnelPath} to see it.`; |
| 22 | Log.logMessage(outputMessage); |
| 23 | this.remoteExtension.showInformationMessage(outputMessage); |
| 24 | return Q.resolve<void>(void 0); |
| 25 | } |
| 26 | |
| 27 | public enableJSDebuggingMode(): Q.Promise<void> { |
| 28 | Log.logMessage("Application is running on Exponent. Please shake device and select 'Debug JS Remotely' to enable debugging."); |
| 29 | return Q.resolve<void>(void 0); |
| 30 | } |
| 31 | |
| 32 | public startPackager(): Q.Promise<void> { |
| 33 | Log.logMessage("Starting Exponent Packager."); |
| 34 | return this.remoteExtension.startExponentPackager() |
| 35 | .then(exponentUrl => { |
| 36 | if (!exponentUrl) { |
| 37 | return Q.reject<void>(ErrorHelper.getInternalError(InternalErrorCode.ExpectedExponentTunnelPath, |
| 38 | "No link provided by exponent. Is your project correctly setup?")); |
| 39 | } |
| 40 | this.exponentTunnelPath = exponentUrl; |
| 41 | }); |
| 42 | } |
| 43 | } |