diff --git a/packages/live-share-canvas/src/core/InkingManager.ts b/packages/live-share-canvas/src/core/InkingManager.ts index aaac951be..a1560c3f7 100644 --- a/packages/live-share-canvas/src/core/InkingManager.ts +++ b/packages/live-share-canvas/src/core/InkingManager.ts @@ -51,7 +51,7 @@ import { computeQuadPath, renderQuadPathToSVG, } from "./internals"; -import { IEvent } from "@fluidframework/common-definitions"; +import { IEvent } from "@fluidframework/core-interfaces"; /** * Defines available inking tools. diff --git a/packages/live-share-canvas/src/core/LiveCanvas.ts b/packages/live-share-canvas/src/core/LiveCanvas.ts index f2867686b..f73e5569c 100644 --- a/packages/live-share-canvas/src/core/LiveCanvas.ts +++ b/packages/live-share-canvas/src/core/LiveCanvas.ts @@ -34,15 +34,17 @@ import { } from "./Geometry"; import { IStroke, Stroke, StrokeType } from "./Stroke"; import { - LiveEventScope, - LiveEventTarget, UserMeetingRole, - DynamicObjectRegistry, - LiveDataObject, LiveTelemetryLogger, ILiveEvent, LiveDataObjectInitializeState, } from "@microsoft/live-share"; +import { + LiveEventScope, + LiveEventTarget, + DynamicObjectRegistry, + LiveDataObject, +} from "@microsoft/live-share/internal"; import { IBrush } from "./Brush"; import { BasicColors, IColor, lightenColor, toCssRgbaColor } from "./Colors"; import { TelemetryEvents } from "./internals"; diff --git a/packages/live-share-media/src/LiveMediaSession.ts b/packages/live-share-media/src/LiveMediaSession.ts index 90826d7a5..fe5f66ff1 100644 --- a/packages/live-share-media/src/LiveMediaSession.ts +++ b/packages/live-share-media/src/LiveMediaSession.ts @@ -8,13 +8,15 @@ import { createDataObjectKind, } from "@fluidframework/aqueduct/internal"; import { - DynamicObjectRegistry, - LiveDataObject, LiveDataObjectInitializeNotNeededError, LiveDataObjectInitializeState, LiveTelemetryLogger, UserMeetingRole, } from "@microsoft/live-share"; +import { + DynamicObjectRegistry, + LiveDataObject, +} from "@microsoft/live-share/internal"; import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer"; import { ITriggerActionEvent, TelemetryEvents } from "./internals"; import { diff --git a/packages/live-share-media/src/LiveMediaSessionCoordinator.ts b/packages/live-share-media/src/LiveMediaSessionCoordinator.ts index 09aeaef1e..09c16604d 100644 --- a/packages/live-share-media/src/LiveMediaSessionCoordinator.ts +++ b/packages/live-share-media/src/LiveMediaSessionCoordinator.ts @@ -4,19 +4,21 @@ */ import { - LiveEventScope, LiveTelemetryLogger, - LiveEventTarget, - IRuntimeSignaler, TimeInterval, UserMeetingRole, - LiveShareRuntime, LiveDataObjectInitializeState, LiveDataObjectInitializeNotNeededError, LiveDataObjectNotInitializedError, - LiveObjectSynchronizer, ILiveEvent, } from "@microsoft/live-share"; +import { + IRuntimeSignaler, + LiveEventScope, + LiveEventTarget, + LiveObjectSynchronizer, + LiveShareRuntime, +} from "@microsoft/live-share/internal"; import { CoordinationWaitPoint, ExtendedMediaMetadata, @@ -36,9 +38,9 @@ import { IRateChangeCommandEvent, } from "./internals"; import { LiveMediaSessionCoordinatorSuspension } from "./LiveMediaSessionCoordinatorSuspension"; -import { isErrorLike } from "@microsoft/live-share/bin/internals"; +import { isErrorLike } from "@microsoft/live-share/bin/internals/type-guards"; import { TypedEventEmitter } from "@fluid-internal/client-utils"; -import { IEvent } from "@fluidframework/common-definitions"; +import { IEvent } from "@fluidframework/core-interfaces"; /** * Most recent state of the media session. diff --git a/packages/live-share-media/src/MediaPlayerSynchronizer.ts b/packages/live-share-media/src/MediaPlayerSynchronizer.ts index 116ae0900..8bc1868a1 100644 --- a/packages/live-share-media/src/MediaPlayerSynchronizer.ts +++ b/packages/live-share-media/src/MediaPlayerSynchronizer.ts @@ -2,11 +2,8 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Microsoft Live Share SDK License. */ -import { - LiveTelemetryLogger, - ILiveEvent, - IRuntimeSignaler, -} from "@microsoft/live-share"; +import { LiveTelemetryLogger, ILiveEvent } from "@microsoft/live-share"; +import { IRuntimeSignaler } from "@microsoft/live-share/internal"; import { ExtendedMediaSessionAction, ExtendedMediaSessionPlaybackState, @@ -20,9 +17,9 @@ import { VolumeManager } from "./VolumeManager"; import { LiveMediaSession } from "./LiveMediaSession"; import { IMediaPlayer } from "./IMediaPlayer"; import { ITriggerActionEvent, TelemetryEvents } from "./internals"; -import { waitUntilConnected } from "@microsoft/live-share/bin/internals"; +import { waitUntilConnected } from "@microsoft/live-share/bin/internals/utils"; import { TypedEventEmitter } from "@fluid-internal/client-utils"; -import { IEvent } from "@fluidframework/common-definitions"; +import { IEvent } from "@fluidframework/core-interfaces"; /** * Event data returned by `MediaPlayerSynchronizer` object. diff --git a/packages/live-share-media/src/internals/GroupCoordinatorState.ts b/packages/live-share-media/src/internals/GroupCoordinatorState.ts index 9a72060a8..7de9b94e8 100644 --- a/packages/live-share-media/src/internals/GroupCoordinatorState.ts +++ b/packages/live-share-media/src/internals/GroupCoordinatorState.ts @@ -6,11 +6,13 @@ import { ILiveEvent, TimeInterval, - IRuntimeSignaler, LiveTelemetryLogger, - LiveShareRuntime, IEvent, } from "@microsoft/live-share"; +import { + IRuntimeSignaler, + LiveShareRuntime, +} from "@microsoft/live-share/internal"; import { ExtendedMediaMetadata, CoordinationWaitPoint, @@ -42,7 +44,7 @@ import { IPlaybackTrackDataChangeEvent, } from "./GroupPlaybackTrackData"; import { TelemetryEvents } from "./consts"; -import { waitUntilConnected } from "@microsoft/live-share/bin/internals"; +import { waitUntilConnected } from "@microsoft/live-share/bin/internals/utils"; import { GroupPlaybackRate, IPlaybackRate, diff --git a/packages/live-share-media/src/internals/GroupPlaybackPosition.ts b/packages/live-share-media/src/internals/GroupPlaybackPosition.ts index c2d2fedd9..e219664b4 100644 --- a/packages/live-share-media/src/internals/GroupPlaybackPosition.ts +++ b/packages/live-share-media/src/internals/GroupPlaybackPosition.ts @@ -3,11 +3,11 @@ * Licensed under the Microsoft Live Share SDK License. */ +import { TimeInterval } from "@microsoft/live-share"; import { IRuntimeSignaler, - TimeInterval, LiveShareRuntime, -} from "@microsoft/live-share"; +} from "@microsoft/live-share/internal"; import { GroupTransportState } from "./GroupTransportState"; import { GroupPlaybackTrackEvents } from "./GroupPlaybackTrack"; import { diff --git a/packages/live-share-media/src/internals/GroupTransportState.ts b/packages/live-share-media/src/internals/GroupTransportState.ts index ec682d9c4..07b23576b 100644 --- a/packages/live-share-media/src/internals/GroupTransportState.ts +++ b/packages/live-share-media/src/internals/GroupTransportState.ts @@ -3,7 +3,7 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { LiveShareRuntime } from "@microsoft/live-share"; +import { LiveShareRuntime } from "@microsoft/live-share/internal"; import { TypedEventEmitter } from "@fluid-internal/client-utils"; import { IMediaPlayerState } from "../LiveMediaSessionCoordinator"; import { diff --git a/packages/live-share-media/src/internals/interfaces.ts b/packages/live-share-media/src/internals/interfaces.ts index 254a34efa..38ce5fcef 100644 --- a/packages/live-share-media/src/internals/interfaces.ts +++ b/packages/live-share-media/src/internals/interfaces.ts @@ -1,5 +1,5 @@ import { IEvent } from "@microsoft/live-share"; -import { IEvent as IFluidEvent } from "@fluidframework/common-definitions"; +import { IEvent as IFluidEvent } from "@fluidframework/core-interfaces"; import { ExtendedMediaSessionActionSource } from "../MediaSessionExtensions"; /** diff --git a/packages/live-share-media/src/test/GroupPlaybackPosition.spec.ts b/packages/live-share-media/src/test/GroupPlaybackPosition.spec.ts index 51a4bdb23..75c0a379f 100644 --- a/packages/live-share-media/src/test/GroupPlaybackPosition.spec.ts +++ b/packages/live-share-media/src/test/GroupPlaybackPosition.spec.ts @@ -18,12 +18,11 @@ import { ICurrentPlaybackPosition, ITransportState, } from "../internals"; +import { TestLiveShareHost, TimeInterval } from "@microsoft/live-share"; import { IRuntimeSignaler, - TestLiveShareHost, - TimeInterval, -} from "@microsoft/live-share"; -import { MockLiveShareRuntime } from "@microsoft/live-share/src/test/MockLiveShareRuntime"; + MockLiveShareRuntime, +} from "@microsoft/live-share/internal"; import { IMediaPlayerState } from "../LiveMediaSessionCoordinator"; function createTransportUpdate( diff --git a/packages/live-share-media/src/test/GroupPlaybackTrack.spec.ts b/packages/live-share-media/src/test/GroupPlaybackTrack.spec.ts index 9f1eb8b58..8a2ec52d4 100644 --- a/packages/live-share-media/src/test/GroupPlaybackTrack.spec.ts +++ b/packages/live-share-media/src/test/GroupPlaybackTrack.spec.ts @@ -11,7 +11,7 @@ import { IPlaybackTrackChangeEvent, } from "../internals/GroupPlaybackTrack"; import { ExtendedMediaMetadata } from "../MediaSessionExtensions"; -import { Deferred } from "@microsoft/live-share/src/internals/Deferred"; +import { Deferred } from "@microsoft/live-share/internal"; describe("GroupPlaybackTrack", () => { const track1 = { diff --git a/packages/live-share-media/src/test/LiveMediaSession_ManualActionHandler.spec.ts b/packages/live-share-media/src/test/LiveMediaSession_ManualActionHandler.spec.ts index 5c4140eed..fab831b73 100644 --- a/packages/live-share-media/src/test/LiveMediaSession_ManualActionHandler.spec.ts +++ b/packages/live-share-media/src/test/LiveMediaSession_ManualActionHandler.spec.ts @@ -4,7 +4,6 @@ */ import { TestLiveMediaSession, TestMediaTimeStampProvider } from "./TestUtils"; -import { Deferred } from "@microsoft/live-share/src/internals/Deferred"; import { strict as assert } from "assert"; import { ITestObjectProvider, @@ -13,15 +12,18 @@ import { } from "@fluidframework/test-utils/internal"; import { ITimestampProvider, - LiveEventScope, - LiveEventTarget, LocalTimestampProvider, UserMeetingRole, + TestLiveShareHost, } from "@microsoft/live-share"; -import { TestLiveShareHost } from "@microsoft/live-share"; -import { getLiveDataObjectKind } from "@microsoft/live-share"; -import { waitForDelay } from "@microsoft/live-share/src/internals"; -import { MockLiveShareRuntime } from "@microsoft/live-share/src/test/MockLiveShareRuntime"; +import { + getLiveDataObjectKind, + LiveEventScope, + LiveEventTarget, + MockLiveShareRuntime, + waitForDelay, + Deferred, +} from "@microsoft/live-share/internal"; import { ExtendedMediaMetadata, ExtendedMediaSessionActionDetails, diff --git a/packages/live-share-media/src/test/LiveMediaSession_Synchronizer.spec.ts b/packages/live-share-media/src/test/LiveMediaSession_Synchronizer.spec.ts index d84817cbd..401b2c95b 100644 --- a/packages/live-share-media/src/test/LiveMediaSession_Synchronizer.spec.ts +++ b/packages/live-share-media/src/test/LiveMediaSession_Synchronizer.spec.ts @@ -8,12 +8,11 @@ import { TestMediaPlayer, TestMediaTimeStampProvider, } from "./TestUtils"; -import { Deferred } from "@microsoft/live-share/src/internals/Deferred"; import { strict as assert } from "assert"; import { - ITestObjectProvider, - fluidEntryPoint, getContainerEntryPointBackCompat, + fluidEntryPoint, + ITestObjectProvider, } from "@fluidframework/test-utils/internal"; import { ITimestampProvider, @@ -21,10 +20,13 @@ import { UserMeetingRole, } from "@microsoft/live-share"; import { TestLiveShareHost } from "@microsoft/live-share"; -import { getLiveDataObjectKind } from "@microsoft/live-share"; -import { waitForDelay } from "@microsoft/live-share/src/internals"; -import { MockLiveShareRuntime } from "@microsoft/live-share/src/test/MockLiveShareRuntime"; -import { isErrorLike } from "@microsoft/live-share/bin/internals"; +import { getLiveDataObjectKind } from "@microsoft/live-share/internal"; +import { + Deferred, + isErrorLike, + MockLiveShareRuntime, + waitForDelay, +} from "@microsoft/live-share/internal"; import { ExtendedMediaMetadata, ExtendedMediaSessionAction, diff --git a/packages/live-share-media/src/test/TestUtils.ts b/packages/live-share-media/src/test/TestUtils.ts index 29ed7d7f2..a727fa6ea 100644 --- a/packages/live-share-media/src/test/TestUtils.ts +++ b/packages/live-share-media/src/test/TestUtils.ts @@ -4,13 +4,13 @@ */ import { IMediaPlayer } from "../IMediaPlayer"; -import { Deferred } from "@microsoft/live-share/src/internals/Deferred"; import { LiveMediaSession } from "../LiveMediaSession"; +import { ITimestampProvider } from "@microsoft/live-share"; import { + Deferred, IRuntimeSignaler, - ITimestampProvider, LiveShareRuntime, -} from "@microsoft/live-share"; +} from "@microsoft/live-share/internal"; export class TestMediaPlayer implements IMediaPlayer { private done = new Deferred(); diff --git a/packages/live-share-media/src/test/VolumeManager.spec.ts b/packages/live-share-media/src/test/VolumeManager.spec.ts index e52b9eaa0..09151f72e 100644 --- a/packages/live-share-media/src/test/VolumeManager.spec.ts +++ b/packages/live-share-media/src/test/VolumeManager.spec.ts @@ -1,7 +1,7 @@ import { strict as assert } from "assert"; import { IMediaPlayer } from "../IMediaPlayer"; import { LimitLevelType, VolumeManager } from "../VolumeManager"; -import { Deferred, waitForDelay } from "@microsoft/live-share/src/internals"; +import { Deferred, waitForDelay } from "@microsoft/live-share/internal"; // few millis more than max timeout callback in scheduleAnimationFrame const milliTolerance = 25; diff --git a/packages/live-share-react/src/providers/AzureProvider.tsx b/packages/live-share-react/src/providers/AzureProvider.tsx index 901a3edc4..b8a7c5aff 100644 --- a/packages/live-share-react/src/providers/AzureProvider.tsx +++ b/packages/live-share-react/src/providers/AzureProvider.tsx @@ -14,10 +14,8 @@ import { ISharedStateRegistryResponse, useSharedStateRegistry, } from "../shared-hooks"; -import { - BaseLiveShareClient, - AzureLiveShareClient, -} from "@microsoft/live-share"; +import { AzureLiveShareClient } from "@microsoft/live-share"; +import { BaseLiveShareClient } from "@microsoft/live-share/internal"; /** * React Context provider values for `` and ``. diff --git a/packages/live-share-react/src/shared-hooks/useSharedStateRegistry.ts b/packages/live-share-react/src/shared-hooks/useSharedStateRegistry.ts index 42beb9ab6..a412146cf 100644 --- a/packages/live-share-react/src/shared-hooks/useSharedStateRegistry.ts +++ b/packages/live-share-react/src/shared-hooks/useSharedStateRegistry.ts @@ -22,7 +22,7 @@ import { getRootDirectory, TurboDirectory, TurboStateMap, -} from "@microsoft/live-share"; +} from "@microsoft/live-share/internal"; /** * Response for the {@link useSharedStateRegistry} hook. diff --git a/packages/live-share/internal.ts b/packages/live-share/internal.ts new file mode 100644 index 000000000..e44e609d0 --- /dev/null +++ b/packages/live-share/internal.ts @@ -0,0 +1,17 @@ +// Exposed for other live share libs, or advanced use cases. +export * from "./bin/internals/BaseLiveShareClient"; +export * from "./bin/internals/Deferred"; +export * from "./bin/internals/DynamicObjectRegistry"; +export * from "./bin/internals/DynamicObjectManager"; +export * from "./bin/internals/LiveDataObject"; +export * from "./bin/internals/LiveEventScope"; +export * from "./bin/internals/LiveEventSource"; +export * from "./bin/internals/LiveEventTarget"; +export * from "./bin/internals/LiveObjectSynchronizer"; +export * from "./bin/internals/LiveShareRuntime"; +export * from "./bin/internals/schema-injection-utils"; +export * from "./bin/internals/smuggle"; + +export { waitForDelay, waitUntilConnected } from "./bin/internals/utils"; +export { MockLiveShareRuntime } from "./bin/internals/mock/MockLiveShareRuntime"; +export { isErrorLike } from "./bin/internals/type-guards"; diff --git a/packages/live-share/src/AzureLiveShareClient.ts b/packages/live-share/src/AzureLiveShareClient.ts index 0dd1ef3a1..ac2f77edb 100644 --- a/packages/live-share/src/AzureLiveShareClient.ts +++ b/packages/live-share/src/AzureLiveShareClient.ts @@ -9,10 +9,10 @@ import { AzureContainerServices } from "@fluidframework/azure-client/internal"; import { BaseLiveShareClient } from "./internals/BaseLiveShareClient"; import { ILiveShareHost } from "./interfaces"; import { AzureLiveShareHost } from "./AzureLiveShareHost"; -import { LiveShareRuntime } from "./LiveShareRuntime"; +import { LiveShareRuntime } from "./internals/LiveShareRuntime"; import { getLiveContainerSchema } from "./internals/schema-injection-utils"; import { LiveShareClient } from "./LiveShareClient"; -import { LiveDataObject } from "./LiveDataObject"; +import { LiveDataObject } from "./internals/LiveDataObject"; import { FluidCompatibilityMode } from "./internals/consts"; /** diff --git a/packages/live-share/src/AzureLiveShareHost.ts b/packages/live-share/src/AzureLiveShareHost.ts index 52b631ede..53f310777 100644 --- a/packages/live-share/src/AzureLiveShareHost.ts +++ b/packages/live-share/src/AzureLiveShareHost.ts @@ -7,7 +7,7 @@ import { INtpTimeInfo, UserMeetingRole, } from "./interfaces"; -import { Deferred } from "./internals"; +import { Deferred } from "./internals/Deferred"; /** * @alpha diff --git a/packages/live-share/src/LiveEvent.ts b/packages/live-share/src/LiveEvent.ts index 9af6a53ff..8605f6b68 100644 --- a/packages/live-share/src/LiveEvent.ts +++ b/packages/live-share/src/LiveEvent.ts @@ -14,17 +14,17 @@ import { ILiveEvent, LiveDataObjectInitializeState, } from "./interfaces"; -import { LiveEventScope } from "./LiveEventScope"; -import { LiveEventTarget } from "./LiveEventTarget"; +import { LiveEventScope } from "./internals/LiveEventScope"; +import { LiveEventTarget } from "./internals/LiveEventTarget"; import { DynamicObjectRegistry } from "./internals/DynamicObjectRegistry"; -import { LiveDataObject } from "./LiveDataObject"; -import { cloneValue } from "./internals"; +import { LiveDataObject } from "./internals/LiveDataObject"; import { LiveDataObjectInitializeNotNeededError, LiveDataObjectNotInitializedError, UnexpectedError, } from "./errors"; import { SharedObjectKind } from "fluid-framework"; +import { cloneValue } from "./internals/utils"; /** * Events supported by `LiveEvent` object. diff --git a/packages/live-share/src/LiveEventTimer.ts b/packages/live-share/src/LiveEventTimer.ts deleted file mode 100644 index 72359eaea..000000000 --- a/packages/live-share/src/LiveEventTimer.ts +++ /dev/null @@ -1,117 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Microsoft Live Share SDK License. - */ - -import { TimeInterval } from "./TimeInterval"; -import { LiveEventSource } from "./LiveEventSource"; -import { ILiveEvent } from "./interfaces"; - -/** - * Periodically broadcasts an event to listening `LiveEventTarget` instances. - */ -export class LiveEventTimer { - private _eventSource: LiveEventSource; - private _createEvent: () => T; - private _delay: TimeInterval; - private _isRunning = false; - private _timer?: any; - - /** - * Creates a new `LiveEventTimer instance. - * @param eventSource Event source that will be used to emit events. - * @param createEvent Function used to construct an event to send. This will be called at regular intervals prior to sending an event. - * @param delay Period to delay for in milliseconds. - * @param repeat Optional. If true the timer will repeat once `start` is called, otherwise a single event will be sent after the delay. Defaults to false. - */ - constructor( - eventSource: LiveEventSource, - createEvent: () => T, - delay: number, - repeat = false - ) { - this._eventSource = eventSource; - this._createEvent = createEvent; - this._delay = new TimeInterval(delay); - this.repeat = repeat; - } - - /** - * The rate at which the events are sent in milliseconds. - */ - public get delay(): number { - return this._delay.milliseconds; - } - - public set delay(value: number) { - this._delay.milliseconds = value; - } - - /** - * Returns true if the timer is currently running. - */ - public get isRunning(): boolean { - return this._isRunning; - } - - /** - * If true the event will automatically repeat at an interval specified by the `delay`. - */ - public repeat: boolean; - - /** - * Immediately sends an event. - * - * @remarks - * The `createEvent` callback to construct the event is called but does not impact any pending - * timeouts. Call `start` after calling `sendEvent` if you'd like to skip the next timer - * interval. - */ - public sendEvent(): Promise> { - const evt = this._createEvent(); - return this._eventSource.sendEvent(evt); - } - - /** - * Starts the timer. - * - * @remarks - * If the timer is running it will be stooped and then re-started with a new `delay`. - */ - public start(): void { - this.stop(); - this._isRunning = true; - this.delayedEmit(this.delay); - } - - /** - * Stops the timer if its running. - */ - public stop(): void { - if (this._timer != undefined) { - clearTimeout(this._timer); - this._timer = undefined; - } - this._isRunning = false; - } - - private delayedEmit(delay: number): void { - this._timer = setTimeout(() => { - this._timer = undefined; - const startedAt = new Date().getTime(); - this.sendEvent().catch((err) => { - console.warn(err); - }); - - // Auto-repeat - if (this._isRunning && this.repeat) { - // We want to send an every ${this.delay} milliseconds so we subtract the duration - // of the time it took us to emit the event. If it took longer then ${this.delay} - // we will skip to the next interval (hence the %mod% operation.) - const duration = - (new Date().getTime() - startedAt) % this.delay; - this.delayedEmit(this.delay - duration); - } - }, delay); - } -} diff --git a/packages/live-share/src/LiveFollowMode.ts b/packages/live-share/src/LiveFollowMode.ts index 4ab75825f..5b533049f 100644 --- a/packages/live-share/src/LiveFollowMode.ts +++ b/packages/live-share/src/LiveFollowMode.ts @@ -1,4 +1,4 @@ -import { LiveDataObject } from "./LiveDataObject"; +import { LiveDataObject } from "./internals/LiveDataObject"; import { LiveState } from "./LiveState"; import { ILivePresenceEvents, LivePresence } from "./LivePresence"; import { diff --git a/packages/live-share/src/LivePresence.ts b/packages/live-share/src/LivePresence.ts index 721982090..65af6c60c 100644 --- a/packages/live-share/src/LivePresence.ts +++ b/packages/live-share/src/LivePresence.ts @@ -7,16 +7,15 @@ import { DataObjectFactory, createDataObjectKind, } from "@fluidframework/aqueduct/internal"; -import { IEvent } from "@fluidframework/common-definitions"; +import { IEvent } from "@fluidframework/core-interfaces"; import { LivePresenceUser, PresenceState, ILivePresenceEvent, LivePresenceReceivedEventData, } from "./LivePresenceUser"; -import { LiveObjectSynchronizer } from "./LiveObjectSynchronizer"; +import { LiveObjectSynchronizer } from "./internals/LiveObjectSynchronizer"; import { LiveTelemetryLogger } from "./LiveTelemetryLogger"; -import { cloneValue, TelemetryEvents } from "./internals"; import { LiveDataObjectInitializeNotNeededError, LiveDataObjectNotInitializedError, @@ -29,8 +28,10 @@ import { LiveDataObjectInitializeState, UserMeetingRole, } from "./interfaces"; -import { LiveDataObject } from "./LiveDataObject"; +import { LiveDataObject } from "./internals/LiveDataObject"; import { SharedObjectKind } from "fluid-framework"; +import { cloneValue } from "./internals/utils"; +import { TelemetryEvents } from "./internals/consts"; /** * Events supported by `LivePresence` object. diff --git a/packages/live-share/src/LivePresenceConnection.ts b/packages/live-share/src/LivePresenceConnection.ts index e31351985..9fa88109f 100644 --- a/packages/live-share/src/LivePresenceConnection.ts +++ b/packages/live-share/src/LivePresenceConnection.ts @@ -1,11 +1,11 @@ -import { cloneValue } from "./internals"; import { LiveEvent } from "./LiveEvent"; import { LivePresenceReceivedEventData, PresenceState, } from "./LivePresenceUser"; -import { LiveShareRuntime } from "./LiveShareRuntime"; +import { LiveShareRuntime } from "./internals/LiveShareRuntime"; import { TimeInterval } from "./TimeInterval"; +import { cloneValue } from "./internals/utils"; /** * A connection that presence is being tracked for. diff --git a/packages/live-share/src/LivePresenceUser.ts b/packages/live-share/src/LivePresenceUser.ts index 1f973805d..508373206 100644 --- a/packages/live-share/src/LivePresenceUser.ts +++ b/packages/live-share/src/LivePresenceUser.ts @@ -6,9 +6,9 @@ import { LiveEvent } from "./LiveEvent"; import { IClientInfo, ILiveEvent, UserMeetingRole } from "./interfaces"; import { TimeInterval } from "./TimeInterval"; -import { cloneValue } from "./internals"; -import { LiveShareRuntime } from "./LiveShareRuntime"; +import { LiveShareRuntime } from "./internals/LiveShareRuntime"; import { LivePresenceConnection } from "./LivePresenceConnection"; +import { cloneValue } from "./internals/utils"; /** * List of possible presence states. diff --git a/packages/live-share/src/LiveShareClient.ts b/packages/live-share/src/LiveShareClient.ts index 239f904f9..3281114fe 100644 --- a/packages/live-share/src/LiveShareClient.ts +++ b/packages/live-share/src/LiveShareClient.ts @@ -23,10 +23,10 @@ import { import { BaseLiveShareClient } from "./internals/BaseLiveShareClient"; import { LocalTimestampProvider } from "./LocalTimestampProvider"; import { TestLiveShareHost } from "./TestLiveShareHost"; -import { LiveShareRuntime } from "./LiveShareRuntime"; +import { LiveShareRuntime } from "./internals/LiveShareRuntime"; import { getLiveContainerSchema } from "./internals/schema-injection-utils"; import { ExpectedError, UnexpectedError } from "./errors"; -import { FluidCompatibilityMode } from "./internals"; +import { FluidCompatibilityMode } from "./internals/consts"; /** * @hidden diff --git a/packages/live-share/src/LiveState.ts b/packages/live-share/src/LiveState.ts index 2a1f92ebd..0882f12cb 100644 --- a/packages/live-share/src/LiveState.ts +++ b/packages/live-share/src/LiveState.ts @@ -14,7 +14,6 @@ import { LiveDataObjectInitializeState, UserMeetingRole, } from "./interfaces"; -import { cloneValue, TelemetryEvents } from "./internals"; import { LiveDataObjectInitializeNotNeededError, LiveDataObjectNotInitializedError, @@ -22,10 +21,12 @@ import { } from "./errors"; import { LiveTelemetryLogger } from "./LiveTelemetryLogger"; import { LiveEvent } from "./LiveEvent"; -import { LiveObjectSynchronizer } from "./LiveObjectSynchronizer"; +import { LiveObjectSynchronizer } from "./internals/LiveObjectSynchronizer"; import { DynamicObjectRegistry } from "./internals/DynamicObjectRegistry"; -import { LiveDataObject } from "./LiveDataObject"; +import { LiveDataObject } from "./internals/LiveDataObject"; import { SharedObjectKind } from "fluid-framework"; +import { TelemetryEvents } from "./internals/consts"; +import { cloneValue } from "./internals/utils"; /** * Events supported by [LiveState` object. diff --git a/packages/live-share/src/LiveTelemetryLogger.ts b/packages/live-share/src/LiveTelemetryLogger.ts index dcc0818b9..5bc6e355a 100644 --- a/packages/live-share/src/LiveTelemetryLogger.ts +++ b/packages/live-share/src/LiveTelemetryLogger.ts @@ -8,8 +8,8 @@ import { ITelemetryBaseProperties, LogLevel, } from "@fluidframework/core-interfaces"; -import { IRuntimeSignaler } from "./LiveEventScope"; -import { LiveShareRuntime } from "./LiveShareRuntime"; +import { IRuntimeSignaler } from "./internals/LiveEventScope"; +import { LiveShareRuntime } from "./internals/LiveShareRuntime"; /** * Properties included on all events sent by `LiveTelemetryLogger`. diff --git a/packages/live-share/src/LiveTimer.ts b/packages/live-share/src/LiveTimer.ts index 5062805ea..6a2f967bd 100644 --- a/packages/live-share/src/LiveTimer.ts +++ b/packages/live-share/src/LiveTimer.ts @@ -7,7 +7,7 @@ import { DataObjectFactory, createDataObjectKind, } from "@fluidframework/aqueduct/internal"; -import { LiveObjectSynchronizer } from "./LiveObjectSynchronizer"; +import { LiveObjectSynchronizer } from "./internals/LiveObjectSynchronizer"; import { IClientTimestamp, ILiveEvent, @@ -17,7 +17,7 @@ import { import { IEvent } from "@fluidframework/core-interfaces"; import { LiveEvent } from "./LiveEvent"; import { DynamicObjectRegistry } from "./internals/DynamicObjectRegistry"; -import { LiveDataObject } from "./LiveDataObject"; +import { LiveDataObject } from "./internals/LiveDataObject"; import { LiveDataObjectInitializeNotNeededError, LiveDataObjectNotInitializedError, diff --git a/packages/live-share/src/TimestampProvider.ts b/packages/live-share/src/TimestampProvider.ts index 6706a5091..36ff37bfc 100644 --- a/packages/live-share/src/TimestampProvider.ts +++ b/packages/live-share/src/TimestampProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { ILiveShareHost, INtpTimeInfo, ITimestampProvider } from "./interfaces"; +import { INtpTimeInfo, ITimestampProvider } from "./interfaces"; const IMPROVE_ACCURACY_INTERVAL = 5 * 1000; const IMPROVE_ACCURACY_ATTEMPTS = 5; diff --git a/packages/live-share/src/errors.ts b/packages/live-share/src/errors.ts index 6da07284f..5cc54d4aa 100644 --- a/packages/live-share/src/errors.ts +++ b/packages/live-share/src/errors.ts @@ -1,5 +1,5 @@ -import { LiveShareReportIssueLink } from "./internals"; import { LiveDataObjectInitializeState } from "./interfaces"; +import { LiveShareReportIssueLink } from "./internals/consts"; /** * @hidden diff --git a/packages/live-share/src/index.ts b/packages/live-share/src/index.ts index 21347f8a4..60acde0bd 100644 --- a/packages/live-share/src/index.ts +++ b/packages/live-share/src/index.ts @@ -20,21 +20,3 @@ export * from "./LocalTimestampProvider"; export * from "./TestLiveShareHost"; export * from "./TimeInterval"; export * from "./TimestampProvider"; - -export * from "./LiveEventTimer"; // TODO: Delete LiveEventTime.ts - -// TODO: our package structure is such that things that need to be exposed at all for other live share libs -// are in the root of the directory even if they are "internal". move some to internal again? -export * from "./internals/BaseLiveShareClient"; -export * from "./internals/DynamicObjectRegistry"; -export * from "./internals/DynamicObjectManager"; -export * from "./internals/schema-injection-utils"; -export * from "./internals/smuggle"; - -// TODO: move to internal -export * from "./LiveDataObject"; -export * from "./LiveEventScope"; -export * from "./LiveEventSource"; -export * from "./LiveEventTarget"; -export * from "./LiveObjectSynchronizer"; -export * from "./LiveShareRuntime"; diff --git a/packages/live-share/src/internals/BaseLiveShareClient.ts b/packages/live-share/src/internals/BaseLiveShareClient.ts index 9105e6bd1..4efa8e76e 100644 --- a/packages/live-share/src/internals/BaseLiveShareClient.ts +++ b/packages/live-share/src/internals/BaseLiveShareClient.ts @@ -14,7 +14,7 @@ import { AzureContainerServices } from "@fluidframework/azure-client/internal"; import { IFluidLoadable } from "@fluidframework/core-interfaces"; import { DynamicObjectRegistry } from "./DynamicObjectRegistry"; import { DynamicObjectManager } from "./DynamicObjectManager"; -import { LiveShareRuntime } from "../LiveShareRuntime"; +import { LiveShareRuntime } from "./LiveShareRuntime"; import { getRootDataObject, getContainerRuntime, diff --git a/packages/live-share/src/internals/ContainerSynchronizer.ts b/packages/live-share/src/internals/ContainerSynchronizer.ts index 74b3bf6fb..9274c3030 100644 --- a/packages/live-share/src/internals/ContainerSynchronizer.ts +++ b/packages/live-share/src/internals/ContainerSynchronizer.ts @@ -1,5 +1,5 @@ -import { IRuntimeSignaler } from "../LiveEventScope"; -import { LiveShareRuntime } from "../LiveShareRuntime"; +import { IRuntimeSignaler } from "./LiveEventScope"; +import { LiveShareRuntime } from "./LiveShareRuntime"; import { IContainerRuntimeSignaler, ILiveEvent } from "../interfaces"; import { GetAndUpdateStateHandlers, diff --git a/packages/live-share/src/internals/DynamicObjectManager.ts b/packages/live-share/src/internals/DynamicObjectManager.ts index 3cd50f73f..0426f96a7 100644 --- a/packages/live-share/src/internals/DynamicObjectManager.ts +++ b/packages/live-share/src/internals/DynamicObjectManager.ts @@ -16,7 +16,7 @@ import { IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces"; import { assert } from "@fluidframework/core-utils/internal"; import { ConsensusRegisterCollection } from "@fluidframework/register-collection/internal"; import { DynamicObjectRegistry } from "./DynamicObjectRegistry"; -import { LiveDataObject } from "../LiveDataObject"; +import { LiveDataObject } from "./LiveDataObject"; // Register ConsensusRegisterCollection DynamicObjectRegistry.registerObjectClass( diff --git a/packages/live-share/src/LiveDataObject.ts b/packages/live-share/src/internals/LiveDataObject.ts similarity index 96% rename from packages/live-share/src/LiveDataObject.ts rename to packages/live-share/src/internals/LiveDataObject.ts index 8ef6e2141..c41f03291 100644 --- a/packages/live-share/src/LiveDataObject.ts +++ b/packages/live-share/src/internals/LiveDataObject.ts @@ -9,9 +9,9 @@ import { IClientInfo, LiveDataObjectInitializeState, UserMeetingRole, -} from "./interfaces"; -import { LiveShareReportIssueLink } from "./internals/consts"; -import { waitUntilConnected } from "./internals/utils"; +} from "../interfaces"; +import { LiveShareReportIssueLink } from "./consts"; +import { waitUntilConnected } from "./utils"; /** * Extends Fluid's DataObject class. Intended for use with Live Share custom DDS's that rely on a `ILiveShareHost`. diff --git a/packages/live-share/src/LiveEventScope.ts b/packages/live-share/src/internals/LiveEventScope.ts similarity index 97% rename from packages/live-share/src/LiveEventScope.ts rename to packages/live-share/src/internals/LiveEventScope.ts index c7beef7d6..49b25c309 100644 --- a/packages/live-share/src/LiveEventScope.ts +++ b/packages/live-share/src/internals/LiveEventScope.ts @@ -9,11 +9,12 @@ import { } from "@fluidframework/core-interfaces"; import { TypedEventEmitter } from "@fluid-internal/client-utils"; import { IInboundSignalMessage } from "@fluidframework/runtime-definitions/internal"; -import { ILiveEvent, UserMeetingRole } from "./interfaces"; +import { ILiveEvent, UserMeetingRole } from "../interfaces"; import { LiveShareRuntime } from "./LiveShareRuntime"; -import { isILiveEvent, waitUntilConnected } from "./internals"; -import { IEvent } from "@fluidframework/common-definitions"; -import { LiveTelemetryLogger } from "./LiveTelemetryLogger"; +import { IEvent } from "@fluidframework/core-interfaces"; +import { LiveTelemetryLogger } from "../LiveTelemetryLogger"; +import { isILiveEvent } from "./type-guards"; +import { waitUntilConnected } from "./utils"; /** * Live event callback. diff --git a/packages/live-share/src/LiveEventSource.ts b/packages/live-share/src/internals/LiveEventSource.ts similarity index 97% rename from packages/live-share/src/LiveEventSource.ts rename to packages/live-share/src/internals/LiveEventSource.ts index d81f5933e..1530e9ec4 100644 --- a/packages/live-share/src/LiveEventSource.ts +++ b/packages/live-share/src/internals/LiveEventSource.ts @@ -3,7 +3,7 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { ILiveEvent } from "./interfaces"; +import { ILiveEvent } from "../interfaces"; import { LiveEventScope } from "./LiveEventScope"; /** diff --git a/packages/live-share/src/LiveEventTarget.ts b/packages/live-share/src/internals/LiveEventTarget.ts similarity index 100% rename from packages/live-share/src/LiveEventTarget.ts rename to packages/live-share/src/internals/LiveEventTarget.ts diff --git a/packages/live-share/src/internals/LiveObjectManager.ts b/packages/live-share/src/internals/LiveObjectManager.ts index bccadc31b..c105bbbaf 100644 --- a/packages/live-share/src/internals/LiveObjectManager.ts +++ b/packages/live-share/src/internals/LiveObjectManager.ts @@ -5,23 +5,22 @@ import { IInboundSignalMessage } from "@fluidframework/runtime-definitions/internal"; import { TypedEventEmitter } from "@fluid-internal/client-utils"; -import { IRuntimeSignaler } from "../LiveEventScope"; -import { LiveShareRuntime } from "../LiveShareRuntime"; +import { IRuntimeSignaler } from "./LiveEventScope"; +import { LiveShareRuntime } from "./LiveShareRuntime"; import { IContainerRuntimeSignaler, ILiveEvent } from "../interfaces"; import { LiveEvent } from "../LiveEvent"; +import { IAzureAudience } from "@fluidframework/azure-client"; +import { isILiveEvent } from "./type-guards"; +import { ObjectSynchronizerEvents } from "./consts"; +import { cloneValue, waitUntilConnected } from "./utils"; +import { ContainerSynchronizer } from "./ContainerSynchronizer"; import { - ContainerSynchronizer, GetAndUpdateStateHandlers, IContainerLiveObjectStoreEvents, ILiveClientEventMap, ILiveObjectStore, - ObjectSynchronizerEvents, StateSyncEventContent, - cloneValue, - isILiveEvent, - waitUntilConnected, -} from "./"; -import { IAzureAudience } from "@fluidframework/azure-client"; +} from "./internal-interfaces"; /** * @hidden diff --git a/packages/live-share/src/LiveObjectSynchronizer.ts b/packages/live-share/src/internals/LiveObjectSynchronizer.ts similarity index 99% rename from packages/live-share/src/LiveObjectSynchronizer.ts rename to packages/live-share/src/internals/LiveObjectSynchronizer.ts index 8efa3135f..85aa86a40 100644 --- a/packages/live-share/src/LiveObjectSynchronizer.ts +++ b/packages/live-share/src/internals/LiveObjectSynchronizer.ts @@ -9,7 +9,7 @@ import { GetLocalUserCanSend, ILiveEvent, UpdateSynchronizationState, -} from "./interfaces"; +} from "../interfaces"; /** * @internal diff --git a/packages/live-share/src/LiveShareRuntime.ts b/packages/live-share/src/internals/LiveShareRuntime.ts similarity index 94% rename from packages/live-share/src/LiveShareRuntime.ts rename to packages/live-share/src/internals/LiveShareRuntime.ts index 9d39adab8..f427972aa 100644 --- a/packages/live-share/src/LiveShareRuntime.ts +++ b/packages/live-share/src/internals/LiveShareRuntime.ts @@ -1,5 +1,5 @@ import { assert } from "@fluidframework/core-utils/internal"; -import { HostTimestampProvider } from "./HostTimestampProvider"; +import { HostTimestampProvider } from "../HostTimestampProvider"; import { IClientInfo, ILiveShareHost, @@ -7,17 +7,15 @@ import { ITimestampProvider, UserMeetingRole, IContainerRuntimeSignaler, -} from "./interfaces"; -import { - BackwardsCompatibilityHostDecorator, - LiveShareHostDecorator, - RoleVerifier, - isTimestampProvider, - LiveObjectManager, - FormatFixHostDecorator, -} from "./internals"; +} from "../interfaces"; import { IAzureAudience } from "@fluidframework/azure-client"; -import { ILiveShareClientOptions } from "./LiveShareClient"; +import { ILiveShareClientOptions } from "../LiveShareClient"; +import { isTimestampProvider } from "./type-guards"; +import { LiveObjectManager } from "./LiveObjectManager"; +import { RoleVerifier } from "./RoleVerifier"; +import { BackwardsCompatibilityHostDecorator } from "./BackwardsCompatibilityHostDecorator"; +import { LiveShareHostDecorator } from "./LiveShareHostDecorator"; +import { FormatFixHostDecorator } from "./FormatFixHostDecorator"; /** * Runtime for LiveDataObject, which is used to do things like validate roles, get a timestamp diff --git a/packages/live-share/src/internals/index.ts b/packages/live-share/src/internals/index.ts deleted file mode 100644 index 4c9651474..000000000 --- a/packages/live-share/src/internals/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Microsoft Live Share SDK License. - */ - -export * from "./consts"; -export * from "./LiveShareTokenProvider"; -export * from "./RequestCache"; -export * from "./RoleVerifier"; -export * from "./utils"; -export * from "./LiveShareHostDecorator"; -export * from "./BackwardsCompatibilityHostDecorator"; -export * from "./Deferred"; -export * from "./type-guards"; -export * from "./internal-interfaces"; -export * from "./LiveObjectManager"; -export * from "./ContainerSynchronizer"; -export * from "./FormatFixHostDecorator"; - -// TODO: delete internals/index.ts diff --git a/packages/live-share/src/internals/internal-interfaces.ts b/packages/live-share/src/internals/internal-interfaces.ts index 6155b087d..978637c54 100644 --- a/packages/live-share/src/internals/internal-interfaces.ts +++ b/packages/live-share/src/internals/internal-interfaces.ts @@ -3,7 +3,7 @@ import { ILiveEvent, UpdateSynchronizationState, } from "../interfaces"; -import { IEvent } from "@fluidframework/common-definitions"; +import { IEvent } from "@fluidframework/core-interfaces"; /** * @hidden diff --git a/packages/live-share/src/test/MockContainerRuntimeSignaler.ts b/packages/live-share/src/internals/mock/MockContainerRuntimeSignaler.ts similarity index 96% rename from packages/live-share/src/test/MockContainerRuntimeSignaler.ts rename to packages/live-share/src/internals/mock/MockContainerRuntimeSignaler.ts index aa47433de..573eeb3cb 100644 --- a/packages/live-share/src/test/MockContainerRuntimeSignaler.ts +++ b/packages/live-share/src/internals/mock/MockContainerRuntimeSignaler.ts @@ -3,8 +3,8 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { IInboundSignalMessage } from "@fluidframework/runtime-definitions"; -import { IContainerRuntimeSignaler } from "../interfaces"; +import { IInboundSignalMessage } from "@fluidframework/runtime-definitions/internal"; +import { IContainerRuntimeSignaler } from "../../interfaces"; import { v4 } from "uuid"; export class MockContainerRuntimeSignaler implements IContainerRuntimeSignaler { diff --git a/packages/live-share/src/test/MockLiveShareRuntime.ts b/packages/live-share/src/internals/mock/MockLiveShareRuntime.ts similarity index 87% rename from packages/live-share/src/test/MockLiveShareRuntime.ts rename to packages/live-share/src/internals/mock/MockLiveShareRuntime.ts index 3c04469b1..942221edc 100644 --- a/packages/live-share/src/test/MockLiveShareRuntime.ts +++ b/packages/live-share/src/internals/mock/MockLiveShareRuntime.ts @@ -1,8 +1,11 @@ import { LiveShareRuntime } from "../LiveShareRuntime"; -import { TestLiveShareHost } from "../TestLiveShareHost"; -import { IContainerRuntimeSignaler, ITimestampProvider } from "../interfaces"; +import { TestLiveShareHost } from "../../TestLiveShareHost"; +import { + IContainerRuntimeSignaler, + ITimestampProvider, +} from "../../interfaces"; import { MockContainerRuntimeSignaler } from "./MockContainerRuntimeSignaler"; -import { LocalTimestampProvider } from "../LocalTimestampProvider"; +import { LocalTimestampProvider } from "../../LocalTimestampProvider"; export class MockLiveShareRuntime extends LiveShareRuntime { constructor( diff --git a/packages/live-share/src/test/MockRoleVerifier.ts b/packages/live-share/src/internals/mock/MockRoleVerifier.ts similarity index 89% rename from packages/live-share/src/test/MockRoleVerifier.ts rename to packages/live-share/src/internals/mock/MockRoleVerifier.ts index 6b81e7d2a..a7d620716 100644 --- a/packages/live-share/src/test/MockRoleVerifier.ts +++ b/packages/live-share/src/internals/mock/MockRoleVerifier.ts @@ -3,7 +3,7 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { IRoleVerifier, UserMeetingRole } from "../interfaces"; +import { IRoleVerifier, UserMeetingRole } from "../../interfaces"; export class MockRoleVerifier implements IRoleVerifier { private _sendersRoles: UserMeetingRole[]; @@ -14,7 +14,7 @@ export class MockRoleVerifier implements IRoleVerifier { public blocked = false; public called = false; - public clientId: string; + public clientId: string = ""; public verifyRolesAllowed( clientId: string, diff --git a/packages/live-share/src/test/MockRuntimeSignaler.ts b/packages/live-share/src/internals/mock/MockRuntimeSignaler.ts similarity index 99% rename from packages/live-share/src/test/MockRuntimeSignaler.ts rename to packages/live-share/src/internals/mock/MockRuntimeSignaler.ts index 610d2744a..630b1c233 100644 --- a/packages/live-share/src/test/MockRuntimeSignaler.ts +++ b/packages/live-share/src/internals/mock/MockRuntimeSignaler.ts @@ -3,7 +3,7 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { IInboundSignalMessage } from "@fluidframework/runtime-definitions"; +import { IInboundSignalMessage } from "@fluidframework/runtime-definitions/internal"; import { MockLogger } from "@fluidframework/telemetry-utils/internal"; import { IRuntimeSignaler } from "../LiveEventScope"; import { v4 } from "uuid"; diff --git a/packages/live-share/src/test/MockTimestampProvider.ts b/packages/live-share/src/internals/mock/MockTimestampProvider.ts similarity index 88% rename from packages/live-share/src/test/MockTimestampProvider.ts rename to packages/live-share/src/internals/mock/MockTimestampProvider.ts index 565d9b042..7c0d4690c 100644 --- a/packages/live-share/src/test/MockTimestampProvider.ts +++ b/packages/live-share/src/internals/mock/MockTimestampProvider.ts @@ -3,7 +3,7 @@ * Licensed under the Microsoft Live Share SDK License. */ -import { ITimestampProvider } from "../interfaces"; +import { ITimestampProvider } from "../../interfaces"; export class MockTimestampProvider implements ITimestampProvider { public called = false; diff --git a/packages/live-share/src/internals/schema-injection-utils.ts b/packages/live-share/src/internals/schema-injection-utils.ts index 7303fed1c..10b433f1d 100644 --- a/packages/live-share/src/internals/schema-injection-utils.ts +++ b/packages/live-share/src/internals/schema-injection-utils.ts @@ -3,8 +3,8 @@ import { IDataObjectProps, } from "@fluidframework/aqueduct/internal"; import { IFluidLoadable } from "@fluidframework/core-interfaces"; -import { LiveDataObject } from "../LiveDataObject"; -import { LiveShareRuntime } from "../LiveShareRuntime"; +import { LiveDataObject } from "./LiveDataObject"; +import { LiveShareRuntime } from "./LiveShareRuntime"; import { LoadableObjectCtor, LoadableObjectClassRecord, diff --git a/packages/live-share/src/internals/test/FormatFixHostDecorator.spec.ts b/packages/live-share/src/internals/test/FormatFixHostDecorator.spec.ts index bcdf41998..99f1c4b38 100644 --- a/packages/live-share/src/internals/test/FormatFixHostDecorator.spec.ts +++ b/packages/live-share/src/internals/test/FormatFixHostDecorator.spec.ts @@ -1,6 +1,6 @@ import { ILiveShareHost, UserMeetingRole, IClientInfo } from "../../interfaces"; import { strict as assert } from "assert"; -import { FormatFixHostDecorator } from ".."; +import { FormatFixHostDecorator } from "../FormatFixHostDecorator"; class HostWithAndroidBug { constructor(private result: unknown) {} diff --git a/packages/live-share/src/test/LiveEventScope.spec.ts b/packages/live-share/src/internals/test/LiveEventScope.spec.ts similarity index 95% rename from packages/live-share/src/test/LiveEventScope.spec.ts rename to packages/live-share/src/internals/test/LiveEventScope.spec.ts index 81f7080f6..fa54d54ef 100644 --- a/packages/live-share/src/test/LiveEventScope.spec.ts +++ b/packages/live-share/src/internals/test/LiveEventScope.spec.ts @@ -5,12 +5,12 @@ import { strict as assert } from "assert"; import { LiveEventScope } from "../LiveEventScope"; -import { UserMeetingRole } from "../interfaces"; -import { MockRuntimeSignaler } from "./MockRuntimeSignaler"; -import { MockRoleVerifier } from "./MockRoleVerifier"; -import { MockTimestampProvider } from "./MockTimestampProvider"; -import { LocalTimestampProvider } from "../LocalTimestampProvider"; -import { TestLiveShareHost } from "../TestLiveShareHost"; +import { UserMeetingRole } from "../../interfaces"; +import { MockRuntimeSignaler } from "../mock/MockRuntimeSignaler"; +import { MockRoleVerifier } from "../mock/MockRoleVerifier"; +import { MockTimestampProvider } from "../mock/MockTimestampProvider"; +import { LocalTimestampProvider } from "../../LocalTimestampProvider"; +import { TestLiveShareHost } from "../../TestLiveShareHost"; import { LiveShareRuntime } from "../LiveShareRuntime"; function createConnectedSignalers() { diff --git a/packages/live-share/src/test/LiveEventSource.spec.ts b/packages/live-share/src/internals/test/LiveEventSource.spec.ts similarity index 91% rename from packages/live-share/src/test/LiveEventSource.spec.ts rename to packages/live-share/src/internals/test/LiveEventSource.spec.ts index 6b85a979a..92a532409 100644 --- a/packages/live-share/src/test/LiveEventSource.spec.ts +++ b/packages/live-share/src/internals/test/LiveEventSource.spec.ts @@ -6,10 +6,10 @@ import { strict as assert } from "assert"; import { LiveEventScope } from "../LiveEventScope"; import { LiveEventSource } from "../LiveEventSource"; -import { MockRuntimeSignaler } from "./MockRuntimeSignaler"; +import { MockRuntimeSignaler } from "../mock/MockRuntimeSignaler"; import { LiveShareRuntime } from "../LiveShareRuntime"; -import { TestLiveShareHost } from "../TestLiveShareHost"; -import { LocalTimestampProvider } from "../LocalTimestampProvider"; +import { TestLiveShareHost } from "../../TestLiveShareHost"; +import { LocalTimestampProvider } from "../../LocalTimestampProvider"; function createConnectedSignalers() { const localRuntime = new MockRuntimeSignaler(); diff --git a/packages/live-share/src/test/LiveEventTarget.spec.ts b/packages/live-share/src/internals/test/LiveEventTarget.spec.ts similarity index 91% rename from packages/live-share/src/test/LiveEventTarget.spec.ts rename to packages/live-share/src/internals/test/LiveEventTarget.spec.ts index 5bb6dc052..b305f158f 100644 --- a/packages/live-share/src/test/LiveEventTarget.spec.ts +++ b/packages/live-share/src/internals/test/LiveEventTarget.spec.ts @@ -6,10 +6,10 @@ import { strict as assert } from "assert"; import { LiveEventScope } from "../LiveEventScope"; import { LiveEventTarget } from "../LiveEventTarget"; -import { MockRuntimeSignaler } from "./MockRuntimeSignaler"; +import { MockRuntimeSignaler } from "../mock/MockRuntimeSignaler"; import { LiveShareRuntime } from "../LiveShareRuntime"; -import { TestLiveShareHost } from "../TestLiveShareHost"; -import { LocalTimestampProvider } from "../LocalTimestampProvider"; +import { TestLiveShareHost } from "../../TestLiveShareHost"; +import { LocalTimestampProvider } from "../../LocalTimestampProvider"; function createConnectedSignalers() { const localRuntime = new MockRuntimeSignaler(); diff --git a/packages/live-share/src/test/LiveObjectSynchronizer.spec.ts b/packages/live-share/src/internals/test/LiveObjectSynchronizer.spec.ts similarity index 98% rename from packages/live-share/src/test/LiveObjectSynchronizer.spec.ts rename to packages/live-share/src/internals/test/LiveObjectSynchronizer.spec.ts index f94804fe2..969704039 100644 --- a/packages/live-share/src/test/LiveObjectSynchronizer.spec.ts +++ b/packages/live-share/src/internals/test/LiveObjectSynchronizer.spec.ts @@ -5,9 +5,10 @@ import { strict as assert } from "assert"; import { LiveObjectSynchronizer } from "../LiveObjectSynchronizer"; -import { MockRuntimeSignaler } from "./MockRuntimeSignaler"; -import { Deferred, waitForDelay } from "../internals"; -import { MockLiveShareRuntime } from "./MockLiveShareRuntime"; +import { MockRuntimeSignaler } from "../mock/MockRuntimeSignaler"; +import { Deferred } from "../Deferred"; +import { waitForDelay } from "../utils"; +import { MockLiveShareRuntime } from "../mock/MockLiveShareRuntime"; interface ITestState { client: "local" | "remote"; diff --git a/packages/live-share/src/internals/utils.ts b/packages/live-share/src/internals/utils.ts index 71166a24d..b9e35aa79 100644 --- a/packages/live-share/src/internals/utils.ts +++ b/packages/live-share/src/internals/utils.ts @@ -5,7 +5,7 @@ import { ITokenProvider } from "@fluidframework/azure-client"; import { v4 as uuid } from "uuid"; -import { IRuntimeSignaler } from "../LiveEventScope"; +import { IRuntimeSignaler } from "./LiveEventScope"; /** * @hidden diff --git a/packages/live-share/src/test/LiveEvent.spec.ts b/packages/live-share/src/test/LiveEvent.spec.ts index b32dccfb7..3e02e2318 100644 --- a/packages/live-share/src/test/LiveEvent.spec.ts +++ b/packages/live-share/src/test/LiveEvent.spec.ts @@ -10,15 +10,15 @@ import { getContainerEntryPointBackCompat, } from "@fluidframework/test-utils/internal"; import { LiveEvent } from "../LiveEvent"; -import { Deferred } from "../internals"; -import { MockTimestampProvider } from "./MockTimestampProvider"; -import { MockRoleVerifier } from "./MockRoleVerifier"; +import { MockTimestampProvider } from "../internals/mock/MockTimestampProvider"; +import { MockRoleVerifier } from "../internals/mock/MockRoleVerifier"; import { LocalTimestampProvider } from "../LocalTimestampProvider"; import { UserMeetingRole, ILiveEvent } from "../interfaces"; import { TestLiveShareHost } from "../TestLiveShareHost"; import { getLiveDataObjectKind } from "../internals/schema-injection-utils"; -import { LiveShareRuntime } from "../LiveShareRuntime"; +import { LiveShareRuntime } from "../internals/LiveShareRuntime"; import { describeCompat } from "@live-share-private/test-utils"; +import { Deferred } from "../internals/Deferred"; describeCompat("LiveEvent", (getTestObjectProvider) => { let provider: ITestObjectProvider; diff --git a/packages/live-share/src/test/LiveEventTimer.spec.ts b/packages/live-share/src/test/LiveEventTimer.spec.ts deleted file mode 100644 index 1a94f12ba..000000000 --- a/packages/live-share/src/test/LiveEventTimer.spec.ts +++ /dev/null @@ -1,130 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Microsoft Live Share SDK License. - */ - -import { strict as assert } from "assert"; -import { LiveEventScope } from "../LiveEventScope"; -import { LiveEventTarget } from "../LiveEventTarget"; -import { LiveEventTimer } from "../LiveEventTimer"; -import { MockRuntimeSignaler } from "./MockRuntimeSignaler"; -import { LiveShareRuntime } from "../LiveShareRuntime"; -import { TestLiveShareHost } from "../TestLiveShareHost"; -import { LocalTimestampProvider } from "../LocalTimestampProvider"; - -function createConnectedSignalers() { - const localRuntime = new MockRuntimeSignaler(); - const remoteRuntime = new MockRuntimeSignaler(); - MockRuntimeSignaler.connectRuntimes([localRuntime, remoteRuntime]); - return { localRuntime, remoteRuntime }; -} - -describe("LiveEventTimer", () => { - let localLiveRuntime = new LiveShareRuntime(TestLiveShareHost.create(), { - timestampProvider: new LocalTimestampProvider(), - }); - let remoteLiveRuntime = new LiveShareRuntime(TestLiveShareHost.create(), { - timestampProvider: new LocalTimestampProvider(), - }); - - afterEach(async () => { - // restore defaults - localLiveRuntime = new LiveShareRuntime(TestLiveShareHost.create(), { - timestampProvider: new LocalTimestampProvider(), - }); - remoteLiveRuntime = new LiveShareRuntime(TestLiveShareHost.create(), { - timestampProvider: new LocalTimestampProvider(), - }); - }); - - it("Should send a single event after a delay", (done) => { - let created = 0; - let triggered = 0; - const signalers = createConnectedSignalers(); - const localScope = new LiveEventScope( - signalers.localRuntime, - localLiveRuntime - ); - const localTarget = new LiveEventTarget<{}>( - localScope, - "test", - (evt, local) => triggered++ - ); - const localTimer = new LiveEventTimer( - localTarget, - () => { - created++; - return {}; - }, - 10 - ); - - const remoteScope = new LiveEventScope( - signalers.remoteRuntime, - remoteLiveRuntime - ); - const remoteTarget = new LiveEventTarget( - remoteScope, - "test", - (evt, local) => triggered++ - ); - - localTimer.start(); - assert(created == 0); - setTimeout(() => { - assert(created == 1, `Message creation count is ${created}`); - assert( - triggered == created * 2, - `Messages created is ${created} but received is an unexpected ${triggered}` - ); - localTimer.stop(); - done(); - }, 50); - }); - - it("Should repeatedly send events after a delay", (done) => { - let created = 0; - let triggered = 0; - const signalers = createConnectedSignalers(); - const localScope = new LiveEventScope( - signalers.localRuntime, - localLiveRuntime - ); - const localTarget = new LiveEventTarget<{}>( - localScope, - "test", - (evt, local) => triggered++ - ); - const localTimer = new LiveEventTimer( - localTarget, - () => { - created++; - return {}; - }, - 5, - true - ); - - const remoteScope = new LiveEventScope( - signalers.remoteRuntime, - remoteLiveRuntime - ); - const remoteTarget = new LiveEventTarget( - remoteScope, - "test", - (evt, local) => triggered++ - ); - - localTimer.start(); - assert(created == 0); - setTimeout(() => { - assert(created > 1, `Message creation count is ${created}`); - assert( - triggered == created * 2, - `Messages created is ${created} but received is an unexpected ${triggered}` - ); - localTimer.stop(); - done(); - }, 50); - }); -}); diff --git a/packages/live-share/src/test/LiveFollowMode.spec.ts b/packages/live-share/src/test/LiveFollowMode.spec.ts index 0d378bf26..9b1a9fa4f 100644 --- a/packages/live-share/src/test/LiveFollowMode.spec.ts +++ b/packages/live-share/src/test/LiveFollowMode.spec.ts @@ -15,11 +15,12 @@ import { IFollowModeState, LiveFollowMode, } from "../LiveFollowMode"; -import { Deferred, waitForDelay } from "../internals"; import { getLiveDataObjectKind } from "../internals/schema-injection-utils"; -import { MockLiveShareRuntime } from "./MockLiveShareRuntime"; +import { MockLiveShareRuntime } from "../internals/mock/MockLiveShareRuntime"; import { LivePresenceUser } from "../LivePresenceUser"; import { describeCompat } from "@live-share-private/test-utils"; +import { waitForDelay } from "../internals/utils"; +import { Deferred } from "../internals/Deferred"; interface TestFollowData { page: string; diff --git a/packages/live-share/src/test/LivePresence.spec.ts b/packages/live-share/src/test/LivePresence.spec.ts index a4d5578bb..702b71220 100644 --- a/packages/live-share/src/test/LivePresence.spec.ts +++ b/packages/live-share/src/test/LivePresence.spec.ts @@ -9,10 +9,10 @@ import { fluidEntryPoint, getContainerEntryPointBackCompat, } from "@fluidframework/test-utils/internal"; -import { LivePresence, LivePresenceClass } from "../LivePresence"; +import { LivePresenceClass } from "../LivePresence"; import { PresenceState } from "../LivePresenceUser"; -import { waitForDelay } from "../internals"; -import { Deferred } from "../internals"; +import { waitForDelay } from "../internals/utils"; +import { Deferred } from "../internals/Deferred"; import { IClientInfo, IFluidContainerInfo, @@ -23,7 +23,7 @@ import { } from "../interfaces"; import { TestLiveShareHost } from "../TestLiveShareHost"; import { getLiveDataObjectKind } from "../internals/schema-injection-utils"; -import { MockLiveShareRuntime } from "./MockLiveShareRuntime"; +import { MockLiveShareRuntime } from "../internals/mock/MockLiveShareRuntime"; import { describeCompat } from "@live-share-private/test-utils"; class TestLivePresence< diff --git a/packages/live-share/src/test/LiveState.spec.ts b/packages/live-share/src/test/LiveState.spec.ts index d80647231..606fc5431 100644 --- a/packages/live-share/src/test/LiveState.spec.ts +++ b/packages/live-share/src/test/LiveState.spec.ts @@ -10,9 +10,9 @@ import { getContainerEntryPointBackCompat, } from "@fluidframework/test-utils/internal"; import { LiveState } from "../LiveState"; -import { Deferred } from "../internals"; +import { Deferred } from "../internals/Deferred"; import { getLiveDataObjectKind } from "../internals/schema-injection-utils"; -import { MockLiveShareRuntime } from "./MockLiveShareRuntime"; +import { MockLiveShareRuntime } from "../internals/mock/MockLiveShareRuntime"; import { describeCompat } from "@live-share-private/test-utils"; interface TestStateData { diff --git a/packages/live-share/src/test/LiveTimer.spec.ts b/packages/live-share/src/test/LiveTimer.spec.ts index 5421b324b..87f693433 100644 --- a/packages/live-share/src/test/LiveTimer.spec.ts +++ b/packages/live-share/src/test/LiveTimer.spec.ts @@ -10,10 +10,11 @@ import { getContainerEntryPointBackCompat, } from "@fluidframework/test-utils/internal"; import { LiveTimer } from "../LiveTimer"; -import { Deferred, waitForDelay } from "../internals"; +import { Deferred } from "../internals/Deferred"; import { getLiveDataObjectKind } from "../internals/schema-injection-utils"; -import { MockLiveShareRuntime } from "./MockLiveShareRuntime"; +import { MockLiveShareRuntime } from "../internals/mock/MockLiveShareRuntime"; import { describeCompat } from "@live-share-private/test-utils"; +import { waitForDelay } from "../internals/utils"; async function getObjects( getTestObjectProvider, diff --git a/packages/live-share/src/test/TimestampProvider.spec.ts b/packages/live-share/src/test/TimestampProvider.spec.ts index 7199dd445..865e3f588 100644 --- a/packages/live-share/src/test/TimestampProvider.spec.ts +++ b/packages/live-share/src/test/TimestampProvider.spec.ts @@ -6,7 +6,7 @@ import { strict as assert } from "assert"; import { INtpTimeInfo } from "../interfaces"; import { TimestampProvider } from "../TimestampProvider"; -import { Deferred } from "../internals"; +import { Deferred } from "../internals/Deferred"; class TestTimestampProvider extends TimestampProvider { private _onGetNtpTime: () => Promise; diff --git a/packages/live-share/src/test/utils.spec.ts b/packages/live-share/src/test/utils.spec.ts index 52dc45821..9073e8531 100644 --- a/packages/live-share/src/test/utils.spec.ts +++ b/packages/live-share/src/test/utils.spec.ts @@ -1,10 +1,10 @@ import { strict as assert } from "assert"; import { + TimeoutError, timeoutRequest, - Deferred, waitForResult, - TimeoutError, -} from "../internals"; +} from "../internals/utils"; +import { Deferred } from "../internals/Deferred"; describe("timeoutRequest", function () { it("should return the result when request is successful within timeout", async () => { diff --git a/packages/live-share/tsconfig.build.json b/packages/live-share/tsconfig.build.json index 9d8cab4a6..0a07c839b 100644 --- a/packages/live-share/tsconfig.build.json +++ b/packages/live-share/tsconfig.build.json @@ -3,7 +3,4 @@ "compilerOptions": { "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ }, - "exclude": [ - "test/**/*.ts" - ] } \ No newline at end of file diff --git a/packages/live-share/tsconfig.json b/packages/live-share/tsconfig.json index 258994400..e1f304e87 100644 --- a/packages/live-share/tsconfig.json +++ b/packages/live-share/tsconfig.json @@ -66,11 +66,6 @@ "skipLibCheck": true, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ }, - "exclude": ["build", "dist", "node_modules"], - "include": [ - "test/**/*.ts" - ], - "files": [ - "src/index.ts" - ] + "include": ["src/**/*.ts"], + "exclude": ["**/*.spec.ts"] }