Skip to content

Commit 1810c2a

Browse files
authored
Remove presence functionality from external-views example (#26000)
1 parent 1a98fc8 commit 1810c2a

File tree

14 files changed

+17
-100
lines changed

14 files changed

+17
-100
lines changed

examples/view-integration/external-views/.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module.exports = {
77
extends: [
8-
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
8+
require.resolve("@fluidframework/eslint-config-fluid"),
99
"prettier",
1010
"../../.eslintrc.cjs",
1111
],

examples/view-integration/external-views/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"@fluidframework/datastore-definitions": "workspace:~",
5353
"@fluidframework/local-driver": "workspace:~",
5454
"@fluidframework/map": "workspace:~",
55-
"@fluidframework/presence": "workspace:~",
5655
"@fluidframework/runtime-definitions": "workspace:~",
5756
"@fluidframework/runtime-utils": "workspace:~",
5857
"@fluidframework/server-local-server": "^7.0.0",
@@ -84,7 +83,6 @@
8483
"process": "^0.11.10",
8584
"puppeteer": "^23.6.0",
8685
"rimraf": "^4.4.0",
87-
"tinylicious": "^7.0.0",
8886
"ts-jest": "^29.1.1",
8987
"ts-loader": "^9.5.1",
9088
"typescript": "~5.4.5",

examples/view-integration/external-views/src/app.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import { createElement } from "react";
2121
// eslint-disable-next-line import-x/no-internal-modules
2222
import { createRoot } from "react-dom/client";
2323

24-
import { DiceRollerContainerRuntimeFactory, type EntryPoint } from "./container/index.js";
25-
import { renderCursorPresence } from "./cursor.js";
24+
import { DiceRollerContainerRuntimeFactory, type IDiceRoller } from "./container/index.js";
2625
import { DiceRollerView } from "./view.js";
2726

2827
const service = getSpecifiedServiceFromWebpack();
@@ -68,7 +67,7 @@ if (location.hash.length === 0) {
6867
id = container.resolvedUrl.id;
6968
}
7069
} else {
71-
id = location.hash.substring(1);
70+
id = location.hash.slice(1);
7271
container = await loadExistingContainer({
7372
request: await createLoadExistingRequest(id),
7473
urlResolver,
@@ -77,16 +76,13 @@ if (location.hash.length === 0) {
7776
});
7877
}
7978

80-
const { diceRoller, presence } = (await container.getEntryPoint()) as EntryPoint;
79+
const diceRoller = (await container.getEntryPoint()) as IDiceRoller;
8180

8281
// Render view
83-
const appDiv = document.getElementById("app") as HTMLDivElement;
82+
const appDiv = document.querySelector("#app") as HTMLDivElement;
8483
const appRoot = createRoot(appDiv);
8584
appRoot.render(createElement(DiceRollerView, { diceRoller }));
8685

87-
const cursorContentDiv = document.getElementById("cursor-position") as HTMLDivElement;
88-
renderCursorPresence(presence, cursorContentDiv);
89-
9086
// Update url and tab title
9187
location.hash = id;
9288
document.title = id;

examples/view-integration/external-views/src/container/diceRoller/diceRoller.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ import type {
1212
IFluidDataStoreRuntime,
1313
} from "@fluidframework/datastore-definitions/legacy";
1414
import { MapFactory, type ISharedMap, type IValueChanged } from "@fluidframework/map/legacy";
15-
import { getPresenceFromDataStoreContext } from "@fluidframework/presence/legacy/alpha";
1615
import type {
1716
IFluidDataStoreChannel,
1817
IFluidDataStoreContext,
1918
IFluidDataStoreFactory,
2019
} from "@fluidframework/runtime-definitions/legacy";
2120

22-
import type { EntryPoint, IDiceRoller, IDiceRollerEvents } from "./interface.js";
21+
import type { IDiceRoller, IDiceRollerEvents } from "./interface.js";
2322

2423
// This key is where we store the value in the ISharedMap.
2524
const diceValueKey = "dice-value";
@@ -41,13 +40,13 @@ class DiceRoller implements IDiceRoller {
4140
});
4241
}
4342

44-
public get value() {
45-
const value = this.map.get(diceValueKey);
43+
public get value(): number {
44+
const value: unknown = this.map.get(diceValueKey);
4645
assert(typeof value === "number", "Bad dice value");
4746
return value;
4847
}
4948

50-
public readonly roll = () => {
49+
public readonly roll = (): void => {
5150
const rollValue = Math.floor(Math.random() * 6) + 1;
5251
this.map.set(diceValueKey, rollValue);
5352
};
@@ -74,12 +73,9 @@ export class DiceRollerFactory implements IFluidDataStoreFactory {
7473
): Promise<IFluidDataStoreChannel> {
7574
const provideEntryPoint = async (
7675
entryPointRuntime: IFluidDataStoreRuntime,
77-
): Promise<EntryPoint> => {
76+
): Promise<IDiceRoller> => {
7877
const map = (await entryPointRuntime.getChannel(mapId)) as ISharedMap;
79-
return {
80-
diceRoller: new DiceRoller(map),
81-
presence: getPresenceFromDataStoreContext(context),
82-
};
78+
return new DiceRoller(map);
8379
};
8480

8581
const runtime: FluidDataStoreRuntime = new FluidDataStoreRuntime(

examples/view-integration/external-views/src/container/diceRoller/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
export { DiceRollerFactory } from "./diceRoller.js";
77
export type {
8-
EntryPoint,
98
IDiceRoller,
109
IDiceRollerEvents,
1110
} from "./interface.js";

examples/view-integration/external-views/src/container/diceRoller/interface.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import type { IEvent, IEventProvider } from "@fluidframework/core-interfaces";
7-
import type { Presence } from "@fluidframework/presence/beta";
87

98
/**
109
* IDiceRollerEvents describes the events for an IDiceRoller.
@@ -32,11 +31,3 @@ export interface IDiceRoller {
3231
*/
3332
roll: () => void;
3433
}
35-
36-
/**
37-
* The entry point interface for the Dice Roller container.
38-
*/
39-
export interface EntryPoint {
40-
readonly diceRoller: IDiceRoller;
41-
readonly presence: Presence;
42-
}

examples/view-integration/external-views/src/container/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
export type {
7-
EntryPoint,
87
IDiceRoller,
98
IDiceRollerEvents,
109
} from "./diceRoller/index.js";

examples/view-integration/external-views/src/cursor.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

examples/view-integration/external-views/src/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
</head>
1111
<body style="margin: 0; height: 100%">
1212
<div id="app" style="min-height: 100%"></div>
13-
<div id="cursor-position"></div>
1413
</body>
1514
</html>

examples/view-integration/external-views/src/view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import React, { type FC, useEffect, useState } from "react";
77

8-
import { IDiceRoller } from "./container/index.js";
8+
import type { IDiceRoller } from "./container/index.js";
99

1010
export interface IDiceRollerViewProps {
1111
diceRoller: IDiceRoller;
@@ -17,7 +17,7 @@ export const DiceRollerView: FC<IDiceRollerViewProps> = ({
1717
const [diceValue, setDiceValue] = useState(diceRoller.value);
1818

1919
useEffect(() => {
20-
const onDiceRolled = () => {
20+
const onDiceRolled = (): void => {
2121
setDiceValue(diceRoller.value);
2222
};
2323
diceRoller.events.on("diceRolled", onDiceRolled);

0 commit comments

Comments
 (0)