Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Placeholder PR for cleaner diffs: Sourcemaps #3816

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0b0fe92
Convert resizer to ES6
turt2live Dec 17, 2019
344dac4
Convert CommonJS exports to ES6-compatible exports
turt2live Dec 20, 2019
4aec432
Convert the more complicated CommonJS exports to ES6-style
turt2live Dec 20, 2019
5a17406
Merge branch 'travis/babel7-wp-es6-js-sdk' into travis/babel7-wp-es6-mcp
turt2live Dec 23, 2019
042bd35
Fix MatrixClientPeg imports
turt2live Dec 20, 2019
f1ac3d2
Convert imports to ES6 from CommonJS
turt2live Dec 20, 2019
0c11e03
Merge branch 'travis/babel7-wp-es6-imports-2' into travis/sourcemaps-es6
turt2live Dec 23, 2019
d002c2c
Merge branch 'travis/babel7-wp-es6-export' into travis/sourcemaps-es6
turt2live Dec 23, 2019
2461993
Merge branch 'travis/sourcemaps-es6' into travis/babel7-wp-es6-fixes
turt2live Dec 23, 2019
0d2cb6e
Import haveTileForEvent() from the right place
turt2live Dec 20, 2019
615648a
Fix tabbed view export for component index
turt2live Dec 23, 2019
18ac2db
Fix Notifier imports in NotificationControllers
turt2live Dec 20, 2019
539a33c
Fix naming conflict in VectorConferenceHandler
turt2live Dec 20, 2019
d8da634
Cosmetic updates to package.json
turt2live Dec 20, 2019
69424f4
Add package.json fields for riot-web's webpack
turt2live Dec 20, 2019
3eb3be4
Fix import of language index
turt2live Dec 20, 2019
9edc361
Use new imports for js-sdk's ContentRepo
turt2live Jan 3, 2020
206d4c7
Fix references to 'this' in Avatar and Unread
turt2live Jan 3, 2020
9213f88
Re-add docs
turt2live Jan 7, 2020
4c446e7
Merge branch 'travis/babel7-wp-package' into travis/sourcemaps-dev
turt2live Jan 7, 2020
4260d6a
Merge branch 'travis/babel7-wp-es6-imports-2' into travis/sourcemaps-dev
turt2live Jan 7, 2020
bbb0be6
Merge branch 'travis/babel7-wp-es6-fixes' into travis/sourcemaps-dev
turt2live Jan 7, 2020
4bb5e4e
Merge branch 'travis/babel7-wp-es6-export' into travis/sourcemaps-dev
turt2live Jan 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
},
"license": "Apache-2.0",
"files": [
"lib",
"res",
"src",
"scripts",
"git-revision.txt",
"docs",
"header",
"CHANGELOG.md",
"CONTRIBUTING.rst",
"LICENSE",
"README.md",
"code_style.md",
"git-revision.txt",
"header",
"lib",
"package.json",
"scripts",
"docs",
"src",
"res"
"package.json"
],
"bin": {
"reskindex": "scripts/reskindex.js",
"matrix-gen-i18n": "scripts/gen-i18n.js",
"matrix-prune-i18n": "scripts/prune-i18n.js"
},
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"matrix_src_main": "./src/index.js",
"scripts": {
"i18n": "matrix-gen-i18n",
"prunei18n": "matrix-prune-i18n",
Expand All @@ -40,7 +40,7 @@
"rethemendex": "res/css/rethemendex.sh",
"clean": "rimraf lib",
"build": "yarn clean && git rev-parse HEAD > git-revision.txt && yarn build:compile && yarn build:types",
"build:compile": "yarn reskindex && babel src -s -d lib --verbose --extensions \".ts,.js\"",
"build:compile": "yarn reskindex && babel -d lib --verbose --extensions \".ts,.js\" src",
"build:types": "tsc --emitDeclarationOnly",
"start": "echo THIS IS FOR LEGACY PURPOSES ONLY. && yarn start:all",
"start:all": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n build,reskindex \"yarn start:build\" \"yarn reskindex:watch\"",
Expand Down
2 changes: 1 addition & 1 deletion src/AddThreepid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import MatrixClientPeg from './MatrixClientPeg';
import {MatrixClientPeg} from './MatrixClientPeg';
import * as sdk from './index';
import Modal from './Modal';
import { _t } from './languageHandler';
Expand Down
2 changes: 1 addition & 1 deletion src/Analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,4 @@ class Analytics {
if (!global.mxAnalytics) {
global.mxAnalytics = new Analytics();
}
module.exports = global.mxAnalytics;
export default global.mxAnalytics;
198 changes: 98 additions & 100 deletions src/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,120 +15,118 @@ limitations under the License.
*/

'use strict';
import {ContentRepo} from 'matrix-js-sdk';
import MatrixClientPeg from './MatrixClientPeg';
import {MatrixClientPeg} from './MatrixClientPeg';
import DMRoomMap from './utils/DMRoomMap';
import {getHttpUriForMxc} from "matrix-js-sdk/src/content-repo";

module.exports = {
avatarUrlForMember: function(member, width, height, resizeMethod) {
let url = member.getAvatarUrl(
MatrixClientPeg.get().getHomeserverUrl(),
Math.floor(width * window.devicePixelRatio),
Math.floor(height * window.devicePixelRatio),
resizeMethod,
false,
false,
);
if (!url) {
// member can be null here currently since on invites, the JS SDK
// does not have enough info to build a RoomMember object for
// the inviter.
url = this.defaultAvatarUrlForString(member ? member.userId : '');
}
return url;
},
export function avatarUrlForMember(member, width, height, resizeMethod) {
let url = member.getAvatarUrl(
MatrixClientPeg.get().getHomeserverUrl(),
Math.floor(width * window.devicePixelRatio),
Math.floor(height * window.devicePixelRatio),
resizeMethod,
false,
false,
);
if (!url) {
// member can be null here currently since on invites, the JS SDK
// does not have enough info to build a RoomMember object for
// the inviter.
url = defaultAvatarUrlForString(member ? member.userId : '');
}
return url;
}

avatarUrlForUser: function(user, width, height, resizeMethod) {
const url = ContentRepo.getHttpUriForMxc(
MatrixClientPeg.get().getHomeserverUrl(), user.avatarUrl,
Math.floor(width * window.devicePixelRatio),
Math.floor(height * window.devicePixelRatio),
resizeMethod,
);
if (!url || url.length === 0) {
return null;
}
return url;
},
export function avatarUrlForUser(user, width, height, resizeMethod) {
const url = getHttpUriForMxc(
MatrixClientPeg.get().getHomeserverUrl(), user.avatarUrl,
Math.floor(width * window.devicePixelRatio),
Math.floor(height * window.devicePixelRatio),
resizeMethod,
);
if (!url || url.length === 0) {
return null;
}
return url;
}

defaultAvatarUrlForString: function(s) {
const images = ['03b381', '368bd6', 'ac3ba8'];
let total = 0;
for (let i = 0; i < s.length; ++i) {
total += s.charCodeAt(i);
}
return require('../res/img/' + images[total % images.length] + '.png');
},
export function defaultAvatarUrlForString(s) {
const images = ['03b381', '368bd6', 'ac3ba8'];
let total = 0;
for (let i = 0; i < s.length; ++i) {
total += s.charCodeAt(i);
}
return require('../res/img/' + images[total % images.length] + '.png');
}

/**
* returns the first (non-sigil) character of 'name',
* converted to uppercase
* @param {string} name
* @return {string} the first letter
*/
getInitialLetter(name) {
if (!name) {
// XXX: We should find out what causes the name to sometimes be falsy.
console.trace("`name` argument to `getInitialLetter` not supplied");
return undefined;
}
if (name.length < 1) {
return undefined;
}
/**
* returns the first (non-sigil) character of 'name',
* converted to uppercase
* @param {string} name
* @return {string} the first letter
*/
export function getInitialLetter(name) {
if (!name) {
// XXX: We should find out what causes the name to sometimes be falsy.
console.trace("`name` argument to `getInitialLetter` not supplied");
return undefined;
}
if (name.length < 1) {
return undefined;
}

let idx = 0;
const initial = name[0];
if ((initial === '@' || initial === '#' || initial === '+') && name[1]) {
idx++;
}
let idx = 0;
const initial = name[0];
if ((initial === '@' || initial === '#' || initial === '+') && name[1]) {
idx++;
}

// string.codePointAt(0) would do this, but that isn't supported by
// some browsers (notably PhantomJS).
let chars = 1;
const first = name.charCodeAt(idx);
// string.codePointAt(0) would do this, but that isn't supported by
// some browsers (notably PhantomJS).
let chars = 1;
const first = name.charCodeAt(idx);

// check if it’s the start of a surrogate pair
if (first >= 0xD800 && first <= 0xDBFF && name[idx+1]) {
const second = name.charCodeAt(idx+1);
if (second >= 0xDC00 && second <= 0xDFFF) {
chars++;
}
// check if it’s the start of a surrogate pair
if (first >= 0xD800 && first <= 0xDBFF && name[idx+1]) {
const second = name.charCodeAt(idx+1);
if (second >= 0xDC00 && second <= 0xDFFF) {
chars++;
}
}

const firstChar = name.substring(idx, idx+chars);
return firstChar.toUpperCase();
}

const firstChar = name.substring(idx, idx+chars);
return firstChar.toUpperCase();
},
export function avatarUrlForRoom(room, width, height, resizeMethod) {
const explicitRoomAvatar = room.getAvatarUrl(
MatrixClientPeg.get().getHomeserverUrl(),
width,
height,
resizeMethod,
false,
);
if (explicitRoomAvatar) {
return explicitRoomAvatar;
}

avatarUrlForRoom(room, width, height, resizeMethod) {
const explicitRoomAvatar = room.getAvatarUrl(
let otherMember = null;
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (otherUserId) {
otherMember = room.getMember(otherUserId);
} else {
// if the room is not marked as a 1:1, but only has max 2 members
// then still try to show any avatar (pref. other member)
otherMember = room.getAvatarFallbackMember();
}
if (otherMember) {
return otherMember.getAvatarUrl(
MatrixClientPeg.get().getHomeserverUrl(),
width,
height,
resizeMethod,
false,
);
if (explicitRoomAvatar) {
return explicitRoomAvatar;
}

let otherMember = null;
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (otherUserId) {
otherMember = room.getMember(otherUserId);
} else {
// if the room is not marked as a 1:1, but only has max 2 members
// then still try to show any avatar (pref. other member)
otherMember = room.getAvatarFallbackMember();
}
if (otherMember) {
return otherMember.getAvatarUrl(
MatrixClientPeg.get().getHomeserverUrl(),
width,
height,
resizeMethod,
false,
);
}
return null;
},
};
}
return null;
}
10 changes: 5 additions & 5 deletions src/CallHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ limitations under the License.
* }
*/

import MatrixClientPeg from './MatrixClientPeg';
import {MatrixClientPeg} from './MatrixClientPeg';
import PlatformPeg from './PlatformPeg';
import Modal from './Modal';
import * as sdk from './index';
Expand Down Expand Up @@ -302,7 +302,7 @@ function _onAction(payload) {
switch (payload.action) {
case 'place_call':
{
if (module.exports.getAnyActiveCall()) {
if (callHandler.getAnyActiveCall()) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Handler', 'Existing Call', ErrorDialog, {
title: _t('Existing Call'),
Expand Down Expand Up @@ -355,7 +355,7 @@ function _onAction(payload) {
break;
case 'incoming_call':
{
if (module.exports.getAnyActiveCall()) {
if (callHandler.getAnyActiveCall()) {
// ignore multiple incoming calls. in future, we may want a line-1/line-2 setup.
// we avoid rejecting with "busy" in case the user wants to answer it on a different device.
// in future we could signal a "local busy" as a warning to the caller.
Expand Down Expand Up @@ -523,7 +523,7 @@ if (!global.mxCallHandler) {

const callHandler = {
getCallForRoom: function(roomId) {
let call = module.exports.getCall(roomId);
let call = callHandler.getCall(roomId);
if (call) return call;

if (ConferenceHandler) {
Expand Down Expand Up @@ -583,4 +583,4 @@ if (global.mxCallHandler === undefined) {
global.mxCallHandler = callHandler;
}

module.exports = global.mxCallHandler;
export default global.mxCallHandler;
2 changes: 1 addition & 1 deletion src/ContentMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.

import extend from './extend';
import dis from './dispatcher';
import MatrixClientPeg from './MatrixClientPeg';
import {MatrixClientPeg} from './MatrixClientPeg';
import * as sdk from './index';
import { _t } from './languageHandler';
import Modal from './Modal';
Expand Down
2 changes: 1 addition & 1 deletion src/CrossSigningManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import Modal from './Modal';
import * as sdk from './index';
import MatrixClientPeg from './MatrixClientPeg';
import {MatrixClientPeg} from './MatrixClientPeg';
import { deriveKey } from 'matrix-js-sdk/src/crypto/key_passphrase';
import { decodeRecoveryKey } from 'matrix-js-sdk/src/crypto/recoverykey';
import { _t } from './languageHandler';
Expand Down
Loading