Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions .changeset/beige-candles-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"fluid-framework": minor
"@fluidframework/presence": minor
"__section": deprecation
---
`getPresence` from `@fluidframework/presence` is deprecated and will be removed in a future release.

Now `getPresence` is available for import from the `fluid-framework` package.

To prepare, make changes following this pattern:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think we should expand this a bit. Something like "The export from @fluidframework/presence is now deprecated and will be removed in a future release. Please update any existing imports as follows:"

```diff
-import { getPresence } from "@fluidframework/presence/beta";
+import { getPresence } from "fluid-framework/beta";
```

See [issue #26397](https://github.com/microsoft/FluidFramework/issues/26397) for more details.
2 changes: 1 addition & 1 deletion docs/docs/build/presence.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function logOthersCounters(counterTracker: LatestMap<number, string>): void {
To access Presence APIs, use `getPresence()` with any `IFluidContainer`.

```typescript
import { getPresence } from "@fluidframework/presence/beta";
import { getPresence } from "fluid-framework/beta";

function usePresence(container: IFluidContainer): void {
const presence = getPresence(container);
Expand Down
7 changes: 2 additions & 5 deletions examples/apps/presence-tracker/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
* Licensed under the MIT License.
*/

import {
getPresence,
type AttendeeId,
type AttendeeStatus,
} from "@fluidframework/presence/beta";
import type { AttendeeId, AttendeeStatus } from "@fluidframework/presence/beta";
import { TinyliciousClient } from "@fluidframework/tinylicious-client";
import type { ContainerSchema, IFluidContainer } from "fluid-framework";
import { getPresence } from "fluid-framework/beta";

import { FocusTracker } from "./FocusTracker.js";
import { MouseTracker } from "./MouseTracker.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import { AzureClient, type AzureContainerServices } from "@fluidframework/azure-client";
import { createDevtoolsLogger, initializeDevtools } from "@fluidframework/devtools/beta";
import { getPresence } from "@fluidframework/presence/beta";
import { createChildLogger } from "@fluidframework/telemetry-utils/legacy";
import type { IFluidContainer } from "fluid-framework";
import { getPresence } from "fluid-framework/beta";

import { DiceRollerController, type DieValue } from "./controller.js";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ export function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSc
// @alpha
export function getJsonSchema(schema: ImplicitAllowedTypes, options: Required<TreeSchemaEncodingOptions>): JsonTreeSchema;

// @beta
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @alpha
export function getPresenceAlpha(fluidContainer: IFluidContainer): PresenceWithNotifications;

// @alpha
export function getSimpleSchema(schema: ImplicitFieldSchema): SimpleTreeSchema<SchemaType.View>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ export const ForestTypeOptimized: ForestType;
// @beta
export const ForestTypeReference: ForestType;

// @beta
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @public
export interface IConnection {
readonly id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ export const ForestTypeOptimized: ForestType;
// @beta
export const ForestTypeReference: ForestType;

// @beta
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @beta @legacy
export interface IBranchOrigin {
id: string;
Expand Down
1 change: 1 addition & 0 deletions packages/framework/fluid-framework/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type {
MemberChangedListener,
Myself,
} from "@fluidframework/fluid-static";
export { getPresence, getPresenceAlpha } from "@fluidframework/fluid-static/internal";
export type { SharedObjectKind } from "@fluidframework/shared-object-base";
export type {
IErrorBase,
Expand Down
4 changes: 4 additions & 0 deletions packages/framework/fluid-static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ For more information on the related support guarantees, see [API Support Levels]

To access the `public` ([SemVer](https://semver.org/)) APIs, import via `@fluidframework/fluid-static` like normal.

To access the `beta` APIs, import via `@fluidframework/fluid-static/beta`.

To access the `alpha` APIs, import via `@fluidframework/fluid-static/alpha`.

To access the `legacy` APIs, import via `@fluidframework/fluid-static/legacy`.

## API Documentation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
"mainEntryPointFilePath": "<projectFolder>/dist/alpha.d.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
"mainEntryPointFilePath": "<projectFolder>/lib/alpha.d.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
"mainEntryPointFilePath": "<projectFolder>/dist/beta.d.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
"mainEntryPointFilePath": "<projectFolder>/lib/beta.d.ts"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.current.json",
"mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
"mainEntryPointFilePath": "<projectFolder>/lib/alpha.d.ts",
"apiReport": {
"reportVariants": ["public", "beta", "alpha"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
## Alpha API Report File for "@fluidframework/fluid-static"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public
export type CompatibilityMode = "1" | "2";

// @public
export type ContainerAttachProps<T = unknown> = T;

// @public
export interface ContainerSchema {
readonly dynamicObjectTypes?: readonly SharedObjectKind[];
readonly initialObjects: Record<string, SharedObjectKind>;
}

// @beta
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @alpha
export function getPresenceAlpha(fluidContainer: IFluidContainer): PresenceWithNotifications;

// @public
export interface IConnection {
readonly id: string;
readonly mode: "write" | "read";
}

// @public @sealed
export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
attach(props?: ContainerAttachProps): Promise<string>;
readonly attachState: AttachState;
connect(): void;
readonly connectionState: ConnectionState;
create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
disconnect(): void;
dispose(): void;
readonly disposed: boolean;
readonly initialObjects: InitialObjects<TContainerSchema>;
readonly isDirty: boolean;
}

// @public @sealed
export interface IFluidContainerEvents extends IEvent {
(event: "connected", listener: () => void): void;
(event: "disconnected", listener: () => void): void;
(event: "saved", listener: () => void): void;
(event: "dirty", listener: () => void): void;
(event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
}

// @public
export interface IMember {
readonly connections: IConnection[];
readonly id: string;
}

// @public
export type InitialObjects<T extends ContainerSchema> = {
[K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<infer TChannel> ? TChannel : never;
};

// @public
export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
getMembers(): ReadonlyMap<string, M>;
getMyself(): Myself<M> | undefined;
}

// @public
export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
// @eventProperty
(event: "membersChanged", listener: () => void): void;
// @eventProperty
(event: "memberAdded", listener: MemberChangedListener<M>): void;
// @eventProperty
(event: "memberRemoved", listener: MemberChangedListener<M>): void;
}

// @public
export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;

// @public
export type Myself<M extends IMember = IMember> = M & {
readonly currentConnection: string;
};

```
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface ContainerSchema {
readonly initialObjects: Record<string, SharedObjectKind>;
}

// @beta
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @public
export interface IConnection {
readonly id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function createTreeContainerRuntimeFactory(props: {
readonly minVersionForCollabOverride?: MinimumVersionForCollab;
}): IRuntimeFactory;

// @beta
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @public
export interface IConnection {
readonly id: string;
Expand Down
26 changes: 26 additions & 0 deletions packages/framework/fluid-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
"default": "./dist/index.js"
}
},
"./beta": {
"import": {
"types": "./lib/beta.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/beta.d.ts",
"default": "./dist/index.js"
}
},
"./alpha": {
"import": {
"types": "./lib/alpha.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/alpha.d.ts",
"default": "./dist/index.js"
}
},
"./legacy": {
"import": {
"types": "./lib/legacy.d.ts",
Expand Down Expand Up @@ -65,8 +85,12 @@
"check:biome": "biome check .",
"check:exports": "concurrently \"npm:check:exports:*\"",
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
"check:exports:cjs:alpha": "api-extractor run --config api-extractor/api-extractor-lint-alpha.cjs.json",
"check:exports:cjs:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.cjs.json",
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
"check:exports:esm:alpha": "api-extractor run --config api-extractor/api-extractor-lint-alpha.esm.json",
"check:exports:esm:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.esm.json",
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
"check:format": "npm run check:biome",
Expand Down Expand Up @@ -114,6 +138,8 @@
},
"dependencies": {
"@fluid-internal/client-utils": "workspace:~",
"@fluid-internal/presence-definitions": "workspace:~",
"@fluid-internal/presence-runtime": "workspace:~",
"@fluidframework/aqueduct": "workspace:~",
"@fluidframework/container-definitions": "workspace:~",
"@fluidframework/container-loader": "workspace:~",
Expand Down
43 changes: 43 additions & 0 deletions packages/framework/fluid-static/src/getPresence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

import type {
Presence,
PresenceWithNotifications,
} from "@fluid-internal/presence-definitions";
import {
ContainerPresenceFactory,
extensionId,
// eslint-disable-next-line import-x/no-internal-modules -- any import spec is allowed for @fluid-internal/ imports - eslint-config-fluid needs updated
} from "@fluid-internal/presence-runtime/extension";
import { assert } from "@fluidframework/core-utils/internal";

import type { IFluidContainer } from "./fluidContainer.js";
import { isInternalFluidContainer } from "./fluidContainer.js";

/**
* Acquire a {@link @fluidframework/presence#Presence} from a Fluid Container
* @param fluidContainer - Fluid Container to acquire the map from
* @returns the {@link @fluidframework/presence#Presence}
*
* @beta
*/
export const getPresence: (fluidContainer: IFluidContainer) => Presence = getPresenceAlpha;

/**
* Acquire a {@link @fluidframework/presence#PresenceWithNotifications} from a Fluid Container
* @param fluidContainer - Fluid Container to acquire the map from
* @returns the {@link @fluidframework/presence#PresenceWithNotifications}
*
* @alpha
*/
export function getPresenceAlpha(fluidContainer: IFluidContainer): PresenceWithNotifications {
assert(
isInternalFluidContainer(fluidContainer),
0xa2f /* IFluidContainer was not recognized. Only Containers generated by the Fluid Framework are supported. */,
);
const presence = fluidContainer.acquireExtension(extensionId, ContainerPresenceFactory);
return presence;
}
1 change: 1 addition & 0 deletions packages/framework/fluid-static/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
type IFluidContainerInternal,
type InitialObjects,
} from "./fluidContainer.js";
export { getPresence, getPresenceAlpha } from "./getPresence.js";
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
export { createServiceAudience } from "./serviceAudience.js";
export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/presence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function logOthersCounters(counterTracker: LatestMap<number, string>): void {
To access Presence APIs, use `getPresence()` with any `IFluidContainer`.

```typescript
import { getPresence } from "@fluidframework/presence/beta";
import { getPresence } from "fluid-framework/beta";

function usePresence(container: IFluidContainer): void {
const presence = getPresence(container);
Expand Down
5 changes: 1 addition & 4 deletions packages/framework/presence/api-report/presence.alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ export interface BroadcastControlSettings {
// @beta
export type ClientConnectionId = string;

// @beta
// @beta @deprecated
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @alpha
export function getPresenceAlpha(fluidContainer: IFluidContainer): PresenceWithNotifications;

// @beta @system
export namespace InternalPresenceTypes {
// @system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface BroadcastControlSettings {
// @beta
export type ClientConnectionId = string;

// @beta
// @beta @deprecated
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @beta @system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ export interface BroadcastControlSettings {
// @beta
export type ClientConnectionId = string;

// @beta
// @beta @deprecated
export const getPresence: (fluidContainer: IFluidContainer) => Presence;

// @alpha
export function getPresenceAlpha(fluidContainer: IFluidContainer): PresenceWithNotifications;

// @alpha @legacy
export function getPresenceFromDataStoreContext(context: IFluidDataStoreContext): Presence;

Expand Down
Loading
Loading