Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change imports for Node.js compatibility #4377

Merged
merged 7 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ module.exports = {
modules: process.env.NODE_ENV === "test" ? "commonjs" : false,
},
],
"@babel/preset-typescript",
[
"@babel/preset-typescript",
{
rewriteImportExtensions: process.env.NODE_ENV !== "test",
Johennes marked this conversation as resolved.
Show resolved Hide resolved
},
],
],
plugins: [
"@babel/plugin-transform-numeric-separator",
Expand Down
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.ts";
import { IClientWellKnown } from "../client.ts";

// 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.ts";
import { UnstableValue } from "../NamespacedValue.ts";
import { MAssetEvent, MLocationEvent, MTimestampEvent } from "./location.ts";

/**
* 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.ts";

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.ts";

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.ts";
import {
PolicyRuleEventContent,
RoomAvatarEventContent,
Expand All @@ -34,16 +34,16 @@ import {
RoomTopicEventContent,
SpaceChildEventContent,
SpaceParentEventContent,
} from "./state_events";
} from "./state_events.ts";
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.ts";
import { MSC3089EventContent } from "../models/MSC3089Branch.ts";
import { M_BEACON, M_BEACON_INFO, MBeaconEventContent, MBeaconInfoEventContent } from "./beacon.ts";
import { XOR } from "./common.ts";
import { ReactionEventContent, RoomMessageEventContent, StickerEventContent } from "./events.ts";
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.ts";
import { EncryptionKeysEventContent, ICallNotifyContent } from "../matrixrtc/types.ts";
import { M_POLL_END, M_POLL_START, PollEndEventContent, PollStartEventContent } from "./polls.ts";
import { SessionMembershipData } from "../matrixrtc/CallMembership.ts";

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.ts";
import { FileInfo, ImageInfo, MediaEventContent } from "./media.ts";
import { XOR } from "./common.ts";

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.ts";

// 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.ts";
import { M_TEXT } from "./extensible_events.ts";

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.ts";

/**
* 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.ts";

/**
* 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.ts";

/**
* 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.ts";
import { Preset, Visibility } from "./partials.ts";
import { IEventWithRoomId, SearchKey } from "./search.ts";
import { IRoomEventFilter } from "../filter.ts";
import { Direction } from "../models/event-timeline.ts";
import { PushRuleAction } from "./PushRules.ts";
import { IRoomEvent } from "../sync-accumulator.ts";
import { EventType, RelationType, RoomType } from "./event.ts";

// 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.ts";
import { IRoomEventFilter } from "../filter.ts";
import { SearchResult } from "../models/search-result.ts";

/* 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.ts";
import { RoomType } from "./event.ts";
import { IStrippedState } from "../sync-accumulator.ts";

// 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.ts";
import { GuestAccess, HistoryVisibility, JoinRule, RestrictedAllowType } from "./partials.ts";
import { ImageInfo } from "./media.ts";
import { PolicyRecommendation } from "../models/invites-ignorer.ts";

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.ts";

// 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.ts";

/**
* 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.ts";
import { IMessageRendering } from "./extensible_events.ts";

/**
* 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.ts";

/**
* 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.ts";

export class ReEmitter {
public constructor(private readonly target: EventEmitter) {}
Expand Down
21 changes: 13 additions & 8 deletions src/ToDeviceMessageQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ 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.ts";
import { logger } from "./logger.ts";
import { MatrixClient, ClientEvent } from "./client.ts";
import { MatrixError } from "./http-api/index.ts";
import {
IndexedToDeviceBatch,
ToDeviceBatch,
ToDeviceBatchWithTxnId,
ToDevicePayload,
} from "./models/ToDeviceMessage.ts";
import { MatrixScheduler } from "./scheduler.ts";
import { SyncState } from "./sync.ts";
import { MapWithDefault } from "./utils.ts";

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.ts";
import { logger } from "./logger.ts";
import { MatrixError, Method, timeoutSignal } from "./http-api/index.ts";
import { SUPPORTED_MATRIX_VERSIONS } from "./version-support.ts";

// 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.ts";

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.ts";
globalThis.matrixcs = matrixcs;
Loading
Loading