stop using default exports

because it becomes hard to remember where you used them and where not
This commit is contained in:
Bruno Windels 2020-04-20 21:26:39 +02:00
parent 0de5e899ea
commit 001dbefbcf
100 changed files with 257 additions and 259 deletions

View file

@ -1,4 +1,4 @@
export default class EventEmitter {
export class EventEmitter {
constructor() {
this._handlersByName = {};
}

View file

@ -1,5 +1,5 @@
//#ifdef PLATFORM_GNOME
//##export {default} from "./ui/gnome/GnomePlatform.js";
//#else
export {default} from "./ui/web/WebPlatform.js";
export {WebPlatform as Platform} from "./ui/web/WebPlatform.js";
//#endif

View file

@ -1,15 +1,15 @@
import Session from "../matrix/Session.js";
import {Session} from "../matrix/Session.js";
import {Sync} from "../matrix/Sync.js";
import SessionViewModel from "./session/SessionViewModel.js";
import LoginViewModel from "./LoginViewModel.js";
import SessionPickerViewModel from "./SessionPickerViewModel.js";
import EventEmitter from "../EventEmitter.js";
import {SessionViewModel} from "./session/SessionViewModel.js";
import {LoginViewModel} from "./LoginViewModel.js";
import {SessionPickerViewModel} from "./SessionPickerViewModel.js";
import {EventEmitter} from "../EventEmitter.js";
export function createNewSessionId() {
return (Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)).toString();
}
export default class BrawlViewModel extends EventEmitter {
export class BrawlViewModel extends EventEmitter {
constructor({storageFactory, sessionInfoStorage, createHsApi, clock}) {
super();
this._storageFactory = storageFactory;

View file

@ -1,6 +1,6 @@
import EventEmitter from "../EventEmitter.js";
import {EventEmitter} from "../EventEmitter.js";
export default class LoginViewModel extends EventEmitter {
export class LoginViewModel extends EventEmitter {
constructor({loginCallback, defaultHomeServer, createHsApi}) {
super();
this._loginCallback = loginCallback;

View file

@ -1,5 +1,5 @@
import {SortedArray} from "../observable/index.js";
import EventEmitter from "../EventEmitter.js";
import {EventEmitter} from "../EventEmitter.js";
import {createNewSessionId} from "./BrawlViewModel.js"
class SessionItemViewModel extends EventEmitter {
@ -98,7 +98,7 @@ class SessionItemViewModel extends EventEmitter {
}
}
export default class SessionPickerViewModel {
export class SessionPickerViewModel {
constructor({storageFactory, sessionInfoStorage, sessionCallback}) {
this._storageFactory = storageFactory;
this._sessionInfoStorage = sessionInfoStorage;

View file

@ -1,9 +1,9 @@
import EventEmitter from "../../EventEmitter.js";
import RoomTileViewModel from "./roomlist/RoomTileViewModel.js";
import RoomViewModel from "./room/RoomViewModel.js";
import SyncStatusViewModel from "./SyncStatusViewModel.js";
import {EventEmitter} from "../../EventEmitter.js";
import {RoomTileViewModel} from "./roomlist/RoomTileViewModel.js";
import {RoomViewModel} from "./room/RoomViewModel.js";
import {SyncStatusViewModel} from "./SyncStatusViewModel.js";
export default class SessionLoadViewModel extends ViewModel {
export class SessionLoadViewModel extends ViewModel {
constructor(options) {
super(options);
this._sessionContainer = options.sessionContainer;

View file

@ -1,9 +1,9 @@
import EventEmitter from "../../EventEmitter.js";
import RoomTileViewModel from "./roomlist/RoomTileViewModel.js";
import RoomViewModel from "./room/RoomViewModel.js";
import SyncStatusViewModel from "./SyncStatusViewModel.js";
import {EventEmitter} from "../../EventEmitter.js";
import {RoomTileViewModel} from "./roomlist/RoomTileViewModel.js";
import {RoomViewModel} from "./room/RoomViewModel.js";
import {SyncStatusViewModel} from "./SyncStatusViewModel.js";
export default class SessionViewModel extends EventEmitter {
export class SessionViewModel extends EventEmitter {
constructor({session, sync}) {
super();
this._session = session;

View file

@ -1,6 +1,6 @@
import EventEmitter from "../../EventEmitter.js";
import {EventEmitter} from "../../EventEmitter.js";
export default class SyncStatusViewModel extends EventEmitter {
export class SyncStatusViewModel extends EventEmitter {
constructor(sync) {
super();
this._sync = sync;

View file

@ -1,8 +1,8 @@
import EventEmitter from "../../../EventEmitter.js";
import TimelineViewModel from "./timeline/TimelineViewModel.js";
import {EventEmitter} from "../../../EventEmitter.js";
import {TimelineViewModel} from "./timeline/TimelineViewModel.js";
import {avatarInitials} from "../avatar.js";
export default class RoomViewModel extends EventEmitter {
export class RoomViewModel extends EventEmitter {
constructor({room, ownUserId, closeCallback}) {
super();
this._room = room;

View file

@ -1,12 +1,12 @@
import BaseObservableList from "../../../../observable/list/BaseObservableList.js";
import sortedIndex from "../../../../utils/sortedIndex.js";
import {BaseObservableList} from "../../../../observable/list/BaseObservableList.js";
import {sortedIndex} from "../../../../utils/sortedIndex.js";
// maps 1..n entries to 0..1 tile. Entries are what is stored in the timeline, either an event or fragmentboundary
// for now, tileCreator should be stable in whether it returns a tile or not.
// e.g. the decision to create a tile or not should be based on properties
// not updated later on (e.g. event type)
// also see big comment in onUpdate
export default class TilesCollection extends BaseObservableList {
export class TilesCollection extends BaseObservableList {
constructor(entries, tileCreator) {
super();
this._entries = entries;
@ -187,8 +187,8 @@ export default class TilesCollection extends BaseObservableList {
}
}
import ObservableArray from "../../../../observable/list/ObservableArray.js";
import UpdateAction from "./UpdateAction.js";
import {ObservableArray} from "../../../../observable/list/ObservableArray.js";
import {UpdateAction} from "./UpdateAction.js";
export function tests() {
class TestTile {

View file

@ -14,10 +14,10 @@ the timeline (counted in tiles), which results to a range in sortKeys we want on
to the room timeline, which unload entries from memory.
when loading, it just reads events from a sortkey backwards or forwards...
*/
import TilesCollection from "./TilesCollection.js";
import tilesCreator from "./tilesCreator.js";
import {TilesCollection} from "./TilesCollection.js";
import {tilesCreator} from "./tilesCreator.js";
export default class TimelineViewModel {
export class TimelineViewModel {
constructor(room, timeline, ownUserId) {
this._timeline = timeline;
// once we support sending messages we could do

View file

@ -1,4 +1,4 @@
export default class UpdateAction {
export class UpdateAction {
constructor(remove, update, updateParams) {
this._remove = remove;
this._update = update;

View file

@ -1,7 +1,7 @@
import SimpleTile from "./SimpleTile.js";
import UpdateAction from "../UpdateAction.js";
import {SimpleTile} from "./SimpleTile.js";
import {UpdateAction} from "../UpdateAction.js";
export default class GapTile extends SimpleTile {
export class GapTile extends SimpleTile {
constructor(options, timeline) {
super(options);
this._timeline = timeline;

View file

@ -1,6 +1,6 @@
import MessageTile from "./MessageTile.js";
import {MessageTile} from "./MessageTile.js";
export default class ImageTile extends MessageTile {
export class ImageTile extends MessageTile {
constructor(options) {
super(options);

View file

@ -1,4 +1,4 @@
import MessageTile from "./MessageTile.js";
import {MessageTile} from "./MessageTile.js";
/*
map urls:
@ -7,7 +7,7 @@ android: https://developers.google.com/maps/documentation/urls/guide
wp: maps:49.275267 -122.988617
https://www.habaneroconsulting.com/stories/insights/2011/opening-native-map-apps-from-the-mobile-browser
*/
export default class LocationTile extends MessageTile {
export class LocationTile extends MessageTile {
get mapsLink() {
const geoUri = this._getContent().geo_uri;
const [lat, long] = geoUri.split(":")[1].split(",");

View file

@ -1,6 +1,6 @@
import SimpleTile from "./SimpleTile.js";
import {SimpleTile} from "./SimpleTile.js";
export default class MessageTile extends SimpleTile {
export class MessageTile extends SimpleTile {
constructor(options) {
super(options);

View file

@ -1,6 +1,6 @@
import SimpleTile from "./SimpleTile.js";
import {SimpleTile} from "./SimpleTile.js";
export default class RoomNameTile extends SimpleTile {
export class RoomMemberTile extends SimpleTile {
get shape() {
return "announcement";

View file

@ -1,6 +1,6 @@
import SimpleTile from "./SimpleTile.js";
import {SimpleTile} from "./SimpleTile.js";
export default class RoomNameTile extends SimpleTile {
export class RoomNameTile extends SimpleTile {
get shape() {
return "announcement";

View file

@ -1,6 +1,6 @@
import UpdateAction from "../UpdateAction.js";
import {UpdateAction} from "../UpdateAction.js";
export default class SimpleTile {
export class SimpleTile {
constructor({entry}) {
this._entry = entry;
this._emitUpdate = null;

View file

@ -1,6 +1,6 @@
import MessageTile from "./MessageTile.js";
import {MessageTile} from "./MessageTile.js";
export default class TextTile extends MessageTile {
export class TextTile extends MessageTile {
get text() {
const content = this._getContent();
const body = content && content.body;

View file

@ -1,10 +1,10 @@
import GapTile from "./tiles/GapTile.js";
import TextTile from "./tiles/TextTile.js";
import LocationTile from "./tiles/LocationTile.js";
import RoomNameTile from "./tiles/RoomNameTile.js";
import RoomMemberTile from "./tiles/RoomMemberTile.js";
import {GapTile} from "./tiles/GapTile.js";
import {TextTile} from "./tiles/TextTile.js";
import {LocationTile} from "./tiles/LocationTile.js";
import {RoomNameTile} from "./tiles/RoomNameTile.js";
import {RoomMemberTile} from "./tiles/RoomMemberTile.js";
export default function ({room, ownUserId}) {
export function tilesCreator({room, ownUserId}) {
return function tilesCreator(entry, emitUpdate) {
const options = {entry, emitUpdate, ownUserId};
if (entry.isGap) {

View file

@ -1,6 +1,6 @@
import {avatarInitials} from "../avatar.js";
export default class RoomTileViewModel {
export class RoomTileViewModel {
// we use callbacks to parent VM instead of emit because
// it would be annoying to keep track of subscriptions in
// parent for all RoomTileViewModels

View file

@ -1,13 +1,13 @@
import HomeServerApi from "./matrix/net/HomeServerApi.js";
import {HomeServerApi} from "./matrix/net/HomeServerApi.js";
// import {RecordRequester, ReplayRequester} from "./matrix/net/request/replay.js";
import fetchRequest from "./matrix/net/request/fetch.js";
import {fetchRequest} from "./matrix/net/request/fetch.js";
import {Reconnector} from "./matrix/net/Reconnector.js";
import StorageFactory from "./matrix/storage/idb/create.js";
import SessionInfoStorage from "./matrix/sessioninfo/localstorage/SessionInfoStorage.js";
import BrawlViewModel from "./domain/BrawlViewModel.js";
import BrawlView from "./ui/web/BrawlView.js";
import DOMClock from "./ui/web/dom/Clock.js";
import OnlineStatus from "./ui/web/dom/OnlineStatus.js";
import {StorageFactory} from "./matrix/storage/idb/create.js";
import {SessionInfoStorage} from "./matrix/sessioninfo/localstorage/SessionInfoStorage.js";
import {BrawlViewModel} from "./domain/BrawlViewModel.js";
import {BrawlView} from "./ui/web/BrawlView.js";
import {Clock as DOMClock} from "./ui/web/dom/Clock.js";
import {OnlineStatus} from "./ui/web/dom/OnlineStatus.js";
export default async function main(container) {
try {

View file

@ -1,4 +1,4 @@
import Platform from "../Platform.js";
import {Platform} from "../Platform.js";
import {HomeServerError, ConnectionError} from "./error.js";
export class RateLimitingBackoff {

View file

@ -1,9 +1,9 @@
import Room from "./room/room.js";
import {Room} from "./room/room.js";
import { ObservableMap } from "../observable/index.js";
import { SendScheduler, RateLimitingBackoff } from "./SendScheduler.js";
import User from "./User.js";
import {User} from "./User.js";
export default class Session {
export class Session {
// sessionInfo contains deviceId, userId and homeServer
constructor({storage, hsApi, sessionInfo}) {
this._storage = storage;

View file

@ -1,11 +1,11 @@
import createEnum from "../utils/enum.js";
import ObservableValue from "../observable/ObservableValue.js";
import HomeServerApi from "./net/HomeServerApi.js";
import {createEnum} from "../utils/enum.js";
import {ObservableValue} from "../observable/ObservableValue.js";
import {HomeServerApi} from "./net/HomeServerApi.js";
import {Reconnector, ConnectionStatus} from "./net/Reconnector.js";
import ExponentialRetryDelay from "./net/ExponentialRetryDelay.js";
import {ExponentialRetryDelay} from "./net/ExponentialRetryDelay.js";
import {HomeServerError, ConnectionError, AbortError} from "./error.js";
import {Sync, SyncStatus} from "./Sync.js";
import Session from "./Session.js";
import {Session} from "./Session.js";
export const LoadStatus = createEnum(
"NotLoading",

View file

@ -1,6 +1,6 @@
import {AbortError} from "./error.js";
import ObservableValue from "../observable/ObservableValue.js";
import createEnum from "../utils/enum.js";
import {ObservableValue} from "../observable/ObservableValue.js";
import {createEnum} from "../utils/enum.js";
const INCREMENTAL_TIMEOUT = 30000;
const SYNC_EVENT_LIMIT = 10;

View file

@ -1,4 +1,4 @@
export default class User {
export class User {
constructor(userId) {
this._userId = userId;
}

View file

@ -1,6 +1,6 @@
import {AbortError} from "../../utils/error.js";
export default class ExponentialRetryDelay {
export class ExponentialRetryDelay {
constructor(createTimeout, start = 2000) {
this._start = start;
this._current = start;
@ -43,7 +43,7 @@ export default class ExponentialRetryDelay {
}
import MockClock from "../../mocks/Clock.js";
import {Clock as MockClock} from "../../mocks/Clock.js";
export function tests() {
return {

View file

@ -28,7 +28,7 @@ class RequestWrapper {
}
}
export default class HomeServerApi {
export class HomeServerApi {
constructor({homeServer, accessToken, request, createTimeout, reconnector}) {
// store these both in a closure somehow so it's harder to get at in case of XSS?
// one could change the homeserver as well so the token gets sent there, so both must be protected from read/write

View file

@ -1,7 +1,7 @@
import createEnum from "../../utils/enum.js";
import {createEnum} from "../../utils/enum.js";
import {AbortError} from "../../utils/error.js";
import {ConnectionError} from "../error.js"
import ObservableValue from "../../observable/ObservableValue.js";
import {ObservableValue} from "../../observable/ObservableValue.js";
export const ConnectionStatus = createEnum(
"Offline",
@ -111,8 +111,8 @@ export class Reconnector {
}
import MockClock from "../../mocks/Clock.js";
import ExponentialRetryDelay from "./ExponentialRetryDelay.js";
import {Clock as MockClock} from "../../mocks/Clock.js";
import {ExponentialRetryDelay} from "./ExponentialRetryDelay.js";
export function tests() {
function createHsApiMock(remainingFailures) {

View file

@ -31,7 +31,7 @@ class RequestResult {
}
}
export default function fetchRequest(url, options) {
export function fetchRequest(url, options) {
const controller = typeof AbortController === "function" ? new AbortController() : null;
if (controller) {
options = Object.assign(options, {

View file

@ -1,12 +1,12 @@
import EventEmitter from "../../EventEmitter.js";
import RoomSummary from "./summary.js";
import SyncWriter from "./timeline/persistence/SyncWriter.js";
import GapWriter from "./timeline/persistence/GapWriter.js";
import Timeline from "./timeline/Timeline.js";
import FragmentIdComparer from "./timeline/FragmentIdComparer.js";
import SendQueue from "./sending/SendQueue.js";
import {EventEmitter} from "../../EventEmitter.js";
import {RoomSummary} from "./summary.js";
import {SyncWriter} from "./timeline/persistence/SyncWriter.js";
import {GapWriter} from "./timeline/persistence/GapWriter.js";
import {Timeline} from "./timeline/Timeline.js";
import {FragmentIdComparer} from "./timeline/FragmentIdComparer.js";
import {SendQueue} from "./sending/SendQueue.js";
export default class Room extends EventEmitter {
export class Room extends EventEmitter {
constructor({roomId, storage, hsApi, emitCollectionChange, sendScheduler, pendingEvents, user}) {
super();
this._roomId = roomId;

View file

@ -1,4 +1,4 @@
export default class PendingEvent {
export class PendingEvent {
constructor(data) {
this._data = data;
}

View file

@ -1,6 +1,6 @@
import SortedArray from "../../../observable/list/SortedArray.js";
import {SortedArray} from "../../../observable/list/SortedArray.js";
import {ConnectionError} from "../../error.js";
import PendingEvent from "./PendingEvent.js";
import {PendingEvent} from "./PendingEvent.js";
function makeTxnId() {
const n = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
@ -8,7 +8,7 @@ function makeTxnId() {
return "t" + "0".repeat(14 - str.length) + str;
}
export default class SendQueue {
export class SendQueue {
constructor({roomId, storage, sendScheduler, pendingEvents}) {
pendingEvents = pendingEvents || [];
this._roomId = roomId;

View file

@ -99,7 +99,7 @@ class SummaryData {
}
}
export default class RoomSummary {
export class RoomSummary {
constructor(roomId) {
this._data = new SummaryData(null, roomId);
}

View file

@ -1,6 +1,4 @@
export default class Direction {
export class Direction {
constructor(isForward) {
this._isForward = isForward;
}

View file

@ -1,7 +1,7 @@
import Platform from "../../../Platform.js";
import {Platform} from "../../../Platform.js";
// key for events in the timelineEvents store
export default class EventKey {
export class EventKey {
constructor(fragmentId, eventIndex) {
this.fragmentId = fragmentId;
this.eventIndex = eventIndex;

View file

@ -114,7 +114,7 @@ class Island {
/*
index for fast lookup of how two fragments can be sorted
*/
export default class FragmentIdComparer {
export class FragmentIdComparer {
constructor(fragments) {
this._fragmentsById = fragments.reduce((map, f) => {map.set(f.id, f); return map;}, new Map());
this.rebuild(fragments);

View file

@ -1,9 +1,9 @@
import { SortedArray, MappedList, ConcatList } from "../../../observable/index.js";
import Direction from "./Direction.js";
import TimelineReader from "./persistence/TimelineReader.js";
import PendingEventEntry from "./entries/PendingEventEntry.js";
import {SortedArray, MappedList, ConcatList} from "../../../observable/index.js";
import {Direction} from "./Direction.js";
import {TimelineReader} from "./persistence/TimelineReader.js";
import {PendingEventEntry} from "./entries/PendingEventEntry.js";
export default class Timeline {
export class Timeline {
constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, user}) {
this._roomId = roomId;
this._storage = storage;

View file

@ -1,8 +1,8 @@
//entries can be sorted, first by fragment, then by entry index.
import EventKey from "../EventKey.js";
import {EventKey} from "../EventKey.js";
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
export default class BaseEntry {
export class BaseEntry {
constructor(fragmentIdComparer) {
this._fragmentIdComparer = fragmentIdComparer;
}

View file

@ -1,6 +1,6 @@
import BaseEntry from "./BaseEntry.js";
import {BaseEntry} from "./BaseEntry.js";
export default class EventEntry extends BaseEntry {
export class EventEntry extends BaseEntry {
constructor(eventEntry, fragmentIdComparer) {
super(fragmentIdComparer);
this._eventEntry = eventEntry;

View file

@ -1,9 +1,9 @@
import BaseEntry from "./BaseEntry.js";
import Direction from "../Direction.js";
import {BaseEntry} from "./BaseEntry.js";
import {Direction} from "../Direction.js";
import {isValidFragmentId} from "../common.js";
import Platform from "../../../../Platform.js";
import {Platform} from "../../../../Platform.js";
export default class FragmentBoundaryEntry extends BaseEntry {
export class FragmentBoundaryEntry extends BaseEntry {
constructor(fragment, isFragmentStart, fragmentIdComparer) {
super(fragmentIdComparer);
this._fragment = fragment;

View file

@ -1,6 +1,6 @@
import BaseEntry, {PENDING_FRAGMENT_ID} from "./BaseEntry.js";
import {BaseEntry, PENDING_FRAGMENT_ID} from "./BaseEntry.js";
export default class PendingEventEntry extends BaseEntry {
export class PendingEventEntry extends BaseEntry {
constructor({pendingEvent, user}) {
super(null);
this._pendingEvent = pendingEvent;

View file

@ -1,8 +1,8 @@
import EventKey from "../EventKey.js";
import EventEntry from "../entries/EventEntry.js";
import {EventKey} from "../EventKey.js";
import {EventEntry} from "../entries/EventEntry.js";
import {createEventEntry, directionalAppend} from "./common.js";
export default class GapWriter {
export class GapWriter {
constructor({roomId, storage, fragmentIdComparer}) {
this._roomId = roomId;
this._storage = storage;

View file

@ -1,6 +1,6 @@
import EventKey from "../EventKey.js";
import EventEntry from "../entries/EventEntry.js";
import FragmentBoundaryEntry from "../entries/FragmentBoundaryEntry.js";
import {EventKey} from "../EventKey.js";
import {EventEntry} from "../entries/EventEntry.js";
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";
import {createEventEntry} from "./common.js";
// Synapse bug? where the m.room.create event appears twice in sync response
@ -17,7 +17,7 @@ function deduplicateEvents(events) {
});
}
export default class SyncWriter {
export class SyncWriter {
constructor({roomId, fragmentIdComparer}) {
this._roomId = roomId;
this._fragmentIdComparer = fragmentIdComparer;

View file

@ -1,9 +1,9 @@
import {directionalConcat, directionalAppend} from "./common.js";
import Direction from "../Direction.js";
import EventEntry from "../entries/EventEntry.js";
import FragmentBoundaryEntry from "../entries/FragmentBoundaryEntry.js";
import {Direction} from "../Direction.js";
import {EventEntry} from "../entries/EventEntry.js";
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";
export default class TimelineReader {
export class TimelineReader {
constructor({roomId, storage, fragmentIdComparer}) {
this._roomId = roomId;
this._storage = storage;

View file

@ -1,4 +1,4 @@
export default class SessionInfoStorage {
export class SessionInfoStorage {
constructor(name) {
this._name = name;
}

View file

@ -1,11 +1,11 @@
import Storage from "./storage.js";
import {Storage} from "./storage.js";
import { openDatabase, reqAsPromise } from "./utils.js";
import { exportSession, importSession } from "./export.js";
const sessionName = sessionId => `brawl_session_${sessionId}`;
const openDatabaseWithSessionId = sessionId => openDatabase(sessionName(sessionId), createStores, 1);
export default class StorageFactory {
export class StorageFactory {
async create(sessionId) {
const db = await openDatabaseWithSessionId(sessionId);
return new Storage(db);

View file

@ -1,6 +1,6 @@
import {iterateCursor, reqAsPromise} from "./utils.js";
export default class QueryTarget {
export class QueryTarget {
constructor(target) {
this._target = target;
}

View file

@ -1,7 +1,7 @@
import Transaction from "./transaction.js";
import {Transaction} from "./transaction.js";
import { STORE_NAMES, StorageError } from "../common.js";
export default class Storage {
export class Storage {
constructor(idbDatabase) {
this._db = idbDatabase;
const nameMap = STORE_NAMES.reduce((nameMap, name) => {

View file

@ -1,4 +1,4 @@
import QueryTarget from "./query-target.js";
import {QueryTarget} from "./query-target.js";
import { reqAsPromise } from "./utils.js";
import { StorageError } from "../common.js";
@ -80,7 +80,7 @@ class QueryTargetWrapper {
}
}
export default class Store extends QueryTarget {
export class Store extends QueryTarget {
constructor(idbStore) {
super(new QueryTargetWrapper(idbStore));
}

View file

@ -1,5 +1,5 @@
import { encodeUint32, decodeUint32 } from "../utils.js";
import Platform from "../../../../Platform.js";
import {Platform} from "../../../../Platform.js";
function encodeKey(roomId, queueIndex) {
return `${roomId}|${encodeUint32(queueIndex)}`;
@ -11,7 +11,7 @@ function decodeKey(key) {
return {roomId, queueIndex};
}
export default class PendingEventStore {
export class PendingEventStore {
constructor(eventStore) {
this._eventStore = eventStore;
}

View file

@ -1,4 +1,4 @@
export default class RoomStateStore {
export class RoomStateStore {
constructor(idbStore) {
this._roomStateStore = idbStore;
}

View file

@ -11,7 +11,7 @@ store contains:
inviteCount
joinCount
*/
export default class RoomSummaryStore {
export class RoomSummaryStore {
constructor(summaryStore) {
this._summaryStore = summaryStore;
}

View file

@ -14,7 +14,7 @@ store contains:
avatarUrl
lastSynced
*/
export default class SessionStore {
export class SessionStore {
constructor(sessionStore) {
this._sessionStore = sessionStore;
}

View file

@ -1,7 +1,7 @@
import EventKey from "../../../room/timeline/EventKey.js";
import {EventKey} from "../../../room/timeline/EventKey.js";
import { StorageError } from "../../common.js";
import { encodeUint32 } from "../utils.js";
import Platform from "../../../../Platform.js";
import {Platform} from "../../../../Platform.js";
function encodeKey(roomId, fragmentId, eventIndex) {
return `${roomId}|${encodeUint32(fragmentId)}|${encodeUint32(eventIndex)}`;
@ -81,7 +81,7 @@ class Range {
* @property {?Event} event if an event entry, the event
* @property {?Gap} gap if a gap entry, the gap
*/
export default class TimelineEventStore {
export class TimelineEventStore {
constructor(timelineStore) {
this._timelineStore = timelineStore;
}

View file

@ -1,12 +1,12 @@
import { StorageError } from "../../common.js";
import Platform from "../../../../Platform.js";
import {Platform} from "../../../../Platform.js";
import { encodeUint32 } from "../utils.js";
function encodeKey(roomId, fragmentId) {
return `${roomId}|${encodeUint32(fragmentId)}`;
}
export default class RoomFragmentStore {
export class TimelineFragmentStore {
constructor(store) {
this._store = store;
}

View file

@ -1,14 +1,14 @@
import {txnAsPromise} from "./utils.js";
import {StorageError} from "../common.js";
import Store from "./store.js";
import SessionStore from "./stores/SessionStore.js";
import RoomSummaryStore from "./stores/RoomSummaryStore.js";
import TimelineEventStore from "./stores/TimelineEventStore.js";
import RoomStateStore from "./stores/RoomStateStore.js";
import TimelineFragmentStore from "./stores/TimelineFragmentStore.js";
import PendingEventStore from "./stores/PendingEventStore.js";
import {Store} from "./store.js";
import {SessionStore} from "./stores/SessionStore.js";
import {RoomSummaryStore} from "./stores/RoomSummaryStore.js";
import {TimelineEventStore} from "./stores/TimelineEventStore.js";
import {RoomStateStore} from "./stores/RoomStateStore.js";
import {TimelineFragmentStore} from "./stores/TimelineFragmentStore.js";
import {PendingEventStore} from "./stores/PendingEventStore.js";
export default class Transaction {
export class Transaction {
constructor(txn, allowedStoreNames) {
this._txn = txn;
this._allowedStoreNames = allowedStoreNames;

View file

@ -1,7 +1,7 @@
import Transaction from "./transaction.js";
import {Transaction} from "./transaction.js";
import { STORE_MAP, STORE_NAMES } from "../common.js";
export default class Storage {
export class Storage {
constructor(initialStoreValues = {}) {
this._validateStoreNames(Object.keys(initialStoreValues));
this.storeNames = STORE_MAP;

View file

@ -1,6 +1,6 @@
import RoomTimelineStore from "./stores/RoomTimelineStore.js";
import {RoomTimelineStore} from "./stores/RoomTimelineStore.js";
export default class Transaction {
export class Transaction {
constructor(storeValues, writable) {
this._storeValues = storeValues;
this._txnStoreValues = {};

View file

@ -1,6 +1,6 @@
import SortKey from "../../room/timeline/SortKey.js";
import sortedIndex from "../../../utils/sortedIndex.js";
import Store from "./Store.js";
import {SortKey} from "../../room/timeline/SortKey.js";
import {sortedIndex} from "../../../utils/sortedIndex.js";
import {Store} from "./Store.js";
function compareKeys(key, entry) {
if (key.roomId === entry.roomId) {
@ -65,7 +65,7 @@ class Range {
}
}
export default class RoomTimelineStore extends Store {
export class RoomTimelineStore extends Store {
constructor(timeline, writable) {
super(timeline || [], writable);
}

View file

@ -1,4 +1,4 @@
export default class Store {
export class Store {
constructor(storeValue, writable) {
this._storeValue = storeValue;
this._writable = writable;

View file

@ -1,4 +1,4 @@
import ObservableValue from "../observable/ObservableValue.js";
import {ObservableValue} from "../observable/ObservableValue.js";
class Timeout {
constructor(elapsed, ms) {
@ -29,7 +29,7 @@ class TimeMeasure {
}
}
export default class Clock {
export class Clock {
constructor(baseTimestamp = 0) {
this._baseTimestamp = baseTimestamp;
this._elapsed = new ObservableValue(0);

View file

@ -1,4 +1,4 @@
export default class BaseObservable {
export class BaseObservable {
constructor() {
this._handlers = new Set();
}

View file

@ -1,5 +1,5 @@
import {AbortError} from "../utils/error.js";
import BaseObservable from "./BaseObservable.js";
import {BaseObservable} from "./BaseObservable.js";
// like an EventEmitter, but doesn't have an event type
export class BaseObservableValue extends BaseObservable {
@ -49,7 +49,7 @@ class ResolvedWaitForHandle {
dispose() {}
}
export default class ObservableValue extends BaseObservableValue {
export class ObservableValue extends BaseObservableValue {
constructor(initialValue) {
super();
this._value = initialValue;

View file

@ -1,13 +1,13 @@
import SortedMapList from "./list/SortedMapList.js";
import FilteredMap from "./map/FilteredMap.js";
import MappedMap from "./map/MappedMap.js";
import BaseObservableMap from "./map/BaseObservableMap.js";
import {SortedMapList} from "./list/SortedMapList.js";
import {FilteredMap} from "./map/FilteredMap.js";
import {MappedMap} from "./map/MappedMap.js";
import {BaseObservableMap} from "./map/BaseObservableMap.js";
// re-export "root" (of chain) collections
export { default as ObservableArray } from "./list/ObservableArray.js";
export { default as SortedArray } from "./list/SortedArray.js";
export { default as MappedList } from "./list/MappedList.js";
export { default as ConcatList } from "./list/ConcatList.js";
export { default as ObservableMap } from "./map/ObservableMap.js";
export { ObservableArray } from "./list/ObservableArray.js";
export { SortedArray } from "./list/SortedArray.js";
export { MappedList } from "./list/MappedList.js";
export { ConcatList } from "./list/ConcatList.js";
export { ObservableMap } from "./map/ObservableMap.js";
// avoid circular dependency between these classes
// and BaseObservableMap (as they extend it)

View file

@ -1,6 +1,6 @@
import BaseObservable from "../BaseObservable.js";
import {BaseObservable} from "../BaseObservable.js";
export default class BaseObservableList extends BaseObservable {
export class BaseObservableList extends BaseObservable {
emitReset() {
for(let h of this._handlers) {
h.onReset(this);

View file

@ -1,6 +1,6 @@
import BaseObservableList from "./BaseObservableList.js";
import {BaseObservableList} from "./BaseObservableList.js";
export default class ConcatList extends BaseObservableList {
export class ConcatList extends BaseObservableList {
constructor(...sourceLists) {
super();
this._sourceLists = sourceLists;
@ -86,7 +86,7 @@ export default class ConcatList extends BaseObservableList {
}
}
import ObservableArray from "./ObservableArray.js";
import {ObservableArray} from "./ObservableArray.js";
export async function tests() {
return {
test_length(assert) {

View file

@ -1,6 +1,6 @@
import BaseObservableList from "./BaseObservableList.js";
import {BaseObservableList} from "./BaseObservableList.js";
export default class MappedList extends BaseObservableList {
export class MappedList extends BaseObservableList {
constructor(sourceList, mapper, updater) {
super();
this._sourceList = sourceList;

View file

@ -1,6 +1,6 @@
import BaseObservableList from "./BaseObservableList.js";
import {BaseObservableList} from "./BaseObservableList.js";
export default class ObservableArray extends BaseObservableList {
export class ObservableArray extends BaseObservableList {
constructor(initialValues = []) {
super();
this._items = initialValues;

View file

@ -1,7 +1,7 @@
import BaseObservableList from "./BaseObservableList.js";
import sortedIndex from "../../utils/sortedIndex.js";
import {BaseObservableList} from "./BaseObservableList.js";
import {sortedIndex} from "../../utils/sortedIndex.js";
export default class SortedArray extends BaseObservableList {
export class SortedArray extends BaseObservableList {
constructor(comparator) {
super();
this._comparator = comparator;

View file

@ -1,5 +1,5 @@
import BaseObservableList from "./BaseObservableList.js";
import sortedIndex from "../../utils/sortedIndex.js";
import {BaseObservableList} from "./BaseObservableList.js";
import {sortedIndex} from "../../utils/sortedIndex.js";
/*
@ -29,7 +29,7 @@ with a node containing {value, leftCount, rightCount, leftNode, rightNode, paren
// types modified outside of the collection (and affecting sort order) or not
// no duplicates allowed for now
export default class SortedMapList extends BaseObservableList {
export class SortedMapList extends BaseObservableList {
constructor(sourceMap, comparator) {
super();
this._sourceMap = sourceMap;
@ -114,7 +114,7 @@ export default class SortedMapList extends BaseObservableList {
}
//#ifdef TESTS
import ObservableMap from "../map/ObservableMap.js";
import {ObservableMap} from "../map/ObservableMap.js";
export function tests() {
return {

View file

@ -1,6 +1,6 @@
import BaseObservable from "../BaseObservable.js";
import {BaseObservable} from "../BaseObservable.js";
export default class BaseObservableMap extends BaseObservable {
export class BaseObservableMap extends BaseObservable {
emitReset() {
for(let h of this._handlers) {
h.onReset();

View file

@ -1,6 +1,6 @@
import BaseObservableMap from "./BaseObservableMap.js";
import {BaseObservableMap} from "./BaseObservableMap.js";
export default class FilteredMap extends BaseObservableMap {
export class FilteredMap extends BaseObservableMap {
constructor(source, mapper, updater) {
super();
this._source = source;

View file

@ -1,9 +1,9 @@
import BaseObservableMap from "./BaseObservableMap.js";
import {BaseObservableMap} from "./BaseObservableMap.js";
/*
so a mapped value can emit updates on it's own with this._updater that is passed in the mapping function
how should the mapped value be notified of an update though? and can it then decide to not propagate the update?
*/
export default class MappedMap extends BaseObservableMap {
export class MappedMap extends BaseObservableMap {
constructor(source, mapper) {
super();
this._source = source;

View file

@ -1,6 +1,6 @@
import BaseObservableMap from "./BaseObservableMap.js";
import {BaseObservableMap} from "./BaseObservableMap.js";
export default class ObservableMap extends BaseObservableMap {
export class ObservableMap extends BaseObservableMap {
constructor(initialValues) {
super();
this._values = new Map(initialValues);

View file

@ -1,10 +1,10 @@
import SessionView from "./session/SessionView.js";
import LoginView from "./login/LoginView.js";
import SessionPickerView from "./login/SessionPickerView.js";
import TemplateView from "./general/TemplateView.js";
import SwitchView from "./general/SwitchView.js";
import {SessionView} from "./session/SessionView.js";
import {LoginView} from "./login/LoginView.js";
import {SessionPickerView} from "./login/SessionPickerView.js";
import {TemplateView} from "./general/TemplateView.js";
import {SwitchView} from "./general/SwitchView.js";
export default class BrawlView {
export class BrawlView {
constructor(vm) {
this._vm = vm;
this._switcher = null;

View file

@ -1,4 +1,4 @@
export default {
export const WebPlatform = {
get minStorageKey() {
// for indexeddb, we use unsigned 32 bit integers as keys
return 0;

View file

@ -37,7 +37,7 @@ class TimeMeasure {
}
}
export default class Clock {
export class Clock {
createMeasure() {
return new TimeMeasure();
}

View file

@ -1,6 +1,6 @@
import {BaseObservableValue} from "../../../observable/ObservableValue.js";
export default class OnlineStatus extends BaseObservableValue {
export class OnlineStatus extends BaseObservableValue {
constructor() {
super();
this._onOffline = this._onOffline.bind(this);

View file

@ -10,7 +10,7 @@ function insertAt(parentNode, idx, childNode) {
}
}
export default class ListView {
export class ListView {
constructor({list, onItemClick, className}, childCreator) {
this._onItemClick = onItemClick;
this._list = list;

View file

@ -1,4 +1,4 @@
export default class SwitchView {
export class SwitchView {
constructor(defaultView) {
this._childView = defaultView;
}

View file

@ -22,7 +22,7 @@ function objHasFns(obj) {
missing:
- create views
*/
export default class Template {
export class Template {
constructor(value, render) {
this._value = value;
this._eventListeners = null;

View file

@ -1,6 +1,6 @@
import Template from "./Template.js";
import {Template} from "./Template.js";
export default class TemplateView {
export class TemplateView {
constructor(vm, bindToChangeEvent) {
this.viewModel = vm;
this._changeEventHandler = bindToChangeEvent ? this.update.bind(this, this.viewModel) : null;

View file

@ -1,7 +1,7 @@
import TemplateView from "../general/TemplateView.js";
import {TemplateView} from "../general/TemplateView.js";
import {brawlGithubLink} from "./common.js";
export default class LoginView extends TemplateView {
export class LoginView extends TemplateView {
constructor(vm) {
super(vm, true);
}

View file

@ -1,5 +1,5 @@
import ListView from "../general/ListView.js";
import TemplateView from "../general/TemplateView.js";
import {ListView} from "../general/ListView.js";
import {TemplateView} from "../general/TemplateView.js";
import {brawlGithubLink} from "./common.js";
function selectFileAsText(mimeType) {
@ -71,7 +71,7 @@ class SessionPickerItemView extends TemplateView {
}
}
export default class SessionPickerView extends TemplateView {
export class SessionPickerView extends TemplateView {
mount() {
this._sessionList = new ListView({
list: this.viewModel.sessions,

View file

@ -1,6 +1,6 @@
import {tag} from "../general/html.js";
export default class RoomPlaceholderView {
export class RoomPlaceholderView {
constructor() {
this._root = null;
}

View file

@ -1,6 +1,6 @@
import TemplateView from "../general/TemplateView.js";
import {TemplateView} from "../general/TemplateView.js";
export default class RoomTile extends TemplateView {
export class RoomTile extends TemplateView {
render(t) {
return t.li([
t.div({className: "avatar medium"}, vm => vm.avatarInitials),

View file

@ -1,12 +1,12 @@
import ListView from "../general/ListView.js";
import RoomTile from "./RoomTile.js";
import RoomView from "./room/RoomView.js";
import SwitchView from "../general/SwitchView.js";
import RoomPlaceholderView from "./RoomPlaceholderView.js";
import SyncStatusBar from "./SyncStatusBar.js";
import {ListView} from "../general/ListView.js";
import {RoomTile} from "./RoomTile.js";
import {RoomView} from "./room/RoomView.js";
import {SwitchView} from "../general/SwitchView.js";
import {RoomPlaceholderView} from "./RoomPlaceholderView.js";
import {SyncStatusBar} from "./SyncStatusBar.js";
import {tag} from "../general/html.js";
export default class SessionView {
export class SessionView {
constructor(viewModel) {
this._viewModel = viewModel;
this._middleSwitcher = null;

View file

@ -1,6 +1,6 @@
import TemplateView from "../general/TemplateView.js";
import {TemplateView} from "../general/TemplateView.js";
export default class SyncStatusBar extends TemplateView {
export class SyncStatusBar extends TemplateView {
constructor(vm) {
super(vm, true);
}

View file

@ -1,6 +1,6 @@
import TemplateView from "../../general/TemplateView.js";
import {TemplateView} from "../../general/TemplateView.js";
export default class MessageComposer extends TemplateView {
export class MessageComposer extends TemplateView {
constructor(viewModel) {
super(viewModel);
this._input = null;

View file

@ -1,8 +1,8 @@
import TemplateView from "../../general/TemplateView.js";
import TimelineList from "./TimelineList.js";
import MessageComposer from "./MessageComposer.js";
import {TemplateView} from "../../general/TemplateView.js";
import {TimelineList} from "./TimelineList.js";
import {MessageComposer} from "./MessageComposer.js";
export default class RoomView extends TemplateView {
export class RoomView extends TemplateView {
constructor(viewModel) {
super(viewModel, true);
this._timelineList = null;

View file

@ -1,9 +1,9 @@
import ListView from "../../general/ListView.js";
import GapView from "./timeline/GapView.js";
import TextMessageView from "./timeline/TextMessageView.js";
import AnnouncementView from "./timeline/AnnouncementView.js";
import {ListView} from "../../general/ListView.js";
import {GapView} from "./timeline/GapView.js";
import {TextMessageView} from "./timeline/TextMessageView.js";
import {AnnouncementView} from "./timeline/AnnouncementView.js";
export default class TimelineList extends ListView {
export class TimelineList extends ListView {
constructor(options = {}) {
options.className = "Timeline";
super(options, entry => {

View file

@ -1,6 +1,6 @@
import TemplateView from "../../../general/TemplateView.js";
import {TemplateView} from "../../../general/TemplateView.js";
export default class AnnouncementView extends TemplateView {
export class AnnouncementView extends TemplateView {
render(t) {
return t.li({className: "AnnouncementView"}, t.div(vm => vm.announcement));
}

View file

@ -1,6 +1,6 @@
import TemplateView from "../../../general/TemplateView.js";
import {TemplateView} from "../../../general/TemplateView.js";
export default class GapView extends TemplateView {
export class GapView extends TemplateView {
render(t, vm) {
const className = {
GapView: true,

View file

@ -1,6 +1,6 @@
import TemplateView from "../../../general/TemplateView.js";
import {TemplateView} from "../../../general/TemplateView.js";
export default class TextMessageView extends TemplateView {
export class TextMessageView extends TemplateView {
render(t, vm) {
// no bindings ... should this be a template view?
return t.li(

View file

@ -1,6 +1,6 @@
import {tag} from "../../../general/html.js";
export default class TimelineTile {
export class TimelineTile {
constructor(tileVM) {
this._tileVM = tileVM;
this._root = null;

View file

@ -1,4 +1,4 @@
export default function createEnum(...values) {
export function createEnum(...values) {
const obj = {};
for (const value of values) {
obj[value] = value;

View file

@ -6,7 +6,7 @@
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
export default function sortedIndex(array, value, comparator) {
export function sortedIndex(array, value, comparator) {
let low = 0;
let high = array.length;