Skip to content

Commit dc1c691

Browse files
authored
refactor(client-presence): split files for encapsulated support (microsoft#26237)
1. Separate types where there might be multiple internal uses - especially potentially across layers origin -> new types location ------------------------------- broadcastControls.ts -> broadcastControlsTypes.ts notificationsManager.ts -> notificationsManagerTypes.ts 2. Break up internalTypes.ts type -> new location ----------------------- ExtensionRuntimeProperties, ExtensionHost, IEphemeralRuntime -> runtimeTypes.ts ClientRecord -> stateDatastore.ts PostUpdateAction, ValueManager -> statesManagerTypes.ts Validatable* -> validatableTypes.ts
1 parent ec95f86 commit dc1c691

23 files changed

+350
-310
lines changed

packages/framework/presence/src/broadcastControls.ts

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55

6-
/**
7-
* Common controls for States objects.
8-
*
9-
* @sealed
10-
* @beta
11-
*/
12-
export interface BroadcastControls {
13-
/**
14-
* Maximum time in milliseconds that a local value update is allowed
15-
* to remain pending before it must be broadcast.
16-
*
17-
* @remarks
18-
* There is no guarantee of broadcast within time allowed
19-
* as other conditions such as disconnect or service throttling may
20-
* cause a delay.
21-
*
22-
* Setting to `undefined` will restore to a system default.
23-
*/
24-
allowableUpdateLatencyMs: number | undefined;
25-
26-
/**
27-
* Target time in milliseconds between oldest changed local state
28-
* has been broadcast and forced rebroadcast of all local values.
29-
* A value of less than 10 disables forced refresh.
30-
*
31-
* @privateRemarks
32-
* Any time less than 10 milliseconds is likely to generate too
33-
* many signals. Ideally this feature becomes obsolete as
34-
* we understand the system better and account for holes.
35-
*/
36-
// forcedRefreshIntervalMs is removed until it is supported.
37-
// forcedRefreshIntervalMs: number | undefined;
38-
}
39-
40-
/**
41-
* Value set to configure {@link BroadcastControls}.
42-
*
43-
* @beta
44-
*/
45-
export interface BroadcastControlSettings {
46-
/**
47-
* {@inheritdoc BroadcastControls.allowableUpdateLatencyMs}
48-
*
49-
* @defaultValue 60 [milliseconds]
50-
*/
51-
readonly allowableUpdateLatencyMs?: number;
52-
53-
/**
54-
* {@inheritdoc BroadcastControls.forcedRefreshIntervalMs}
55-
*
56-
* @defaultValue 0 (disabled)
57-
*/
58-
// forcedRefreshIntervalMs is removed until it is supported.
59-
// readonly forcedRefreshIntervalMs?: number;
60-
}
6+
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControlsTypes.js";
617

628
class ForcedRefreshControl
639
implements
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*!
2+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
/**
7+
* Common controls for States objects.
8+
*
9+
* @sealed
10+
* @beta
11+
*/
12+
export interface BroadcastControls {
13+
/**
14+
* Maximum time in milliseconds that a local value update is allowed
15+
* to remain pending before it must be broadcast.
16+
*
17+
* @remarks
18+
* There is no guarantee of broadcast within time allowed
19+
* as other conditions such as disconnect or service throttling may
20+
* cause a delay.
21+
*
22+
* Setting to `undefined` will restore to a system default.
23+
*/
24+
allowableUpdateLatencyMs: number | undefined;
25+
26+
/**
27+
* Target time in milliseconds between oldest changed local state
28+
* has been broadcast and forced rebroadcast of all local values.
29+
* A value of less than 10 disables forced refresh.
30+
*
31+
* @privateRemarks
32+
* Any time less than 10 milliseconds is likely to generate too
33+
* many signals. Ideally this feature becomes obsolete as
34+
* we understand the system better and account for holes.
35+
*/
36+
// forcedRefreshIntervalMs is removed until it is supported.
37+
// forcedRefreshIntervalMs: number | undefined;
38+
}
39+
40+
/**
41+
* Value set to configure {@link BroadcastControls}.
42+
*
43+
* @beta
44+
*/
45+
export interface BroadcastControlSettings {
46+
/**
47+
* {@inheritdoc BroadcastControls.allowableUpdateLatencyMs}
48+
*
49+
* @defaultValue 60 [milliseconds]
50+
*/
51+
readonly allowableUpdateLatencyMs?: number;
52+
53+
/**
54+
* {@inheritdoc BroadcastControls.forcedRefreshIntervalMs}
55+
*
56+
* @defaultValue 0 (disabled)
57+
*/
58+
// forcedRefreshIntervalMs is removed until it is supported.
59+
// readonly forcedRefreshIntervalMs?: number;
60+
}

packages/framework/presence/src/getPresence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import type {
2020
IFluidDataStoreContext,
2121
} from "@fluidframework/runtime-definitions/internal";
2222

23-
import type { ExtensionHost, ExtensionRuntimeProperties } from "./internalTypes.js";
2423
import { pkgVersion } from "./packageVersion.js";
2524
import type { Presence, PresenceWithNotifications } from "./presence.js";
2625
import type { PresenceExtensionInterface } from "./presenceManager.js";
2726
import { createPresenceManager } from "./presenceManager.js";
2827
import type { SignalMessages } from "./protocol.js";
28+
import type { ExtensionHost, ExtensionRuntimeProperties } from "./runtimeTypes.js";
2929

3030
const presenceCompatibility = {
3131
generation: 1,

packages/framework/presence/src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export {
3636
export type {
3737
BroadcastControls,
3838
BroadcastControlSettings,
39-
} from "./broadcastControls.js";
39+
} from "./broadcastControlsTypes.js";
4040

4141
export {
4242
getPresence,
@@ -78,14 +78,14 @@ export type {
7878
ValueAccessor,
7979
} from "./latestValueTypes.js";
8080

81-
export {
82-
type NotificationEmitter,
83-
type NotificationListenable,
84-
type NotificationSubscriptions,
85-
Notifications,
86-
type NotificationsManager,
87-
type NotificationsManagerEvents,
88-
} from "./notificationsManager.js";
81+
export { Notifications } from "./notificationsManager.js";
82+
export type {
83+
NotificationEmitter,
84+
NotificationListenable,
85+
NotificationSubscriptions,
86+
NotificationsManager,
87+
NotificationsManagerEvents,
88+
} from "./notificationsManagerTypes.js";
8989

9090
export { StateFactory } from "./stateFactory.js";
9191

packages/framework/presence/src/internalUtils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import type {
1212
OpaqueJsonSerializable,
1313
} from "@fluidframework/core-interfaces/internal";
1414

15-
import type { ValidatableOptionalState, ValidatableRequiredState } from "./internalTypes.js";
15+
import type {
16+
ValidatableOptionalState,
17+
ValidatableRequiredState,
18+
} from "./validatableTypes.js";
1619

1720
/**
1821
* Returns union of types of values in a record.

packages/framework/presence/src/latestMapValueManager.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@ import type {
1212
JsonSerializable,
1313
} from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
1414

15-
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControls.js";
1615
import { OptionalBroadcastControl } from "./broadcastControls.js";
16+
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControlsTypes.js";
1717
import type { InternalTypes } from "./exposedInternalTypes.js";
18-
import type {
19-
PostUpdateAction,
20-
ValidatableOptionalState,
21-
ValueManager,
22-
} from "./internalTypes.js";
2318
import {
2419
asDeeplyReadonly,
2520
asDeeplyReadonlyDeserializedJson,
@@ -40,6 +35,8 @@ import type {
4035
} from "./latestValueTypes.js";
4136
import type { AttendeeId, Attendee, Presence, SpecificAttendee } from "./presence.js";
4237
import { datastoreFromHandle, type StateDatastore } from "./stateDatastore.js";
38+
import type { PostUpdateAction, ValueManager } from "./statesManagerTypes.js";
39+
import type { ValidatableOptionalState } from "./validatableTypes.js";
4340
import { brandIVM } from "./valueManager.js";
4441

4542
/**

packages/framework/presence/src/latestValueManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import type {
1212
} from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
1313
import { shallowCloneObject } from "@fluidframework/core-utils/internal";
1414

15-
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControls.js";
1615
import { OptionalBroadcastControl } from "./broadcastControls.js";
16+
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControlsTypes.js";
1717
import type { InternalTypes } from "./exposedInternalTypes.js";
18-
import type { PostUpdateAction, ValueManager } from "./internalTypes.js";
1918
import type { FlattenUnionWithOptionals } from "./internalUtils.js";
2019
import {
2120
asDeeplyReadonly,
@@ -34,6 +33,7 @@ import type {
3433
} from "./latestValueTypes.js";
3534
import type { Attendee, Presence } from "./presence.js";
3635
import { datastoreFromHandle, type StateDatastore } from "./stateDatastore.js";
36+
import type { PostUpdateAction, ValueManager } from "./statesManagerTypes.js";
3737
import { brandIVM } from "./valueManager.js";
3838

3939
/**

packages/framework/presence/src/latestValueTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import type {
99
OpaqueJsonDeserialized,
1010
} from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
1111

12-
import type { ValidatableRequiredState } from "./internalTypes.js";
1312
import { asDeeplyReadonlyDeserializedJson } from "./internalUtils.js";
1413
import type { Attendee } from "./presence.js";
14+
import type { ValidatableRequiredState } from "./validatableTypes.js";
1515

1616
/**
1717
* Metadata for the value state.

0 commit comments

Comments
 (0)