Skip to content

Commit

Permalink
Change imports for Node.js compatibility
Browse files Browse the repository at this point in the history
Fixes: matrix-org#4287
Signed-off-by: Johannes Marbach <[email protected]>
  • Loading branch information
Johennes committed Aug 23, 2024
1 parent ee94e93 commit c4bbe4b
Show file tree
Hide file tree
Showing 190 changed files with 1,385 additions and 1,385 deletions.
4 changes: 2 additions & 2 deletions src/@types/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { UnstableValue } from "../NamespacedValue";
import { IClientWellKnown } from "../client";
import { UnstableValue } from "../NamespacedValue.js";
import { IClientWellKnown } from "../client.js";

// disable lint because these are wire responses
/* eslint-disable camelcase */
Expand Down
6 changes: 3 additions & 3 deletions src/@types/beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { RelatesToRelationship, REFERENCE_RELATION } from "./extensible_events";
import { UnstableValue } from "../NamespacedValue";
import { MAssetEvent, MLocationEvent, MTimestampEvent } from "./location";
import { RelatesToRelationship, REFERENCE_RELATION } from "./extensible_events.js";
import { UnstableValue } from "../NamespacedValue.js";
import { MAssetEvent, MLocationEvent, MTimestampEvent } from "./location.js";

/**
* Beacon info and beacon event types as described in MSC3672
Expand Down
4 changes: 2 additions & 2 deletions src/@types/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import type { ISignatures } from "./signed";
import type { ISignatures } from "./signed.js";

export type OlmGroupSessionExtraData = {
untrusted?: boolean;
sharedHistory?: boolean;
};

// Backwards compatible re-export
export type { EventDecryptionResult as IEventDecryptionResult } from "../common-crypto/CryptoBackend";
export type { EventDecryptionResult as IEventDecryptionResult } from "../common-crypto/CryptoBackend.js";

interface Extensible {
[key: string]: any;
Expand Down
22 changes: 11 additions & 11 deletions src/@types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { NamespacedValue, UnstableValue } from "../NamespacedValue";
import { NamespacedValue, UnstableValue } from "../NamespacedValue.js";
import {
PolicyRuleEventContent,
RoomAvatarEventContent,
Expand All @@ -34,16 +34,16 @@ import {
RoomTopicEventContent,
SpaceChildEventContent,
SpaceParentEventContent,
} from "./state_events";
} from "./state_events.js";
import {
ExperimentalGroupCallRoomMemberState,
IGroupCallRoomMemberState,
IGroupCallRoomState,
} from "../webrtc/groupCall";
import { MSC3089EventContent } from "../models/MSC3089Branch";
import { M_BEACON, M_BEACON_INFO, MBeaconEventContent, MBeaconInfoEventContent } from "./beacon";
import { XOR } from "./common";
import { ReactionEventContent, RoomMessageEventContent, StickerEventContent } from "./events";
} from "../webrtc/groupCall.js";
import { MSC3089EventContent } from "../models/MSC3089Branch.js";
import { M_BEACON, M_BEACON_INFO, MBeaconEventContent, MBeaconInfoEventContent } from "./beacon.js";
import { XOR } from "./common.js";
import { ReactionEventContent, RoomMessageEventContent, StickerEventContent } from "./events.js";
import {
MCallAnswer,
MCallBase,
Expand All @@ -54,10 +54,10 @@ import {
MCallSelectAnswer,
SDPStreamMetadata,
SDPStreamMetadataKey,
} from "../webrtc/callEventTypes";
import { EncryptionKeysEventContent, ICallNotifyContent } from "../matrixrtc/types";
import { M_POLL_END, M_POLL_START, PollEndEventContent, PollStartEventContent } from "./polls";
import { SessionMembershipData } from "../matrixrtc/CallMembership";
} from "../webrtc/callEventTypes.js";
import { EncryptionKeysEventContent, ICallNotifyContent } from "../matrixrtc/types.js";
import { M_POLL_END, M_POLL_START, PollEndEventContent, PollStartEventContent } from "./polls.js";
import { SessionMembershipData } from "../matrixrtc/CallMembership.js";

export enum EventType {
// Room state events
Expand Down
6 changes: 3 additions & 3 deletions src/@types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MsgType, RelationType } from "./event";
import { FileInfo, ImageInfo, MediaEventContent } from "./media";
import { XOR } from "./common";
import { MsgType, RelationType } from "./event.js";
import { FileInfo, ImageInfo, MediaEventContent } from "./media.js";
import { XOR } from "./common.js";

interface BaseTimelineEvent {
"body": string;
Expand Down
2 changes: 1 addition & 1 deletion src/@types/extensible_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import { EitherAnd, NamespacedValue, Optional, UnstableValue } from "matrix-events-sdk";

import { isProvided } from "../extensible_events_v1/utilities";
import { isProvided } from "../extensible_events_v1/utilities.js";

// Types and utilities for MSC1767: Extensible events (version 1) in Matrix

Expand Down
4 changes: 2 additions & 2 deletions src/@types/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
// Types for MSC3488 - m.location: Extending events with location data
import { EitherAnd } from "matrix-events-sdk";

import { UnstableValue } from "../NamespacedValue";
import { M_TEXT } from "./extensible_events";
import { UnstableValue } from "../NamespacedValue.js";
import { M_TEXT } from "./extensible_events.js";

export enum LocationAssetType {
Self = "m.self",
Expand Down
2 changes: 1 addition & 1 deletion src/@types/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MsgType } from "../@types/event";
import { MsgType } from "../@types/event.js";

/**
* Information on encrypted media attachments.
Expand Down
2 changes: 1 addition & 1 deletion src/@types/polls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
REFERENCE_RELATION,
RelatesToRelationship,
TSNamespace,
} from "./extensible_events";
} from "./extensible_events.js";

/**
* Identifier for a disclosed poll.
Expand Down
2 changes: 1 addition & 1 deletion src/@types/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { AuthDict } from "../interactive-auth";
import { AuthDict } from "../interactive-auth.js";

/**
* The request body of a call to `POST /_matrix/client/v3/register`.
Expand Down
16 changes: 8 additions & 8 deletions src/@types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IContent, IEvent } from "../models/event";
import { Preset, Visibility } from "./partials";
import { IEventWithRoomId, SearchKey } from "./search";
import { IRoomEventFilter } from "../filter";
import { Direction } from "../models/event-timeline";
import { PushRuleAction } from "./PushRules";
import { IRoomEvent } from "../sync-accumulator";
import { EventType, RelationType, RoomType } from "./event";
import { IContent, IEvent } from "../models/event.js";
import { Preset, Visibility } from "./partials.js";
import { IEventWithRoomId, SearchKey } from "./search.js";
import { IRoomEventFilter } from "../filter.js";
import { Direction } from "../models/event-timeline.js";
import { PushRuleAction } from "./PushRules.js";
import { IRoomEvent } from "../sync-accumulator.js";
import { EventType, RelationType, RoomType } from "./event.js";

// allow camelcase as these are things that go onto the wire
/* eslint-disable camelcase */
Expand Down
6 changes: 3 additions & 3 deletions src/@types/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.

// Types relating to the /search API

import { IRoomEvent, IStateEvent } from "../sync-accumulator";
import { IRoomEventFilter } from "../filter";
import { SearchResult } from "../models/search-result";
import { IRoomEvent, IStateEvent } from "../sync-accumulator.js";
import { IRoomEventFilter } from "../filter.js";
import { SearchResult } from "../models/search-result.js";

/* eslint-disable camelcase */
export interface IEventWithRoomId extends IRoomEvent {
Expand Down
6 changes: 3 additions & 3 deletions src/@types/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IPublicRoomsChunkRoom } from "../client";
import { RoomType } from "./event";
import { IStrippedState } from "../sync-accumulator";
import { IPublicRoomsChunkRoom } from "../client.js";
import { RoomType } from "./event.js";
import { IStrippedState } from "../sync-accumulator.js";

// Types relating to Rooms of type `m.space` and related APIs

Expand Down
8 changes: 4 additions & 4 deletions src/@types/state_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { RoomType } from "./event";
import { GuestAccess, HistoryVisibility, JoinRule, RestrictedAllowType } from "./partials";
import { ImageInfo } from "./media";
import { PolicyRecommendation } from "../models/invites-ignorer";
import { RoomType } from "./event.js";
import { GuestAccess, HistoryVisibility, JoinRule, RestrictedAllowType } from "./partials.js";
import { ImageInfo } from "./media.js";
import { PolicyRecommendation } from "../models/invites-ignorer.js";

export interface RoomCanonicalAliasEventContent {
alias?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/@types/synapse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IdServerUnbindResult } from "./partials";
import { IdServerUnbindResult } from "./partials.js";

// Types relating to Synapse Admin APIs

Expand Down
2 changes: 1 addition & 1 deletion src/@types/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { ServerControlledNamespacedValue } from "../NamespacedValue";
import { ServerControlledNamespacedValue } from "../NamespacedValue.js";

/**
* https://github.com/matrix-org/matrix-doc/pull/3773
Expand Down
4 changes: 2 additions & 2 deletions src/@types/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.

import { EitherAnd } from "matrix-events-sdk";

import { UnstableValue } from "../NamespacedValue";
import { IMessageRendering } from "./extensible_events";
import { UnstableValue } from "../NamespacedValue.js";
import { IMessageRendering } from "./extensible_events.js";

/**
* Extensible topic event type based on MSC3765
Expand Down
2 changes: 1 addition & 1 deletion src/@types/uia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { AuthDict, IAuthData } from "../interactive-auth";
import { AuthDict, IAuthData } from "../interactive-auth.js";

/**
* Helper type to represent HTTP request body for a UIA enabled endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/ReEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
// eslint-disable-next-line no-restricted-imports
import { EventEmitter } from "events";

import { ListenerMap, TypedEventEmitter } from "./models/typed-event-emitter";
import { ListenerMap, TypedEventEmitter } from "./models/typed-event-emitter.js";

export class ReEmitter {
public constructor(private readonly target: EventEmitter) {}
Expand Down
16 changes: 8 additions & 8 deletions src/ToDeviceMessageQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { ToDeviceMessageId } from "./@types/event";
import { logger } from "./logger";
import { MatrixClient, ClientEvent } from "./client";
import { MatrixError } from "./http-api";
import { IndexedToDeviceBatch, ToDeviceBatch, ToDeviceBatchWithTxnId, ToDevicePayload } from "./models/ToDeviceMessage";
import { MatrixScheduler } from "./scheduler";
import { SyncState } from "./sync";
import { MapWithDefault } from "./utils";
import { ToDeviceMessageId } from "./@types/event.js";
import { logger } from "./logger.js";
import { MatrixClient, ClientEvent } from "./client.js";
import { MatrixError } from "./http-api/index.js";
import { IndexedToDeviceBatch, ToDeviceBatch, ToDeviceBatchWithTxnId, ToDevicePayload } from "./models/ToDeviceMessage.js";
import { MatrixScheduler } from "./scheduler.js";
import { SyncState } from "./sync.js";
import { MapWithDefault } from "./utils.js";

const MAX_BATCH_SIZE = 20;

Expand Down
8 changes: 4 additions & 4 deletions src/autodiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IClientWellKnown, IWellKnownConfig, IServerVersions } from "./client";
import { logger } from "./logger";
import { MatrixError, Method, timeoutSignal } from "./http-api";
import { SUPPORTED_MATRIX_VERSIONS } from "./version-support";
import { IClientWellKnown, IWellKnownConfig, IServerVersions } from "./client.js";
import { logger } from "./logger.js";
import { MatrixError, Method, timeoutSignal } from "./http-api/index.js";
import { SUPPORTED_MATRIX_VERSIONS } from "./version-support.js";

// Dev note: Auto discovery is part of the spec.
// See: https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
Expand Down
4 changes: 2 additions & 2 deletions src/browser-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import * as matrixcs from "./matrix";
import * as matrixcs from "./matrix.js";

type BrowserMatrix = typeof matrixcs;
declare global {
Expand All @@ -40,5 +40,5 @@ if (indexedDB) {
matrixcs.setCryptoStoreFactory(() => new matrixcs.IndexedDBCryptoStore(indexedDB!, "matrix-js-sdk:crypto"));
}

export * from "./matrix";
export * from "./matrix.js";
globalThis.matrixcs = matrixcs;
Loading

0 comments on commit c4bbe4b

Please sign in to comment.