浏览代码

Upgrade typescript, @types/webrtc

Danilo Bargen 6 年之前
父节点
当前提交
544d6f115b
共有 6 个文件被更改,包括 38 次插入28 次删除
  1. 6 6
      package-lock.json
  2. 2 2
      package.json
  3. 6 4
      src/directives/avatar_editor.ts
  4. 11 8
      src/directives/compose_area.ts
  5. 5 5
      src/directives/drag_file.ts
  6. 8 3
      src/services/webclient.ts

+ 6 - 6
package-lock.json

@@ -822,9 +822,9 @@
       "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg=="
     },
     "@types/webrtc": {
-      "version": "0.0.23",
-      "resolved": "https://registry.npmjs.org/@types/webrtc/-/webrtc-0.0.23.tgz",
-      "integrity": "sha512-mq3RpNvVoR2r5ts7gGJh+uHv2wgLUdu1r+rwsZoR5tmb9pCtj8uMC1BWpYQF/SZBtPaj9RfnbIvudk+ajdXP4w=="
+      "version": "0.0.24",
+      "resolved": "https://registry.npmjs.org/@types/webrtc/-/webrtc-0.0.24.tgz",
+      "integrity": "sha512-6+tx3/EinMqQriXezCSS2AlbYAYSimGi9GTWuCDhZihm5fXqJjMYeo4enoakllhJnXErdkxsRt7+ELwRV8Ckkg=="
     },
     "@uirouter/angularjs": {
       "version": "1.0.20",
@@ -8383,9 +8383,9 @@
       "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
     },
     "typescript": {
-      "version": "2.9.2",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz",
-      "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w=="
+      "version": "3.2.2",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz",
+      "integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg=="
     },
     "ultron": {
       "version": "1.1.1",

+ 2 - 2
package.json

@@ -44,7 +44,7 @@
     "@types/file-saver": "^2.0.0",
     "@types/jquery": "^3.3.29",
     "@types/msgpack-lite": "^0.1.6",
-    "@types/webrtc": "0.0.23",
+    "@types/webrtc": "0.0.24",
     "@uirouter/angularjs": "^1.0.20",
     "angular": "^1.7.5",
     "angular-animate": "^1.7.5",
@@ -69,7 +69,7 @@
     "ts-events": "^3.1.5",
     "tsify": "^4.0.1",
     "tweetnacl": "^1.0.0",
-    "typescript": "^2.9.2",
+    "typescript": "^3.2.2",
     "webrtc-adapter": "^7.1.1"
   },
   "devDependencies": {

+ 6 - 4
src/directives/avatar_editor.ts

@@ -100,14 +100,16 @@ export default [
                 function fetchFileContent(file: File): Promise<ArrayBuffer> {
                     return new Promise((resolve, reject) => {
                         const reader = new FileReader();
-                        reader.onload = function(ev: FileReaderProgressEvent) {
-                            resolve(ev.target.result);
+                        reader.onload = function(ev: ProgressEvent) {
+                            // The result will be an ArrayBuffer because we call
+                            // the `FileReader.readAsArrayBuffer` method.
+                            resolve(this.result as ArrayBuffer);
                         };
-                        reader.onerror = function(ev: FileReaderProgressEvent) {
+                        reader.onerror = function(ev: ProgressEvent) {
                             // set a null object
                             reject(ev);
                         };
-                        reader.onprogress = function(ev: FileReaderProgressEvent) {
+                        reader.onprogress = function(ev: ProgressEvent) {
                             if (ev.lengthComputable) {
                                 // TODO implement progress?
                                 // let progress = ((data.loaded / data.total) * 100);

+ 11 - 8
src/directives/compose_area.ts

@@ -311,14 +311,14 @@ export default [
                         for (let n = 0; n < fileCounter; n++) {
                             const reader = new FileReader();
                             const file = fileList.item(n);
-                            reader.onload = function(ev: FileReaderProgressEvent) {
-                                next(file, ev.target.result, ev);
+                            reader.onload = function(ev: ProgressEvent) {
+                                next(file, this.result as ArrayBuffer, ev);
                             };
-                            reader.onerror = function(ev: FileReaderProgressEvent) {
+                            reader.onerror = function(ev: ProgressEvent) {
                                 // set a null object
                                 next(file, null, ev);
                             };
-                            reader.onprogress = function(ev: FileReaderProgressEvent) {
+                            reader.onprogress = function(ev: ProgressEvent) {
                                 if (ev.lengthComputable) {
                                     const progress = ((ev.loaded / ev.total) * 100);
                                     scope.onUploading(true, progress, 100 / fileCounter * n);
@@ -393,8 +393,8 @@ export default [
 
                         // Convert blob to arraybuffer
                         const reader = new FileReader();
-                        reader.onload = function(progressEvent: FileReaderProgressEvent) {
-                            const buffer: ArrayBuffer = this.result;
+                        reader.onload = function(progressEvent: ProgressEvent) {
+                            const buffer: ArrayBuffer = this.result as ArrayBuffer;
 
                             // Construct file name
                             let fileName: string;
@@ -642,10 +642,13 @@ export default [
                     }
 
                     if (browserService.getBrowser().isFirefox(false)) {
-                        // disable object resizing is the only way to disable resizing of
+                        // Disabling object resizing is the only way to disable resizing of
                         // emoji (contenteditable must be true, otherwise the emoji can not
                         // be removed with backspace (in FF))
-                        document.execCommand('enableObjectResizing', false, false);
+                        //
+                        // Note: This is not required anymore for FF63+ (but
+                        // please test before removing it to make sure).
+                        (document.execCommand as any)('enableObjectResizing', false, false);
                     }
                 }
 

+ 5 - 5
src/directives/drag_file.ts

@@ -43,7 +43,7 @@ export default [
                 function fetchFileListContents(fileList: FileList): Promise<Map<File, ArrayBuffer>> {
                     return new Promise((resolve) => {
                         const buffers = new Map<File, ArrayBuffer>();
-                        const next = (file: File, res: ArrayBuffer | null, error?: FileReaderProgressEvent) => {
+                        const next = (file: File, res: ArrayBuffer | null, error?: ProgressEvent) => {
                             buffers.set(file, res);
                             if (buffers.size >= fileList.length) {
                                 resolve(buffers);
@@ -56,14 +56,14 @@ export default [
                         for (let n = 0; n < fileList.length; n++) {
                             const reader = new FileReader();
                             const file = fileList.item(n);
-                            reader.onload = function(ev: FileReaderProgressEvent) {
-                                next(file, ev.target.result);
+                            reader.onload = function(ev: ProgressEvent) {
+                                next(file, this.result as ArrayBuffer);
                             };
-                            reader.onerror = function(ev: FileReaderProgressEvent) {
+                            reader.onerror = function(ev: ProgressEvent) {
                                 // set a null object
                                 next(file, null, ev);
                             };
-                            reader.onprogress = function(ev: FileReaderProgressEvent) {
+                            reader.onprogress = function(ev: ProgressEvent) {
                                 if (ev.lengthComputable) {
                                     const progress = ((ev.loaded / ev.total) * 100);
                                     scope.onUploading(true, progress, 100 / fileList.length * n);

+ 8 - 3
src/services/webclient.ts

@@ -26,7 +26,10 @@ import {
     arraysAreEqual, copyDeep, hasFeature, hasValue, hexToU8a,
     msgpackVisualizer, randomString, stringToUtf8a, u8aToHex,
 } from '../helpers';
-import {isContactReceiver, isDistributionListReceiver, isGroupReceiver, isValidReceiverType} from '../typeguards';
+import {
+    isContactReceiver, isDistributionListReceiver,
+    isGroupReceiver, isValidReceiverType,
+} from '../typeguards';
 import {BatteryStatusService} from './battery';
 import {BrowserService} from './browser';
 import {TrustedKeyStoreService} from './keystore';
@@ -1210,7 +1213,8 @@ export class WebClientService {
             // There's at least one TURN server with TCP transport in the list
             for (const server of this.config.ICE_SERVERS) {
                 // Remove TLS entries
-                server.urls = server.urls.filter((url) => !url.startsWith('turns:'));
+                const urls = Array.isArray(server.urls) ? server.urls : [server.urls];
+                server.urls = urls.filter((url) => !url.startsWith('turns:'));
             }
         } else {
             this.$log.debug(this.logTag, 'No fallback TURN TCP server present, keeping TURNS server');
@@ -1229,7 +1233,8 @@ export class WebClientService {
         if (allUrls.some((url) => url.includes('ds-turn.threema.ch'))) {
             for (const server of this.config.ICE_SERVERS) {
                 // Replace dual stack entries
-                server.urls = server.urls.map((url) => {
+                const urls = Array.isArray(server.urls) ? server.urls : [server.urls];
+                server.urls = urls.map((url) => {
                     return url.replace('ds-turn.threema.ch', 'turn.threema.ch');
                 });
             }