microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/common/exponent/exponentPlatform.ts
43lines · modeblame
1c32fe84Patricio Beltran9 years ago | 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"; | |
5c8365a6Artem Egorov8 years ago | 8 | import {GeneralMobilePlatform, MobilePlatformDeps} from "../generalMobilePlatform"; |
1c32fe84Patricio Beltran9 years ago | 9 | |
| 10 | import * as Q from "q"; | |
| 11 | | |
| 12 | export class ExponentPlatform extends GeneralMobilePlatform { | |
5c8365a6Artem Egorov8 years ago | 13 | private exponentTunnelPath: string | null; |
1c32fe84Patricio Beltran9 years ago | 14 | |
5c8365a6Artem Egorov8 years ago | 15 | constructor(runOptions: IRunOptions, {remoteExtension}: MobilePlatformDeps = {}) { |
1c32fe84Patricio Beltran9 years ago | 16 | super(runOptions, { remoteExtension: remoteExtension }); |
| 17 | this.exponentTunnelPath = null; | |
| 18 | } | |
| 19 | | |
| 20 | public runApp(): Q.Promise<void> { | |
280c0746Patricio Beltran9 years ago | 21 | const outputMessage = `Application is running on Exponent. Open your exponent app at ${this.exponentTunnelPath} to see it.`; |
| 22 | Log.logMessage(outputMessage); | |
1c32fe84Patricio Beltran9 years ago | 23 | return Q.resolve<void>(void 0); |
| 24 | } | |
| 25 | | |
| 26 | public enableJSDebuggingMode(): Q.Promise<void> { | |
| 27 | Log.logMessage("Application is running on Exponent. Please shake device and select 'Debug JS Remotely' to enable debugging."); | |
| 28 | return Q.resolve<void>(void 0); | |
| 29 | } | |
| 30 | | |
| 31 | public startPackager(): Q.Promise<void> { | |
4052c7eddaserge9 years ago | 32 | Log.logMessage("Starting Exponent Packager."); |
1c32fe84Patricio Beltran9 years ago | 33 | return this.remoteExtension.startExponentPackager() |
| 34 | .then(exponentUrl => { | |
| 35 | if (!exponentUrl) { | |
| 36 | return Q.reject<void>(ErrorHelper.getInternalError(InternalErrorCode.ExpectedExponentTunnelPath, | |
| 37 | "No link provided by exponent. Is your project correctly setup?")); | |
| 38 | } | |
| 39 | this.exponentTunnelPath = exponentUrl; | |
5c8365a6Artem Egorov8 years ago | 40 | return Q.resolve(void 0); |
1c32fe84Patricio Beltran9 years ago | 41 | }); |
| 42 | } | |
e23fa745Vladimir Kotikov9 years ago | 43 | } |