Skip to content

Commit 6f91fc4

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #42 from telerik/fatme/expose-publicApi
Expose public api
2 parents 73a36d5 + af5ffcf commit 6f91fc4

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

lib/ios-sim.js

-13
This file was deleted.

lib/ios-sim.ts

+38
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,41 @@ var fiber = Fiber(() => {
1414
});
1515

1616
fiber.run();
17+
18+
global.publicApi = {};
19+
20+
Object.defineProperty(global.publicApi, "getRunningSimulator", {
21+
get: () => {
22+
return (...args: any[]) => {
23+
let future = new Future<any>();
24+
let libraryPath = require("./iphone-simulator-xcode-7");
25+
let simulator = new libraryPath.XCode7Simulator();
26+
let repeatCount = 30;
27+
let timer = setInterval(() => {
28+
Fiber(() => {
29+
let result = simulator.getBootedDevice.apply(simulator, args).wait();
30+
if( (result || !repeatCount) && !future.isResolved()) {
31+
clearInterval(timer);
32+
future.return(result);
33+
}
34+
repeatCount--;
35+
}).run();
36+
}, 500);
37+
return future.wait();
38+
}
39+
}
40+
});
41+
42+
Object.defineProperty(global.publicApi, "getApplicationPath", {
43+
get: () => {
44+
return (...args: any[]) => {
45+
let libraryPath = require("./simctl");
46+
let obj = new libraryPath.Simctl()
47+
let result = obj.getAppContainer.apply(obj, args).wait();
48+
return result;
49+
}
50+
}
51+
});
52+
53+
54+
module.exports = global.publicApi;

lib/simctl.ts

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class Simctl implements ISimctl {
3737
return this.simctlExec("notify_post", [deviceId, notification]);
3838
}
3939

40+
public getAppContainer(deviceId: string, applicationIdentifier: string): IFuture<string> {
41+
return this.simctlExec("get_app_container", [deviceId, applicationIdentifier]);
42+
}
43+
4044
public getDevices(): IFuture<IDevice[]> {
4145
return (() => {
4246
if(!this.devices) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-sim-portable",
3-
"version": "1.0.12-gamma",
3+
"version": "1.0.13-beta",
44
"description": "",
55
"main": "./lib/ios-sim.js",
66
"scripts": {

0 commit comments

Comments
 (0)