Skip to content

Commit 859fb5a

Browse files
authored
Migrate uProxy to Typescript v2
2 parents 6f90c37 + b310a48 commit 859fb5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+130
-129
lines changed

Gruntfile.js

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -636,38 +636,12 @@ module.exports = function(grunt) {
636636
}
637637
},
638638

639-
// One pass for code running inside freedom.js modules and another
640-
// for code running outside, due to the differences in the meaning
641-
// of the (global) freedom object between the two environments.
642639
ts: {
643-
options: {
644-
target: 'es5',
645-
comments: true,
646-
noImplicitAny: true,
647-
sourceMap: false,
648-
module: 'commonjs',
649-
fast: 'always',
650-
rootDir: '.'
651-
},
652-
moduleEnv: {
653-
src: [
654-
'src/**/*.ts',
655-
'!src/**/*.d.ts',
656-
'!src/lib/build-tools/**/*',
657-
'!src/integration/**/*',
658-
'!src/**/*.core-env.ts',
659-
'!src/**/*.core-env.spec.ts'
660-
],
661-
outDir: 'build'
662-
},
663-
coreEnv: {
664-
src: [
665-
'src/**/*.core-env.ts',
666-
'src/**/*.core-env.spec.ts',
667-
'!src/lib/build-tools/**/*.ts',
668-
'!src/integration/**/*.ts'
669-
],
670-
outDir: 'build'
640+
default: {
641+
tsconfig: {
642+
tsconfig: 'tsconfig.json',
643+
passThrough: true
644+
}
671645
}
672646
},
673647
browserify: {
@@ -1400,6 +1374,10 @@ module.exports = function(grunt) {
14001374
]);
14011375
registerTask(grunt, 'lint', ['jshint', 'tslint']);
14021376

1377+
grunt.registerTask('printConfig', function() {
1378+
grunt.log.writeln(JSON.stringify(grunt.config.getRaw(), null, 2));
1379+
});
1380+
14031381
//-------------------------------------------------------------------------
14041382
grunt.loadNpmTasks('grunt-browserify');
14051383
grunt.loadNpmTasks('grunt-contrib-clean');

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121
}
2222
],
2323
"devDependencies": {
24+
"@types/chrome": "0.0.34",
25+
"@types/circular-json": "^0.1.30",
26+
"@types/compare-version": "^0.1.30",
27+
"@types/filesystem": "0.0.28",
28+
"@types/filewriter": "0.0.28",
29+
"@types/jasmine": "^2.2.34",
30+
"@types/ssh2": "0.0.31",
31+
"@types/xregexp": "^3.0.28",
2432
"bower": "^1.4.1",
2533
"browserify-zlib": "^0.1.4",
2634
"cca": "^0.8.0",
2735
"circular-json": "^0.3.0",
2836
"compare-version": "^0.1.2",
29-
"es6-promise": "^3.2.1",
37+
"es6-promise": "^4.0.5",
3038
"forge-min": "^0.6.20",
3139
"freedom": "^0.6.31",
3240
"freedom-for-chrome": "^0.4.25",
@@ -58,7 +66,7 @@
5866
"grunt-string-replace": "^1.0.0",
5967
"grunt-subgrunt": "^1.2.0",
6068
"grunt-template-jasmine-istanbul": "^0.3.0",
61-
"grunt-ts": "^5.4.0",
69+
"grunt-ts": "^6.0.0-beta.3",
6270
"grunt-tslint": "^3.1.0",
6371
"grunt-verbosity": "^1.0.1",
6472
"grunt-vulcanize": "^0.6.0",
@@ -73,7 +81,7 @@
7381
"ssh2": "0.5.0",
7482
"time-grunt": "^1.4.0",
7583
"tslint": "^3.10.2",
76-
"typescript": "~1.8.10",
84+
"typescript": "^2.0.3",
7785
"typings": "^1.3.2",
7886
"uparams": "^1.2.0",
7987
"xregexp": "^2.0.0"

src/cca/app/scripts/cordova_core_connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CordovaCoreConnector implements browser_connector.CoreBrowserConnector {
4141
console.log('trying to connect to app');
4242
if (this.status.connected) {
4343
console.warn('Already connected.');
44-
return Promise.resolve<void>();
44+
return Promise.resolve();
4545
}
4646

4747
return this.connect_().then(() => {

src/chrome/extension/scripts/chrome_browser_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class ChromeBrowserApi implements BrowserAPI {
179179
} else if (this.popupState_ == PopupState.LAUNCHED) {
180180
// If the popup is already open, simply focus on it.
181181
chrome.windows.update(this.popupWindowId_, {focused: true});
182-
return Promise.resolve<void>();
182+
return Promise.resolve();
183183
} else {
184184
console.log('Waiting for popup to launch...');
185185
return this.onceLaunched_;

src/chrome/extension/scripts/chrome_core_connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ChromeCoreConnector implements browser_connector.CoreBrowserConnector {
7777
console.log('trying to connect to app');
7878
if (this.status.connected) {
7979
console.warn('Already connected.');
80-
return Promise.resolve<void>();
80+
return Promise.resolve();
8181
}
8282

8383
return this.connect_().then(this.flushQueue).then(() => {

src/firefox/data/scripts/firefox_connector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class FirefoxConnector implements browser_connector.CoreBrowserConnector {
2525

2626
public connect = () :Promise<void> => {
2727
this.emit('core_connect');
28-
this.onceConnected = Promise.resolve<void>();
29-
return Promise.resolve<void>();
28+
this.onceConnected = Promise.resolve();
29+
return Promise.resolve();
3030
}
3131

3232
/**

src/generic_core/remote-connection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var generateProxyingSessionId_ = (): string => {
109109
log.info('proxying session %1 initiated by remote peer', message.proxyingId);
110110
this.proxyingId_ = message.proxyingId;
111111
}
112-
return Promise.resolve<void>();
112+
return Promise.resolve();
113113
}
114114

115115
// Forwards a signalling message to the RemoteConnection.
@@ -199,7 +199,7 @@ var generateProxyingSessionId_ = (): string => {
199199
public stopShare = () :Promise<void> => {
200200
if (this.localSharingWithRemote === social.SharingState.NONE) {
201201
log.warn('Cannot stop sharing when neither sharing nor trying to share.');
202-
return Promise.resolve<void>();
202+
return Promise.resolve();
203203
}
204204

205205
this.localSharingWithRemote = social.SharingState.NONE;

src/generic_core/remote-instance.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('remote_instance.RemoteInstance', () => {
160160
expect(aliceState.localGettingFromRemote).toEqual(social.GettingState.NONE);
161161
alice.user.consent.localRequestsAccessFromRemote = true;
162162
alice.wireConsentFromRemote.isOffering = true;
163-
spyOn(socksToRtc, 'start').and.returnValue(Promise.resolve<void>());
163+
spyOn(socksToRtc, 'start').and.returnValue(Promise.resolve());
164164

165165
alice.start().then(() => {
166166
aliceState = alice.currentStateForUi();
@@ -230,7 +230,7 @@ describe('remote_instance.RemoteInstance', () => {
230230

231231
beforeEach(() => {
232232
alice = new remote_instance.RemoteInstance(user, 'instance-alice');
233-
alice['connection_'].onceSharerCreated = Promise.resolve<void>();
233+
alice['connection_'].onceSharerCreated = Promise.resolve();
234234

235235
user.consent.localGrantsAccessToRemote = true;
236236

@@ -259,7 +259,7 @@ describe('remote_instance.RemoteInstance', () => {
259259

260260
it('handles signal from server peer as client', (done) => {
261261
alice.wireConsentFromRemote.isOffering = true;
262-
spyOn(socksToRtc, 'start').and.returnValue(Promise.resolve<void>());
262+
spyOn(socksToRtc, 'start').and.returnValue(Promise.resolve());
263263

264264
alice.start().then(() => {
265265
alice.handleSignal({

src/generic_core/remote-instance.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ import ui = ui_connector.connector;
250250
// If the remote peer sent signal as the client, we act as server.
251251
if (!this.user.consent.localGrantsAccessToRemote) {
252252
log.warn('Remote side attempted access without permission');
253-
return Promise.resolve<void>();
253+
return Promise.resolve();
254254
}
255255

256256
// Create a new RtcToNet instance each time a new round of client peer
@@ -289,7 +289,7 @@ import ui = ui_connector.connector;
289289
type: type,
290290
data: signalFromRemote
291291
});
292-
return Promise.resolve<void>();
292+
return Promise.resolve();
293293
}
294294

295295
public verifyUser = (firstMsg ?:any) : void => {
@@ -381,7 +381,7 @@ import ui = ui_connector.connector;
381381
log.debug('startShare_');
382382
if (this.connection_.localSharingWithRemote === social.SharingState.NONE) {
383383
// Stop any existing sharing attempts with this instance.
384-
sharingStopped = Promise.resolve<void>();
384+
sharingStopped = Promise.resolve();
385385
} else {
386386
// Implies that the SharingState is TRYING_TO_SHARE_ACCESS because
387387
// the client peer should never be able to try to get if they are
@@ -421,7 +421,7 @@ import ui = ui_connector.connector;
421421
log.debug('stopShare()');
422422
if (this.connection_.localSharingWithRemote === social.SharingState.NONE) {
423423
log.warn('Cannot stop sharing while currently not sharing.');
424-
return Promise.resolve<void>();
424+
return Promise.resolve();
425425
}
426426

427427
if (this.connection_.localSharingWithRemote === social.SharingState.TRYING_TO_SHARE_ACCESS) {

src/generic_core/social.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ export function notifyUI(networkName :string, userId :string) {
702702
user.saveToStorage();
703703
// No need to update UI until they accept our invite.
704704
}
705-
return Promise.resolve<void>();
705+
return Promise.resolve();
706706
});
707707
}
708708

0 commit comments

Comments
 (0)