Skip to content

Commit 8f6dd45

Browse files
authored
remove(devtools): Prototype editing code (#23741)
This code was developed as a prototype but was never formalized and is not on the near-term product roadmap. Removing the code for now to reduce maintenance burden. Note: backwards compatibility with the browser extension is not a concern here for 2 reasons: 1. The API exposes no way to enable editing, so no clients could be using the functionality 2. Even if somehow the browser extension was sending edit messages to the client, they would simply be ignored.
1 parent ad230d1 commit 8f6dd45

File tree

16 files changed

+23
-697
lines changed

16 files changed

+23
-697
lines changed

packages/tools/devtools/devtools-core/.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
"import/no-nodejs-modules": "off",
2727
"unicorn/prefer-module": "off",
2828

29-
// Superceded by chai-expect rule
29+
// Superseded by chai-expect rule
3030
"@typescript-eslint/no-unused-expressions": "off",
3131
},
3232
},

packages/tools/devtools/devtools-core/src/ContainerDevtools.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import {
1919
DataVisualizerGraph,
2020
type FluidObjectNode,
2121
type RootHandleNode,
22-
type SharedObjectEdit,
23-
defaultEditors,
2422
defaultVisualizers,
2523
} from "./data-visualization/index.js";
2624
import {
@@ -30,7 +28,6 @@ import {
3028
ContainerDevtoolsFeatures,
3129
ContainerStateChange,
3230
ContainerStateHistory,
33-
DataEdit,
3431
DataVisualization,
3532
DisconnectContainer,
3633
GetAudienceSummary,
@@ -333,15 +330,6 @@ export class ContainerDevtools implements IContainerDevtools, HasContainerKey {
333330
}
334331
return false;
335332
},
336-
337-
[DataEdit.MessageType]: async (untypedMessage) => {
338-
const message = untypedMessage as DataEdit.Message;
339-
if (message.data.containerKey === this.containerKey) {
340-
await this.editData(message.data.edit);
341-
return true;
342-
}
343-
return false;
344-
},
345333
};
346334

347335
/**
@@ -468,7 +456,7 @@ export class ContainerDevtools implements IContainerDevtools, HasContainerKey {
468456
this.dataVisualizer =
469457
props.containerData === undefined
470458
? undefined
471-
: new DataVisualizerGraph(props.containerData, defaultVisualizers, defaultEditors);
459+
: new DataVisualizerGraph(props.containerData, defaultVisualizers);
472460

473461
this.dataVisualizer?.on("update", this.dataUpdateHandler);
474462

@@ -545,9 +533,6 @@ export class ContainerDevtools implements IContainerDevtools, HasContainerKey {
545533
return {
546534
// If no container data was provided to the devtools, we cannot support data visualization.
547535
containerDataVisualization: this.containerData !== undefined,
548-
549-
// TODO: When ready to enable feature set it to this.containerData !== undefined
550-
containerDataEditing: false,
551536
};
552537
}
553538

@@ -577,11 +562,4 @@ export class ContainerDevtools implements IContainerDevtools, HasContainerKey {
577562
): Promise<FluidObjectNode | undefined> {
578563
return this.dataVisualizer?.render(fluidObjectId) ?? undefined;
579564
}
580-
581-
/**
582-
* Applies an {@link Edit} to a {@link SharedObject}
583-
*/
584-
private async editData(edit: SharedObjectEdit): Promise<void> {
585-
return this.dataVisualizer?.applyEdit(edit);
586-
}
587565
}

packages/tools/devtools/devtools-core/src/Features.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,4 @@ export interface ContainerDevtoolsFeatureFlags {
5151
* Indicates that the Container Devtools supports visualizing the data associated with the Container.
5252
*/
5353
containerDataVisualization?: boolean;
54-
55-
/**
56-
* Indicates that the Container Devtools supports editing the data associated with the Container.
57-
*/
58-
containerDataEditing?: boolean;
5954
}

packages/tools/devtools/devtools-core/src/data-visualization/DataEditing.ts

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

packages/tools/devtools/devtools-core/src/data-visualization/DataVisualization.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type { ISharedObject } from "@fluidframework/shared-object-base/internal"
1919

2020
import type { FluidObjectId } from "../CommonInterfaces.js";
2121

22-
import type { Edit, EditSharedObject, SharedObjectEdit } from "./DataEditing.js";
2322
import { visualizeUnknownSharedObject } from "./DefaultVisualizers.js";
2423
import {
2524
type FluidObjectNode,
@@ -100,23 +99,6 @@ export interface SharedObjectVisualizers {
10099
[k: SharedObjectType]: VisualizeSharedObject;
101100
}
102101

103-
/**
104-
* Specifies editors for different {@link @fluidframework/shared-object-base#ISharedObject} types.
105-
*
106-
* @remarks
107-
*
108-
* - `key`: The type of Shared object ({@link @fluidframework/datastore-definitions#IChannelFactory.Type}).
109-
*
110-
* - `value`: A editor that takes a {@link @fluidframework/shared-object-base#ISharedObject} of the
111-
* specified type and preforms the corresponding edit for it.
112-
*/
113-
export interface SharedObjectEditors {
114-
/**
115-
* Individual Fluid object editors, keyed by {@link SharedObjectType}.
116-
*/
117-
[k: SharedObjectType]: EditSharedObject;
118-
}
119-
120102
/**
121103
* Data visualization update events.
122104
*/
@@ -178,11 +160,6 @@ export class DataVisualizerGraph
178160
* Policy object for visualizing different kinds of shared objects.
179161
*/
180162
private readonly visualizers: SharedObjectVisualizers,
181-
182-
/**
183-
* Policy object for editing different kinds of shared objects.
184-
*/
185-
private readonly editors: SharedObjectEditors,
186163
) {
187164
super();
188165

@@ -243,15 +220,6 @@ export class DataVisualizerGraph
243220
return this.visualizerNodes.get(fluidObjectId)?.render() ?? undefined;
244221
}
245222

246-
/**
247-
* Applies an edit to a Fluid object.
248-
* @param edit - is a Edit object that describes an edit to a Fluid object.
249-
* @returns A promise that resolves when the editing of a {@link @fluidframework/shared-object-base#ISharedObject} is complete
250-
*/
251-
public async applyEdit(edit: SharedObjectEdit): Promise<void> {
252-
return this.visualizerNodes.get(edit.fluidObjectId)?.applyEdit(edit);
253-
}
254-
255223
/**
256224
* Adds a visualizer node to the collection for the specified
257225
* {@link @fluidframework/shared-object-base#ISharedObject} if one does not already exist.
@@ -262,13 +230,9 @@ export class DataVisualizerGraph
262230
const visualizationFunction =
263231
this.visualizers[sharedObject.attributes.type] ?? visualizeUnknownSharedObject;
264232

265-
// Create visualizer node for the shared object
266-
const editorFunction = this.editors[sharedObject.attributes.type];
267-
268233
const visualizerNode = new VisualizerNode(
269234
sharedObject,
270235
visualizationFunction,
271-
editorFunction,
272236
async (handle) => this.registerVisualizerForHandle(handle),
273237
);
274238

@@ -378,12 +342,6 @@ export class VisualizerNode
378342
*/
379343
private readonly visualizeSharedObject: VisualizeSharedObject,
380344

381-
/**
382-
* Callback for editing {@link VisualizerNode.sharedObject}.
383-
* Encapsulates the policies for editing different kinds of DDSs.
384-
*/
385-
private readonly editSharedObject: EditSharedObject,
386-
387345
/**
388346
* Registers some child handle to a Fluid object for future rendering.
389347
*
@@ -442,15 +400,6 @@ export class VisualizerNode
442400
);
443401
}
444402

445-
/**
446-
* Edits a {@link @fluidframework/shared-object-base#ISharedObject}
447-
* @param edit - Describes an edit to a Fluid object.
448-
* @returns A promise that resolves when the editing of a {@link @fluidframework/shared-object-base#ISharedObject} is complete
449-
*/
450-
public async applyEdit(edit: Edit): Promise<void> {
451-
return this.editSharedObject(this.sharedObject, edit);
452-
}
453-
454403
/**
455404
* {@inheritDoc VisualizeChildData}
456405
*/

packages/tools/devtools/devtools-core/src/data-visualization/DefaultEditors.ts

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

packages/tools/devtools/devtools-core/src/data-visualization/DefaultVisualizers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ export const visualizeUnknownSharedObject: VisualizeSharedObject = async (
309309
export const defaultVisualizers: Record<string, VisualizeSharedObject> = {
310310
[SharedCell.getFactory().type]: visualizeSharedCell,
311311
[SharedCounter.getFactory().type]: visualizeSharedCounter,
312-
// eslint-disable-next-line import/no-deprecated
313312
[SharedDirectory.getFactory().type]: visualizeSharedDirectory,
314313
[SharedMap.getFactory().type]: visualizeSharedMap,
315314
[SharedMatrix.getFactory().type]: visualizeSharedMatrix,

packages/tools/devtools/devtools-core/src/data-visualization/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export {
1515
visualizeChildData,
1616
VisualizerNode,
1717
} from "./DataVisualization.js";
18-
export type { Edit, EditData, EditSharedObject, SharedObjectEdit } from "./DataEditing.js";
19-
export { defaultEditors } from "./DefaultEditors.js";
2018
export {
2119
defaultVisualizers,
2220
visualizeSharedCell,

packages/tools/devtools/devtools-core/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ export { ContainerStateChangeKind } from "./Container.js";
3434
export type { ContainerDevtoolsProps } from "./ContainerDevtools.js";
3535
export type { ContainerStateMetadata } from "./ContainerMetadata.js";
3636
export type {
37-
Edit,
38-
EditData,
39-
EditSharedObject,
4037
FluidHandleNode,
4138
FluidObjectNode,
4239
FluidObjectNodeBase,
@@ -45,7 +42,6 @@ export type {
4542
FluidUnknownObjectNode,
4643
Primitive,
4744
RootHandleNode,
48-
SharedObjectEdit,
4945
TreeNodeBase,
5046
ValueNodeBase,
5147
VisualChildNode,
@@ -83,7 +79,6 @@ export {
8379
ContainerList,
8480
ContainerStateChange,
8581
ContainerStateHistory,
86-
DataEdit,
8782
DataVisualization,
8883
DevtoolsDisposed,
8984
DevtoolsFeatures,

packages/tools/devtools/devtools-core/src/messaging/Utilities.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,27 @@ export function handleIncomingMessage(
106106
): void {
107107
// TODO: remove loggingOptions once things settle.
108108

109-
if (message === undefined || !isDevtoolsMessage(message)) {
109+
const loggingPreamble =
110+
loggingOptions?.context === undefined ? "" : `${loggingOptions.context}: `;
111+
112+
if (message === undefined) {
113+
console.error(`${loggingPreamble} No message provided to handle.`);
114+
return;
115+
}
116+
117+
if (!isDevtoolsMessage(message)) {
118+
console.debug(`${loggingPreamble} Ignoring non-devtools message.`);
110119
return;
111120
}
112121

113122
if (handlers[message.type] === undefined) {
114123
// No handler for this type provided. No-op.
124+
console.debug(
125+
`${loggingPreamble} Ignoring message of type: "${message.type}", for which no handler was provided.`,
126+
);
115127
return;
116128
}
117129

118-
const loggingPreamble =
119-
loggingOptions?.context === undefined ? "" : `${loggingOptions.context}: `;
120-
121130
handlers[message.type](message).then(
122131
(wasMessageHandled) => {
123132
// Only log if the message was actually handled by the recipient.

0 commit comments

Comments
 (0)