@fluidframework/devtools-core 2.70.0-360753 → 2.70.0-361248

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"DevtoolsLogger.js","sourceRoot":"","sources":["../src/DevtoolsLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,mDAS8B;AAkB9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,cAAc;IAuDnB,aAAa;IAEb,YAAmB,UAAiC;QA7CpD;;WAEG;QACc,0BAAqB,GAA0B;YAC/D,OAAO,EAAE,qBAAqB;SAC9B,CAAC;QAEF;;WAEG;QACc,2BAAsB,GAAoB;YAC1D,CAAC,8BAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;gBAC3D,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC;QAEF;;WAEG;QACc,yBAAoB,GAAG,CACvC,KAA8C,EACvC,EAAE;YACT,IAAA,sCAA2B,EAC1B,KAAK,EACL,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACH,CAAC,CAAC;QAEF;;;WAGG;QACc,mBAAc,GAAG,GAAS,EAAE;YAC5C,IAAA,+BAAoB,EACnB,IAAI,CAAC,qBAAqB,EAC1B,2BAAgB,CAAC,aAAa,CAAC;gBAC9B,QAAQ,EAAE,IAAI,CAAC,aAAa;aAC5B,CAAC,CACF,CAAC;QACH,CAAC,CAAC;QAKD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QAExB,sEAAsE;QACtE,UAAU,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,KAA0B;QACrC,+BAA+B;QAC/B,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC;YACJ,MAAM,QAAQ,GAA+B;gBAC5C,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACrB,CAAC;YAEF,0EAA0E;YAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAErC,0GAA0G;YAC1G,IAAA,+BAAoB,EACnB,SAAS,EACT,yBAAc,CAAC,aAAa,CAAC;gBAC5B,KAAK,EAAE,QAAQ;aACf,CAAC,CACF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,uFAAuF;YACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,UAAiC;IACrE,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC;AAFD,oDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\n\nimport type { ITimestampedTelemetryEvent } from \"./TelemetryMetadata.js\";\nimport {\n\tGetTelemetryHistory,\n\ttype IDevtoolsMessage,\n\ttype InboundHandlers,\n\ttype MessageLoggingOptions,\n\tTelemetryEvent,\n\tTelemetryHistory,\n\thandleIncomingWindowMessage,\n\tpostMessagesToWindow,\n} from \"./messaging/index.js\";\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * An `IDevtoolsLogger` can be created via {@link createDevtoolsLogger} - this logger may then be provided to the Fluid\n * runtime to ensure telemetry messages are flowing to it.\n * If you wish to enable telemetry functionality in the devtools, you **must** pass this same logger back when\n * initializing the Devtools.\n *\n * @sealed\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IDevtoolsLogger extends ITelemetryBaseLogger {}\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks\n *\n * This logger optionally wraps a provided base logger, and forwards all events to that logger (in addition to posting\n * data to the window).\n *\n * **Messages it listens for:**\n *\n * - {@link GetTelemetryHistory.Message}: When received, the logger will broadcast {@link TelemetryHistory.Message}.\n *\n * TODO: Document others as they are added.\n *\n * **Messages it posts:**\n *\n * - {@link TelemetryHistory.Message}: This is posted when requested (via {@link GetTelemetryHistory.Message}).\n * - {@link TelemetryEvent.Message}: This is posted any time a telemetry event is logged.\n *\n * TODO: Document others as they are added.\n *\n * @sealed\n */\nclass DevtoolsLogger implements IDevtoolsLogger {\n\t/**\n\t * Base telemetry logger provided by the consumer.\n\t * All messages sent to the Devtools logger will be forwarded to this.\n\t */\n\tprivate readonly baseLogger: ITelemetryBaseLogger | undefined;\n\n\t/**\n\t * Accumulated data for Telemetry logs.\n\t */\n\tprivate readonly _telemetryLog: ITimestampedTelemetryEvent[];\n\n\t/**\n\t * Message logging options used by the logger.\n\t */\n\tprivate readonly messageLoggingOptions: MessageLoggingOptions = {\n\t\tcontext: `FluidDevtoolsLogger`,\n\t};\n\n\t/**\n\t * Handlers for inbound messages related to the logger.\n\t */\n\tprivate readonly inboundMessageHandlers: InboundHandlers = {\n\t\t[GetTelemetryHistory.MessageType]: async (untypedMessage) => {\n\t\t\tthis.postLogHistory();\n\t\t\treturn true;\n\t\t},\n\t};\n\n\t/**\n\t * Event handler for messages coming from the window (globalThis).\n\t */\n\tprivate readonly windowMessageHandler = (\n\t\tevent: MessageEvent<Partial<IDevtoolsMessage>>,\n\t): void => {\n\t\thandleIncomingWindowMessage(\n\t\t\tevent,\n\t\t\tthis.inboundMessageHandlers,\n\t\t\tthis.messageLoggingOptions,\n\t\t);\n\t};\n\n\t/**\n\t * Posts a {@link TelemetryHistory.Message} to the window (globalThis) containing the complete history of\n\t * telemetry events.\n\t */\n\tprivate readonly postLogHistory = (): void => {\n\t\tpostMessagesToWindow(\n\t\t\tthis.messageLoggingOptions,\n\t\t\tTelemetryHistory.createMessage({\n\t\t\t\tcontents: this._telemetryLog,\n\t\t\t}),\n\t\t);\n\t};\n\n\t// #endregion\n\n\tpublic constructor(baseLogger?: ITelemetryBaseLogger) {\n\t\tthis.baseLogger = baseLogger;\n\n\t\tthis._telemetryLog = [];\n\n\t\t// Register listener for inbound messages from the window (globalThis)\n\t\tglobalThis.addEventListener?.(\"message\", this.windowMessageHandler);\n\t}\n\n\t/**\n\t * Post a {@link TelemetryEvent.Message} to the window (globalThis) for the provided telemetry event.\n\t *\n\t * @param event - The telemetry event to send.\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// Forward event to base logger\n\t\tthis.baseLogger?.send(event);\n\n\t\ttry {\n\t\t\tconst newEvent: ITimestampedTelemetryEvent = {\n\t\t\t\tlogContent: event,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\n\t\t\t// insert log into the beginning of the array to show the latest log first\n\t\t\tthis._telemetryLog.unshift(newEvent);\n\n\t\t\t// set log option to be undefined to avoid sending the log message to window console; these were too noisy\n\t\t\tpostMessagesToWindow(\n\t\t\t\tundefined,\n\t\t\t\tTelemetryEvent.createMessage({\n\t\t\t\t\tevent: newEvent,\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\t// Eat the error to ensure that Devtools logic doesn't crash the consuming application.\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n}\n\n/**\n * Creates a new {@link IDevtoolsLogger} by wrapping the provided (optional) base logger.\n *\n * @beta\n */\nexport function createDevtoolsLogger(baseLogger?: ITelemetryBaseLogger): IDevtoolsLogger {\n\treturn new DevtoolsLogger(baseLogger);\n}\n"]}
1
+ {"version":3,"file":"Devtool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AE,IAAI,CAAC,GAAG,EAAE;aACrB,CAAC;YAEF,0EAA0E;YAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAErC,0GAA0G;YAC1G,IAAA,+BAAoB,EACnB,SAAS,EACT,yBAAc,CAAC,aAAa,CAAC;gBAC5B,KAAK,EAAE,QAAQ;aACf,CAAC,CACF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,uFAAuF;YACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,UAAiC;IACrE,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC;AAFD,oDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\n\nimport type { ITimestampedTelemetryEvent } from \"./TelemetryMetadata.js\";\nimport {\n\tGetTelemetryHistory,\n\ttype IDevtoolsMessage,\n\ttype InboundHandlers,\n\ttype MessageLoggingOptions,\n\tTelemetryEvent,\n\tTelemetryHistory,\n\thandleIncomingWindowMessage,\n\tpostMessagesToWindow,\n} from \"./messaging/index.js\";\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * An `IDevtoolsLogger` can be created via {@link createDevtoolsLogger} - this logger may then be provided to the Fluid\n * runtime to ensure telemetry messages are flowing to it.\n * If you wish to enable telemetry functionality in the devtools, you **must** pass this same logger back when\n * initializing the Devtools.\n *\n * @sealed\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface\nexport interface IDevtoolsLogger extends ITelemetryBaseLogger {}\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks\n *\n * This logger optionally wraps a provided base logger, and forwards all events to that logger (in addition to posting\n * data to the window).\n *\n * **Messages it listens for:**\n *\n * - {@link GetTelemetryHistory.Message}: When received, the logger will broadcast {@link TelemetryHistory.Message}.\n *\n * TODO: Document others as they are added.\n *\n * **Messages it posts:**\n *\n * - {@link TelemetryHistory.Message}: This is posted when requested (via {@link GetTelemetryHistory.Message}).\n * - {@link TelemetryEvent.Message}: This is posted any time a telemetry event is logged.\n *\n * TODO: Document others as they are added.\n *\n * @sealed\n */\nclass DevtoolsLogger implements IDevtoolsLogger {\n\t/**\n\t * Base telemetry logger provided by the consumer.\n\t * All messages sent to the Devtools logger will be forwarded to this.\n\t */\n\tprivate readonly baseLogger: ITelemetryBaseLogger | undefined;\n\n\t/**\n\t * Accumulated data for Telemetry logs.\n\t */\n\tprivate readonly _telemetryLog: ITimestampedTelemetryEvent[];\n\n\t/**\n\t * Message logging options used by the logger.\n\t */\n\tprivate readonly messageLoggingOptions: MessageLoggingOptions = {\n\t\tcontext: `FluidDevtoolsLogger`,\n\t};\n\n\t/**\n\t * Handlers for inbound messages related to the logger.\n\t */\n\tprivate readonly inboundMessageHandlers: InboundHandlers = {\n\t\t[GetTelemetryHistory.MessageType]: async (untypedMessage) => {\n\t\t\tthis.postLogHistory();\n\t\t\treturn true;\n\t\t},\n\t};\n\n\t/**\n\t * Event handler for messages coming from the window (globalThis).\n\t */\n\tprivate readonly windowMessageHandler = (\n\t\tevent: MessageEvent<Partial<IDevtoolsMessage>>,\n\t): void => {\n\t\thandleIncomingWindowMessage(\n\t\t\tevent,\n\t\t\tthis.inboundMessageHandlers,\n\t\t\tthis.messageLoggingOptions,\n\t\t);\n\t};\n\n\t/**\n\t * Posts a {@link TelemetryHistory.Message} to the window (globalThis) containing the complete history of\n\t * telemetry events.\n\t */\n\tprivate readonly postLogHistory = (): void => {\n\t\tpostMessagesToWindow(\n\t\t\tthis.messageLoggingOptions,\n\t\t\tTelemetryHistory.createMessage({\n\t\t\t\tcontents: this._telemetryLog,\n\t\t\t}),\n\t\t);\n\t};\n\n\t// #endregion\n\n\tpublic constructor(baseLogger?: ITelemetryBaseLogger) {\n\t\tthis.baseLogger = baseLogger;\n\n\t\tthis._telemetryLog = [];\n\n\t\t// Register listener for inbound messages from the window (globalThis)\n\t\tglobalThis.addEventListener?.(\"message\", this.windowMessageHandler);\n\t}\n\n\t/**\n\t * Post a {@link TelemetryEvent.Message} to the window (globalThis) for the provided telemetry event.\n\t *\n\t * @param event - The telemetry event to send.\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// Forward event to base logger\n\t\tthis.baseLogger?.send(event);\n\n\t\ttry {\n\t\t\tconst newEvent: ITimestampedTelemetryEvent = {\n\t\t\t\tlogContent: event,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\n\t\t\t// insert log into the beginning of the array to show the latest log first\n\t\t\tthis._telemetryLog.unshift(newEvent);\n\n\t\t\t// set log option to be undefined to avoid sending the log message to window console; these were too noisy\n\t\t\tpostMessagesToWindow(\n\t\t\t\tundefined,\n\t\t\t\tTelemetryEvent.createMessage({\n\t\t\t\t\tevent: newEvent,\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\t// Eat the error to ensure that Devtools logic doesn't crash the consuming application.\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n}\n\n/**\n * Creates a new {@link IDevtoolsLogger} by wrapping the provided (optional) base logger.\n *\n * @beta\n */\nexport function createDevtoolsLogger(baseLogger?: ITelemetryBaseLogger): IDevtoolsLogger {\n\treturn new DevtoolsLogger(baseLogger);\n}\n"]}
@@ -13,7 +13,7 @@ export declare function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeK
13
13
  /**
14
14
  * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.
15
15
  * @param tree - the visual representation of the SharedTree.
16
- * @returns - the visual representation of type {@link VisualChildNode}
16
+ * @returns the visual representation of type {@link VisualChildNode}
17
17
  */
18
18
  export declare function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode;
19
19
  /**
@@ -30,7 +30,7 @@ exports.determineNodeKind = determineNodeKind;
30
30
  /**
31
31
  * Returns allowed types of the non-leaf nodes in the tree.
32
32
  * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.
33
- * @returns - a VisualChildNode with the allowed type.
33
+ * @returns a VisualChildNode with the allowed type.
34
34
  */
35
35
  function createAllowedTypesVisualTree(allowedTypes) {
36
36
  if (typeof allowedTypes === "string") {
@@ -78,7 +78,7 @@ function createToolTipContents(schema) {
78
78
  /**
79
79
  * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.
80
80
  * @param tree - the visual representation of the SharedTree.
81
- * @returns - the visual representation of type {@link VisualChildNode}
81
+ * @returns the visual representation of type {@link VisualChildNode}
82
82
  */
83
83
  function toVisualTree(tree) {
84
84
  if (tree.kind === VisualSharedTreeTypes_js_1.VisualSharedTreeNodeKind.LeafNode) {
@@ -1 +1 @@
1
- {"version":3,"file":"SharedTreeVisualizer.js","sourceRoot":"","sources":["../../src/data-visualization/SharedTreeVisualizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAiD;AASjD,4DAA8E;AAI9E,yEAAsE;AACtE,mDAOyB;AAEzB;;GAEG;AACH,SAAgB,iBAAiB,CAAC,QAAwB;IACzD,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,8BAAc,CAAC,QAAQ,CAAC;QAC7B,KAAK,8BAAc,CAAC,eAAe,CAAC,CAAC,CAAC;YACrC,OAAO,8BAAc,CAAC,aAAa,CAAC;QACrC,CAAC;QACD,KAAK,8BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;YAC/B,OAAO,8BAAc,CAAC,cAAc,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,8BAAc,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AAC;gBACzD,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE;aAClC;YACD,KAAK,EAAE,MAAM,kBAAkB,CAAC,IAAI,CAAC;YACrC,IAAI,EAAE,mDAAwB,CAAC,QAAQ;SACvC;QACF,CAAC,CAAC,qBAAqB,CACrB,IAAI,EACJ,eAAe,EACf,EAAE,YAAY,EAAE,UAAU,EAAE,EAC5B,kBAAkB,CAClB,CAAC;AACL,CAAC;AAtBD,kEAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FieldKind } from \"@fluidframework/tree\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tVerboseTree,\n\tVerboseTreeNode,\n} from \"@fluidframework/tree/internal\";\nimport { NodeKind, SchemaFactory, Tree } from \"@fluidframework/tree/internal\";\n\nimport type { VisualizeChildData } from \"./DataVisualization.js\";\nimport type { VisualSharedTreeNode, SharedTreeSchemaNode } from \"./VisualSharedTreeTypes.js\";\nimport { VisualSharedTreeNodeKind } from \"./VisualSharedTreeTypes.js\";\nimport {\n\ttype VisualChildNode,\n\tVisualNodeKind,\n\ttype VisualValueNode,\n\ttype VisualTreeNode,\n\ttype FluidHandleNode,\n\ttype UnknownObjectNode,\n} from \"./VisualTree.js\";\n\n/**\n * Returns VisualNodeKind that is compatible to {@link FluidObjectNode} based on the `visualTree`'s node kind.\n */\nexport function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeKind {\n\tswitch (nodeKind) {\n\t\tcase VisualNodeKind.TreeNode:\n\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\treturn VisualNodeKind.FluidTreeNode;\n\t\t}\n\t\tcase VisualNodeKind.ValueNode: {\n\t\t\treturn VisualNodeKind.FluidValueNode;\n\t\t}\n\t\tdefault: {\n\t\t\treturn VisualNodeKind.FluidUnknownObjectNode;\n\t\t}\n\t}\n}\n\n/**\n * Returns allowed types of the non-leaf nodes in the tree.\n * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.\n * @returns - a VisualChildNode with the allowed type.\n */\nfunction createAllowedTypesVisualTree(\n\tallowedTypes: string | Record<string, string>,\n): VisualChildNode {\n\tif (typeof allowedTypes === \"string\") {\n\t\treturn {\n\t\t\tvalue: allowedTypes,\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t};\n\t}\n\n\tconst result: Record<string, VisualValueNode> = {};\n\tfor (const [allowedTypeKey, allowedType] of Object.entries(allowedTypes)) {\n\t\tresult[allowedTypeKey] = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: allowedType,\n\t\t};\n\t}\n\n\treturn {\n\t\tchildren: result,\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t};\n}\n\n/**\n * Creates a visual representation of the schema of the tree in {@link VisualTreeNode} format.\n */\nfunction createToolTipContents(schema: SharedTreeSchemaNode): VisualTreeNode {\n\tconst children: Record<string, VisualChildNode> = {\n\t\tname: {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.schemaName,\n\t\t},\n\t};\n\tif (schema.allowedTypes !== undefined) {\n\t\tchildren.allowedTypes = createAllowedTypesVisualTree(schema.allowedTypes);\n\t}\n\tif (schema.isRequired !== undefined) {\n\t\tchildren.isRequired = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.isRequired,\n\t\t};\n\t}\n\treturn {\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\tchildren,\n\t};\n}\n\n/**\n * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.\n * @param tree - the visual representation of the SharedTree.\n * @returns - the visual representation of type {@link VisualChildNode}\n */\nexport function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode {\n\tif (tree.kind === VisualSharedTreeNodeKind.LeafNode) {\n\t\tswitch (tree.value.nodeKind) {\n\t\t\tcase VisualNodeKind.ValueNode: {\n\t\t\t\tconst result: VisualValueNode = {\n\t\t\t\t\tvalue: tree.value.value,\n\t\t\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\t\tconst result: FluidHandleNode = {\n\t\t\t\t\tfluidObjectId: tree.value.fluidObjectId,\n\t\t\t\t\tnodeKind: VisualNodeKind.FluidHandleNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconsole.error(`Unknown node kind: ${tree.value.nodeKind}`);\n\t\t\t\tconst result: UnknownObjectNode = {\n\t\t\t\t\tnodeKind: VisualNodeKind.UnknownObjectNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst children: Record<string, VisualChildNode> = {};\n\n\t\tfor (const [key, value] of Object.entries(tree.fields)) {\n\t\t\tconst child = toVisualTree(value);\n\t\t\tchildren[key] = child;\n\t\t}\n\n\t\treturn {\n\t\t\tchildren,\n\t\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\t\ttooltipContents: {\n\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Concatenate allowed types for `ObjectNodeStoredSchema` and `MapNodeStoredSchema`.\n */\nexport function concatenateTypes(fieldTypes: ReadonlySet<string>): string {\n\treturn [...fieldTypes].join(\" | \");\n}\n\n/**\n * Properties that describe schema constraints for a field in the tree\n */\ninterface FieldSchemaProperties {\n\tallowedTypes: ReadonlySet<string> | undefined;\n\n\t/**\n\t * Whether the field is required (true) or optional (false).\n\t *\n\t * `undefined` indicates that the field is implicitly required.\n\t * In this case, no requirement information will be displayed by the devtools.\n\t */\n\tisRequired: boolean | undefined;\n}\n\n/**\n * Processes and visualizes the fields of a verbose tree node.\n *\n * @param treeFields - The fields of the tree node to visualize. Can be either an array of VerboseTree (for array nodes) or a Record of field names to VerboseTree (for object/map nodes).\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Record mapping field names to their schema properties, including allowed types and whether they are required.\n * @param visualizeChildData - Callback function to visualize child node data.\n *\n * @returns A record mapping field names/indices to their visual tree representations.\n */\nasync function visualizeVerboseNodeFields(\n\ttreeFields: readonly VerboseTree[] | Record<string, VerboseTree>,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\tfieldSchemaProperties: Record<string, FieldSchemaProperties>,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<Record<string, VisualSharedTreeNode>> {\n\tconst fields: Record<string | number, VisualSharedTreeNode> = {};\n\n\tfor (const [fieldKey, childField] of Object.entries(treeFields)) {\n\t\tfields[fieldKey] = await visualizeSharedTreeBySchema(\n\t\t\tchildField,\n\t\t\ttreeDefinitions,\n\t\t\t{\n\t\t\t\tallowedTypes: fieldSchemaProperties[fieldKey]?.allowedTypes,\n\t\t\t\tisRequired: fieldSchemaProperties[fieldKey]?.isRequired,\n\t\t\t},\n\t\t\tvisualizeChildData,\n\t\t);\n\t}\n\n\treturn fields;\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ObjectNodeStoredSchema}.\n */\nasync function visualizeObjectNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleObjectNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst objectNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [fieldKey, treeFieldSimpleSchema] of schema.fields) {\n\t\tobjectNodeSchemaProperties[fieldKey] = {\n\t\t\tallowedTypes: treeFieldSimpleSchema.allowedTypesIdentifiers,\n\t\t\tisRequired: treeFieldSimpleSchema.kind === FieldKind.Required ? true : false,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tobjectNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link MapNodeStoredSchema}.\n */\nasync function visualizeMapNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleMapNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst mapNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const key of Object.keys(tree.fields)) {\n\t\tmapNodeSchemaProperties[key] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Map values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tmapNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ArrayNodeStoredSchema}.\n */\nasync function visualizeArrayNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleArrayNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst children = tree.fields;\n\tif (!Array.isArray(children)) {\n\t\tthrow new TypeError(\"Invalid array\");\n\t}\n\n\tconst arrayNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [i] of children.entries()) {\n\t\tarrayNodeSchemaProperties[i] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Array values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tarrayNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Creates the visual representation of non-leaf SharedTree nodes.\n *\n * @remarks\n * Processes internal tree nodes based on their schema type (e.g., ObjectNodeStoredSchema, MapNodeStoredSchema, ArrayNodeStoredSchema),\n * producing the visual representation for each type.\n *\n * @see {@link https://fluidframework.com/docs/data-structures/tree/} for more information on the SharedTree schema.\n *\n * @remarks\n */\nasync function visualizeNodeBySchema(\n\ttree: VerboseTreeNode,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst schema = treeDefinitions.get(tree.type);\n\n\tif (schema === undefined) {\n\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t}\n\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst objectVisualized = visualizeObjectNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn objectVisualized;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst mapVisualized = visualizeMapNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn mapVisualized;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn visualizeArrayNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t\t}\n\t}\n}\n\n/**\n * Creates a visual representation of a SharedTree based on its schema.\n * @param tree - The {@link VerboseTree} to visualize\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition\n * describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Properties describing schema constraints for this field:\n * - `allowedTypes`: Set of type names that are valid for this specific node position in the tree.\n * This is a subset of the types defined in treeDefinitions.\n * - `isRequired`: Whether this field is required in its parent object schema.\n * Only meaningful for direct children of object nodes.\n * Undefined for array/map elements since they are always required within their parent.\n * @param visualizeChildData - Callback function to visualize child node data\n * @returns A visual representation of the tree that includes schema information and node values\n *\n * @remarks\n * This function handles both leaf nodes (primitive values, handles) and internal nodes (objects, maps, arrays).\n * For leaf nodes, it creates a visual representation with the node's schema and value.\n * For internal nodes, it recursively processes the node's fields using {@link visualizeNodeBySchema}.\n */\nexport async function visualizeSharedTreeBySchema(\n\ttree: VerboseTree,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\treturn Tree.is(tree, SchemaFactory.leaves)\n\t\t? {\n\t\t\t\tschema: {\n\t\t\t\t\tschemaName: Tree.schema(tree).identifier,\n\t\t\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\t\t\tisRequired: isRequired?.toString(),\n\t\t\t\t},\n\t\t\t\tvalue: await visualizeChildData(tree),\n\t\t\t\tkind: VisualSharedTreeNodeKind.LeafNode,\n\t\t\t}\n\t\t: visualizeNodeBySchema(\n\t\t\t\ttree,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n}\n"]}
1
+ {"version":3,"file":"SharedTreeVisualizer.js","sourceRoot":"","sources":["../../src/data-visualization/SharedTreeVisualizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAAiD;AASjD,4DAA8E;AAI9E,yEAAsE;AACtE,mDAOyB;AAEzB;;GAEG;AACH,SAAgB,iBAAiB,CAAC,QAAwB;IACzD,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,8BAAc,CAAC,QAAQ,CAAC;QAC7B,KAAK,8BAAc,CAAC,eAAe,CAAC,CAAC,CAAC;YACrC,OAAO,8BAAc,CAAC,aAAa,CAAC;QACrC,CAAC;QACD,KAAK,8BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;YAC/B,OAAO,8BAAc,CAAC,cAAc,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,8BAAc,CAAC,sBAAsB,CAAC;QAC9C,CAAC;IACF,CAAC;AACF,CAAC;AAbD,8CAa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EAAE,MAAM,kBAAkB,CAAC,IAAI,CAAC;YACrC,IAAI,EAAE,mDAAwB,CAAC,QAAQ;SACvC;QACF,CAAC,CAAC,qBAAqB,CACrB,IAAI,EACJ,eAAe,EACf,EAAE,YAAY,EAAE,UAAU,EAAE,EAC5B,kBAAkB,CAClB,CAAC;AACL,CAAC;AAtBD,kEAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FieldKind } from \"@fluidframework/tree\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tVerboseTree,\n\tVerboseTreeNode,\n} from \"@fluidframework/tree/internal\";\nimport { NodeKind, SchemaFactory, Tree } from \"@fluidframework/tree/internal\";\n\nimport type { VisualizeChildData } from \"./DataVisualization.js\";\nimport type { VisualSharedTreeNode, SharedTreeSchemaNode } from \"./VisualSharedTreeTypes.js\";\nimport { VisualSharedTreeNodeKind } from \"./VisualSharedTreeTypes.js\";\nimport {\n\ttype VisualChildNode,\n\tVisualNodeKind,\n\ttype VisualValueNode,\n\ttype VisualTreeNode,\n\ttype FluidHandleNode,\n\ttype UnknownObjectNode,\n} from \"./VisualTree.js\";\n\n/**\n * Returns VisualNodeKind that is compatible to {@link FluidObjectNode} based on the `visualTree`'s node kind.\n */\nexport function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeKind {\n\tswitch (nodeKind) {\n\t\tcase VisualNodeKind.TreeNode:\n\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\treturn VisualNodeKind.FluidTreeNode;\n\t\t}\n\t\tcase VisualNodeKind.ValueNode: {\n\t\t\treturn VisualNodeKind.FluidValueNode;\n\t\t}\n\t\tdefault: {\n\t\t\treturn VisualNodeKind.FluidUnknownObjectNode;\n\t\t}\n\t}\n}\n\n/**\n * Returns allowed types of the non-leaf nodes in the tree.\n * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.\n * @returns a VisualChildNode with the allowed type.\n */\nfunction createAllowedTypesVisualTree(\n\tallowedTypes: string | Record<string, string>,\n): VisualChildNode {\n\tif (typeof allowedTypes === \"string\") {\n\t\treturn {\n\t\t\tvalue: allowedTypes,\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t};\n\t}\n\n\tconst result: Record<string, VisualValueNode> = {};\n\tfor (const [allowedTypeKey, allowedType] of Object.entries(allowedTypes)) {\n\t\tresult[allowedTypeKey] = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: allowedType,\n\t\t};\n\t}\n\n\treturn {\n\t\tchildren: result,\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t};\n}\n\n/**\n * Creates a visual representation of the schema of the tree in {@link VisualTreeNode} format.\n */\nfunction createToolTipContents(schema: SharedTreeSchemaNode): VisualTreeNode {\n\tconst children: Record<string, VisualChildNode> = {\n\t\tname: {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.schemaName,\n\t\t},\n\t};\n\tif (schema.allowedTypes !== undefined) {\n\t\tchildren.allowedTypes = createAllowedTypesVisualTree(schema.allowedTypes);\n\t}\n\tif (schema.isRequired !== undefined) {\n\t\tchildren.isRequired = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.isRequired,\n\t\t};\n\t}\n\treturn {\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\tchildren,\n\t};\n}\n\n/**\n * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.\n * @param tree - the visual representation of the SharedTree.\n * @returns the visual representation of type {@link VisualChildNode}\n */\nexport function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode {\n\tif (tree.kind === VisualSharedTreeNodeKind.LeafNode) {\n\t\tswitch (tree.value.nodeKind) {\n\t\t\tcase VisualNodeKind.ValueNode: {\n\t\t\t\tconst result: VisualValueNode = {\n\t\t\t\t\tvalue: tree.value.value,\n\t\t\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\t\tconst result: FluidHandleNode = {\n\t\t\t\t\tfluidObjectId: tree.value.fluidObjectId,\n\t\t\t\t\tnodeKind: VisualNodeKind.FluidHandleNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconsole.error(`Unknown node kind: ${tree.value.nodeKind}`);\n\t\t\t\tconst result: UnknownObjectNode = {\n\t\t\t\t\tnodeKind: VisualNodeKind.UnknownObjectNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst children: Record<string, VisualChildNode> = {};\n\n\t\tfor (const [key, value] of Object.entries(tree.fields)) {\n\t\t\tconst child = toVisualTree(value);\n\t\t\tchildren[key] = child;\n\t\t}\n\n\t\treturn {\n\t\t\tchildren,\n\t\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\t\ttooltipContents: {\n\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Concatenate allowed types for `ObjectNodeStoredSchema` and `MapNodeStoredSchema`.\n */\nexport function concatenateTypes(fieldTypes: ReadonlySet<string>): string {\n\treturn [...fieldTypes].join(\" | \");\n}\n\n/**\n * Properties that describe schema constraints for a field in the tree\n */\ninterface FieldSchemaProperties {\n\tallowedTypes: ReadonlySet<string> | undefined;\n\n\t/**\n\t * Whether the field is required (true) or optional (false).\n\t *\n\t * `undefined` indicates that the field is implicitly required.\n\t * In this case, no requirement information will be displayed by the devtools.\n\t */\n\tisRequired: boolean | undefined;\n}\n\n/**\n * Processes and visualizes the fields of a verbose tree node.\n *\n * @param treeFields - The fields of the tree node to visualize. Can be either an array of VerboseTree (for array nodes) or a Record of field names to VerboseTree (for object/map nodes).\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Record mapping field names to their schema properties, including allowed types and whether they are required.\n * @param visualizeChildData - Callback function to visualize child node data.\n *\n * @returns A record mapping field names/indices to their visual tree representations.\n */\nasync function visualizeVerboseNodeFields(\n\ttreeFields: readonly VerboseTree[] | Record<string, VerboseTree>,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\tfieldSchemaProperties: Record<string, FieldSchemaProperties>,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<Record<string, VisualSharedTreeNode>> {\n\tconst fields: Record<string | number, VisualSharedTreeNode> = {};\n\n\tfor (const [fieldKey, childField] of Object.entries(treeFields)) {\n\t\tfields[fieldKey] = await visualizeSharedTreeBySchema(\n\t\t\tchildField,\n\t\t\ttreeDefinitions,\n\t\t\t{\n\t\t\t\tallowedTypes: fieldSchemaProperties[fieldKey]?.allowedTypes,\n\t\t\t\tisRequired: fieldSchemaProperties[fieldKey]?.isRequired,\n\t\t\t},\n\t\t\tvisualizeChildData,\n\t\t);\n\t}\n\n\treturn fields;\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ObjectNodeStoredSchema}.\n */\nasync function visualizeObjectNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleObjectNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst objectNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [fieldKey, treeFieldSimpleSchema] of schema.fields) {\n\t\tobjectNodeSchemaProperties[fieldKey] = {\n\t\t\tallowedTypes: treeFieldSimpleSchema.allowedTypesIdentifiers,\n\t\t\tisRequired: treeFieldSimpleSchema.kind === FieldKind.Required ? true : false,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tobjectNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link MapNodeStoredSchema}.\n */\nasync function visualizeMapNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleMapNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst mapNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const key of Object.keys(tree.fields)) {\n\t\tmapNodeSchemaProperties[key] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Map values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tmapNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ArrayNodeStoredSchema}.\n */\nasync function visualizeArrayNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleArrayNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst children = tree.fields;\n\tif (!Array.isArray(children)) {\n\t\tthrow new TypeError(\"Invalid array\");\n\t}\n\n\tconst arrayNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [i] of children.entries()) {\n\t\tarrayNodeSchemaProperties[i] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Array values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tarrayNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Creates the visual representation of non-leaf SharedTree nodes.\n *\n * @remarks\n * Processes internal tree nodes based on their schema type (e.g., ObjectNodeStoredSchema, MapNodeStoredSchema, ArrayNodeStoredSchema),\n * producing the visual representation for each type.\n *\n * @see {@link https://fluidframework.com/docs/data-structures/tree/} for more information on the SharedTree schema.\n *\n * @remarks\n */\nasync function visualizeNodeBySchema(\n\ttree: VerboseTreeNode,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst schema = treeDefinitions.get(tree.type);\n\n\tif (schema === undefined) {\n\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t}\n\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst objectVisualized = visualizeObjectNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn objectVisualized;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst mapVisualized = visualizeMapNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn mapVisualized;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn visualizeArrayNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t\t}\n\t}\n}\n\n/**\n * Creates a visual representation of a SharedTree based on its schema.\n * @param tree - The {@link VerboseTree} to visualize\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition\n * describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Properties describing schema constraints for this field:\n * - `allowedTypes`: Set of type names that are valid for this specific node position in the tree.\n * This is a subset of the types defined in treeDefinitions.\n * - `isRequired`: Whether this field is required in its parent object schema.\n * Only meaningful for direct children of object nodes.\n * Undefined for array/map elements since they are always required within their parent.\n * @param visualizeChildData - Callback function to visualize child node data\n * @returns A visual representation of the tree that includes schema information and node values\n *\n * @remarks\n * This function handles both leaf nodes (primitive values, handles) and internal nodes (objects, maps, arrays).\n * For leaf nodes, it creates a visual representation with the node's schema and value.\n * For internal nodes, it recursively processes the node's fields using {@link visualizeNodeBySchema}.\n */\nexport async function visualizeSharedTreeBySchema(\n\ttree: VerboseTree,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\treturn Tree.is(tree, SchemaFactory.leaves)\n\t\t? {\n\t\t\t\tschema: {\n\t\t\t\t\tschemaName: Tree.schema(tree).identifier,\n\t\t\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\t\t\tisRequired: isRequired?.toString(),\n\t\t\t\t},\n\t\t\t\tvalue: await visualizeChildData(tree),\n\t\t\t\tkind: VisualSharedTreeNodeKind.LeafNode,\n\t\t\t}\n\t\t: visualizeNodeBySchema(\n\t\t\t\ttree,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/devtools-core";
8
- export declare const pkgVersion = "2.70.0-360753";
8
+ export declare const pkgVersion = "2.70.0-361248";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/devtools-core";
11
- exports.pkgVersion = "2.70.0-360753";
11
+ exports.pkgVersion = "2.70.0-361248";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/devtools-core\";\nexport const pkgVersion = \"2.70.0-360753\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/devtools-core\";\nexport const pkgVersion = \"2.70.0-361248\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DevtoolsLogger.js","sourceRoot":"","sources":["../src/DevtoolsLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,mBAAmB,EAInB,cAAc,EACd,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAkB9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,cAAc;IAuDnB,aAAa;IAEb,YAAmB,UAAiC;QA7CpD;;WAEG;QACc,0BAAqB,GAA0B;YAC/D,OAAO,EAAE,qBAAqB;SAC9B,CAAC;QAEF;;WAEG;QACc,2BAAsB,GAAoB;YAC1D,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;gBAC3D,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC;QAEF;;WAEG;QACc,yBAAoB,GAAG,CACvC,KAA8C,EACvC,EAAE;YACT,2BAA2B,CAC1B,KAAK,EACL,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACH,CAAC,CAAC;QAEF;;;WAGG;QACc,mBAAc,GAAG,GAAS,EAAE;YAC5C,oBAAoB,CACnB,IAAI,CAAC,qBAAqB,EAC1B,gBAAgB,CAAC,aAAa,CAAC;gBAC9B,QAAQ,EAAE,IAAI,CAAC,aAAa;aAC5B,CAAC,CACF,CAAC;QACH,CAAC,CAAC;QAKD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QAExB,sEAAsE;QACtE,UAAU,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,KAA0B;QACrC,+BAA+B;QAC/B,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC;YACJ,MAAM,QAAQ,GAA+B;gBAC5C,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACrB,CAAC;YAEF,0EAA0E;YAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAErC,0GAA0G;YAC1G,oBAAoB,CACnB,SAAS,EACT,cAAc,CAAC,aAAa,CAAC;gBAC5B,KAAK,EAAE,QAAQ;aACf,CAAC,CACF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,uFAAuF;YACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAiC;IACrE,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\n\nimport type { ITimestampedTelemetryEvent } from \"./TelemetryMetadata.js\";\nimport {\n\tGetTelemetryHistory,\n\ttype IDevtoolsMessage,\n\ttype InboundHandlers,\n\ttype MessageLoggingOptions,\n\tTelemetryEvent,\n\tTelemetryHistory,\n\thandleIncomingWindowMessage,\n\tpostMessagesToWindow,\n} from \"./messaging/index.js\";\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * An `IDevtoolsLogger` can be created via {@link createDevtoolsLogger} - this logger may then be provided to the Fluid\n * runtime to ensure telemetry messages are flowing to it.\n * If you wish to enable telemetry functionality in the devtools, you **must** pass this same logger back when\n * initializing the Devtools.\n *\n * @sealed\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IDevtoolsLogger extends ITelemetryBaseLogger {}\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks\n *\n * This logger optionally wraps a provided base logger, and forwards all events to that logger (in addition to posting\n * data to the window).\n *\n * **Messages it listens for:**\n *\n * - {@link GetTelemetryHistory.Message}: When received, the logger will broadcast {@link TelemetryHistory.Message}.\n *\n * TODO: Document others as they are added.\n *\n * **Messages it posts:**\n *\n * - {@link TelemetryHistory.Message}: This is posted when requested (via {@link GetTelemetryHistory.Message}).\n * - {@link TelemetryEvent.Message}: This is posted any time a telemetry event is logged.\n *\n * TODO: Document others as they are added.\n *\n * @sealed\n */\nclass DevtoolsLogger implements IDevtoolsLogger {\n\t/**\n\t * Base telemetry logger provided by the consumer.\n\t * All messages sent to the Devtools logger will be forwarded to this.\n\t */\n\tprivate readonly baseLogger: ITelemetryBaseLogger | undefined;\n\n\t/**\n\t * Accumulated data for Telemetry logs.\n\t */\n\tprivate readonly _telemetryLog: ITimestampedTelemetryEvent[];\n\n\t/**\n\t * Message logging options used by the logger.\n\t */\n\tprivate readonly messageLoggingOptions: MessageLoggingOptions = {\n\t\tcontext: `FluidDevtoolsLogger`,\n\t};\n\n\t/**\n\t * Handlers for inbound messages related to the logger.\n\t */\n\tprivate readonly inboundMessageHandlers: InboundHandlers = {\n\t\t[GetTelemetryHistory.MessageType]: async (untypedMessage) => {\n\t\t\tthis.postLogHistory();\n\t\t\treturn true;\n\t\t},\n\t};\n\n\t/**\n\t * Event handler for messages coming from the window (globalThis).\n\t */\n\tprivate readonly windowMessageHandler = (\n\t\tevent: MessageEvent<Partial<IDevtoolsMessage>>,\n\t): void => {\n\t\thandleIncomingWindowMessage(\n\t\t\tevent,\n\t\t\tthis.inboundMessageHandlers,\n\t\t\tthis.messageLoggingOptions,\n\t\t);\n\t};\n\n\t/**\n\t * Posts a {@link TelemetryHistory.Message} to the window (globalThis) containing the complete history of\n\t * telemetry events.\n\t */\n\tprivate readonly postLogHistory = (): void => {\n\t\tpostMessagesToWindow(\n\t\t\tthis.messageLoggingOptions,\n\t\t\tTelemetryHistory.createMessage({\n\t\t\t\tcontents: this._telemetryLog,\n\t\t\t}),\n\t\t);\n\t};\n\n\t// #endregion\n\n\tpublic constructor(baseLogger?: ITelemetryBaseLogger) {\n\t\tthis.baseLogger = baseLogger;\n\n\t\tthis._telemetryLog = [];\n\n\t\t// Register listener for inbound messages from the window (globalThis)\n\t\tglobalThis.addEventListener?.(\"message\", this.windowMessageHandler);\n\t}\n\n\t/**\n\t * Post a {@link TelemetryEvent.Message} to the window (globalThis) for the provided telemetry event.\n\t *\n\t * @param event - The telemetry event to send.\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// Forward event to base logger\n\t\tthis.baseLogger?.send(event);\n\n\t\ttry {\n\t\t\tconst newEvent: ITimestampedTelemetryEvent = {\n\t\t\t\tlogContent: event,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\n\t\t\t// insert log into the beginning of the array to show the latest log first\n\t\t\tthis._telemetryLog.unshift(newEvent);\n\n\t\t\t// set log option to be undefined to avoid sending the log message to window console; these were too noisy\n\t\t\tpostMessagesToWindow(\n\t\t\t\tundefined,\n\t\t\t\tTelemetryEvent.createMessage({\n\t\t\t\t\tevent: newEvent,\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\t// Eat the error to ensure that Devtools logic doesn't crash the consuming application.\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n}\n\n/**\n * Creates a new {@link IDevtoolsLogger} by wrapping the provided (optional) base logger.\n *\n * @beta\n */\nexport function createDevtoolsLogger(baseLogger?: ITelemetryBaseLogger): IDevtoolsLogger {\n\treturn new DevtoolsLogger(baseLogger);\n}\n"]}
1
+ {"version":3,"file":"DevtoolsLogger.js","sourceRoot":"","sources":["../src/DevtoolsLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,mBAAmB,EAInB,cAAc,EACd,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAkB9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,cAAc;IAuDnB,aAAa;IAEb,YAAmB,UAAiC;QA7CpD;;WAEG;QACc,0BAAqB,GAA0B;YAC/D,OAAO,EAAE,qBAAqB;SAC9B,CAAC;QAEF;;WAEG;QACc,2BAAsB,GAAoB;YAC1D,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;gBAC3D,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC;QAEF;;WAEG;QACc,yBAAoB,GAAG,CACvC,KAA8C,EACvC,EAAE;YACT,2BAA2B,CAC1B,KAAK,EACL,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACH,CAAC,CAAC;QAEF;;;WAGG;QACc,mBAAc,GAAG,GAAS,EAAE;YAC5C,oBAAoB,CACnB,IAAI,CAAC,qBAAqB,EAC1B,gBAAgB,CAAC,aAAa,CAAC;gBAC9B,QAAQ,EAAE,IAAI,CAAC,aAAa;aAC5B,CAAC,CACF,CAAC;QACH,CAAC,CAAC;QAKD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QAExB,sEAAsE;QACtE,UAAU,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,KAA0B;QACrC,+BAA+B;QAC/B,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC;YACJ,MAAM,QAAQ,GAA+B;gBAC5C,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACrB,CAAC;YAEF,0EAA0E;YAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAErC,0GAA0G;YAC1G,oBAAoB,CACnB,SAAS,EACT,cAAc,CAAC,aAAa,CAAC;gBAC5B,KAAK,EAAE,QAAQ;aACf,CAAC,CACF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,uFAAuF;YACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAiC;IACrE,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\n\nimport type { ITimestampedTelemetryEvent } from \"./TelemetryMetadata.js\";\nimport {\n\tGetTelemetryHistory,\n\ttype IDevtoolsMessage,\n\ttype InboundHandlers,\n\ttype MessageLoggingOptions,\n\tTelemetryEvent,\n\tTelemetryHistory,\n\thandleIncomingWindowMessage,\n\tpostMessagesToWindow,\n} from \"./messaging/index.js\";\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * An `IDevtoolsLogger` can be created via {@link createDevtoolsLogger} - this logger may then be provided to the Fluid\n * runtime to ensure telemetry messages are flowing to it.\n * If you wish to enable telemetry functionality in the devtools, you **must** pass this same logger back when\n * initializing the Devtools.\n *\n * @sealed\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface\nexport interface IDevtoolsLogger extends ITelemetryBaseLogger {}\n\n/**\n * Logger implementation that posts all telemetry events to the window (globalThis object).\n * This logger is intended to integrate with the Fluid DevTools browser extension.\n *\n * @remarks\n *\n * This logger optionally wraps a provided base logger, and forwards all events to that logger (in addition to posting\n * data to the window).\n *\n * **Messages it listens for:**\n *\n * - {@link GetTelemetryHistory.Message}: When received, the logger will broadcast {@link TelemetryHistory.Message}.\n *\n * TODO: Document others as they are added.\n *\n * **Messages it posts:**\n *\n * - {@link TelemetryHistory.Message}: This is posted when requested (via {@link GetTelemetryHistory.Message}).\n * - {@link TelemetryEvent.Message}: This is posted any time a telemetry event is logged.\n *\n * TODO: Document others as they are added.\n *\n * @sealed\n */\nclass DevtoolsLogger implements IDevtoolsLogger {\n\t/**\n\t * Base telemetry logger provided by the consumer.\n\t * All messages sent to the Devtools logger will be forwarded to this.\n\t */\n\tprivate readonly baseLogger: ITelemetryBaseLogger | undefined;\n\n\t/**\n\t * Accumulated data for Telemetry logs.\n\t */\n\tprivate readonly _telemetryLog: ITimestampedTelemetryEvent[];\n\n\t/**\n\t * Message logging options used by the logger.\n\t */\n\tprivate readonly messageLoggingOptions: MessageLoggingOptions = {\n\t\tcontext: `FluidDevtoolsLogger`,\n\t};\n\n\t/**\n\t * Handlers for inbound messages related to the logger.\n\t */\n\tprivate readonly inboundMessageHandlers: InboundHandlers = {\n\t\t[GetTelemetryHistory.MessageType]: async (untypedMessage) => {\n\t\t\tthis.postLogHistory();\n\t\t\treturn true;\n\t\t},\n\t};\n\n\t/**\n\t * Event handler for messages coming from the window (globalThis).\n\t */\n\tprivate readonly windowMessageHandler = (\n\t\tevent: MessageEvent<Partial<IDevtoolsMessage>>,\n\t): void => {\n\t\thandleIncomingWindowMessage(\n\t\t\tevent,\n\t\t\tthis.inboundMessageHandlers,\n\t\t\tthis.messageLoggingOptions,\n\t\t);\n\t};\n\n\t/**\n\t * Posts a {@link TelemetryHistory.Message} to the window (globalThis) containing the complete history of\n\t * telemetry events.\n\t */\n\tprivate readonly postLogHistory = (): void => {\n\t\tpostMessagesToWindow(\n\t\t\tthis.messageLoggingOptions,\n\t\t\tTelemetryHistory.createMessage({\n\t\t\t\tcontents: this._telemetryLog,\n\t\t\t}),\n\t\t);\n\t};\n\n\t// #endregion\n\n\tpublic constructor(baseLogger?: ITelemetryBaseLogger) {\n\t\tthis.baseLogger = baseLogger;\n\n\t\tthis._telemetryLog = [];\n\n\t\t// Register listener for inbound messages from the window (globalThis)\n\t\tglobalThis.addEventListener?.(\"message\", this.windowMessageHandler);\n\t}\n\n\t/**\n\t * Post a {@link TelemetryEvent.Message} to the window (globalThis) for the provided telemetry event.\n\t *\n\t * @param event - The telemetry event to send.\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// Forward event to base logger\n\t\tthis.baseLogger?.send(event);\n\n\t\ttry {\n\t\t\tconst newEvent: ITimestampedTelemetryEvent = {\n\t\t\t\tlogContent: event,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t};\n\n\t\t\t// insert log into the beginning of the array to show the latest log first\n\t\t\tthis._telemetryLog.unshift(newEvent);\n\n\t\t\t// set log option to be undefined to avoid sending the log message to window console; these were too noisy\n\t\t\tpostMessagesToWindow(\n\t\t\t\tundefined,\n\t\t\t\tTelemetryEvent.createMessage({\n\t\t\t\t\tevent: newEvent,\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\t// Eat the error to ensure that Devtools logic doesn't crash the consuming application.\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n}\n\n/**\n * Creates a new {@link IDevtoolsLogger} by wrapping the provided (optional) base logger.\n *\n * @beta\n */\nexport function createDevtoolsLogger(baseLogger?: ITelemetryBaseLogger): IDevtoolsLogger {\n\treturn new DevtoolsLogger(baseLogger);\n}\n"]}
@@ -13,7 +13,7 @@ export declare function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeK
13
13
  /**
14
14
  * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.
15
15
  * @param tree - the visual representation of the SharedTree.
16
- * @returns - the visual representation of type {@link VisualChildNode}
16
+ * @returns the visual representation of type {@link VisualChildNode}
17
17
  */
18
18
  export declare function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode;
19
19
  /**
@@ -26,7 +26,7 @@ export function determineNodeKind(nodeKind) {
26
26
  /**
27
27
  * Returns allowed types of the non-leaf nodes in the tree.
28
28
  * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.
29
- * @returns - a VisualChildNode with the allowed type.
29
+ * @returns a VisualChildNode with the allowed type.
30
30
  */
31
31
  function createAllowedTypesVisualTree(allowedTypes) {
32
32
  if (typeof allowedTypes === "string") {
@@ -74,7 +74,7 @@ function createToolTipContents(schema) {
74
74
  /**
75
75
  * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.
76
76
  * @param tree - the visual representation of the SharedTree.
77
- * @returns - the visual representation of type {@link VisualChildNode}
77
+ * @returns the visual representation of type {@link VisualChildNode}
78
78
  */
79
79
  export function toVisualTree(tree) {
80
80
  if (tree.kind === VisualSharedTreeNodeKind.LeafNode) {
@@ -1 +1 @@
1
- {"version":3,"file":"SharedTreeVisualizer.js","sourceRoot":"","sources":["../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B,CACxB,IAAI,EACJ,MAAM,EACN,eAAe,EACf,EAAE,YAAY,EAAE,UAAU,EAAE,EAC5B,kBAAkB,CAClB,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAChD,IAAiB,EACjB,eAAsD,EACtD,EAAE,YAAY,EAAE,UAAU,EAAyB,EACnD,kBAAsC;IAEtC,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;QACzC,CAAC,CAAC;YACA,MAAM,EAAE;gBACP,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU;gBACxC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI,GAAG,EAAE,CAAC;gBACzD,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE;aAClC;YACD,KAAK,EAAE,MAAM,kBAAkB,CAAC,IAAI,CAAC;YACrC,IAAI,EAAE,wBAAwB,CAAC,QAAQ;SACvC;QACF,CAAC,CAAC,qBAAqB,CACrB,IAAI,EACJ,eAAe,EACf,EAAE,YAAY,EAAE,UAAU,EAAE,EAC5B,kBAAkB,CAClB,CAAC;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FieldKind } from \"@fluidframework/tree\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tVerboseTree,\n\tVerboseTreeNode,\n} from \"@fluidframework/tree/internal\";\nimport { NodeKind, SchemaFactory, Tree } from \"@fluidframework/tree/internal\";\n\nimport type { VisualizeChildData } from \"./DataVisualization.js\";\nimport type { VisualSharedTreeNode, SharedTreeSchemaNode } from \"./VisualSharedTreeTypes.js\";\nimport { VisualSharedTreeNodeKind } from \"./VisualSharedTreeTypes.js\";\nimport {\n\ttype VisualChildNode,\n\tVisualNodeKind,\n\ttype VisualValueNode,\n\ttype VisualTreeNode,\n\ttype FluidHandleNode,\n\ttype UnknownObjectNode,\n} from \"./VisualTree.js\";\n\n/**\n * Returns VisualNodeKind that is compatible to {@link FluidObjectNode} based on the `visualTree`'s node kind.\n */\nexport function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeKind {\n\tswitch (nodeKind) {\n\t\tcase VisualNodeKind.TreeNode:\n\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\treturn VisualNodeKind.FluidTreeNode;\n\t\t}\n\t\tcase VisualNodeKind.ValueNode: {\n\t\t\treturn VisualNodeKind.FluidValueNode;\n\t\t}\n\t\tdefault: {\n\t\t\treturn VisualNodeKind.FluidUnknownObjectNode;\n\t\t}\n\t}\n}\n\n/**\n * Returns allowed types of the non-leaf nodes in the tree.\n * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.\n * @returns - a VisualChildNode with the allowed type.\n */\nfunction createAllowedTypesVisualTree(\n\tallowedTypes: string | Record<string, string>,\n): VisualChildNode {\n\tif (typeof allowedTypes === \"string\") {\n\t\treturn {\n\t\t\tvalue: allowedTypes,\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t};\n\t}\n\n\tconst result: Record<string, VisualValueNode> = {};\n\tfor (const [allowedTypeKey, allowedType] of Object.entries(allowedTypes)) {\n\t\tresult[allowedTypeKey] = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: allowedType,\n\t\t};\n\t}\n\n\treturn {\n\t\tchildren: result,\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t};\n}\n\n/**\n * Creates a visual representation of the schema of the tree in {@link VisualTreeNode} format.\n */\nfunction createToolTipContents(schema: SharedTreeSchemaNode): VisualTreeNode {\n\tconst children: Record<string, VisualChildNode> = {\n\t\tname: {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.schemaName,\n\t\t},\n\t};\n\tif (schema.allowedTypes !== undefined) {\n\t\tchildren.allowedTypes = createAllowedTypesVisualTree(schema.allowedTypes);\n\t}\n\tif (schema.isRequired !== undefined) {\n\t\tchildren.isRequired = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.isRequired,\n\t\t};\n\t}\n\treturn {\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\tchildren,\n\t};\n}\n\n/**\n * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.\n * @param tree - the visual representation of the SharedTree.\n * @returns - the visual representation of type {@link VisualChildNode}\n */\nexport function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode {\n\tif (tree.kind === VisualSharedTreeNodeKind.LeafNode) {\n\t\tswitch (tree.value.nodeKind) {\n\t\t\tcase VisualNodeKind.ValueNode: {\n\t\t\t\tconst result: VisualValueNode = {\n\t\t\t\t\tvalue: tree.value.value,\n\t\t\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\t\tconst result: FluidHandleNode = {\n\t\t\t\t\tfluidObjectId: tree.value.fluidObjectId,\n\t\t\t\t\tnodeKind: VisualNodeKind.FluidHandleNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconsole.error(`Unknown node kind: ${tree.value.nodeKind}`);\n\t\t\t\tconst result: UnknownObjectNode = {\n\t\t\t\t\tnodeKind: VisualNodeKind.UnknownObjectNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst children: Record<string, VisualChildNode> = {};\n\n\t\tfor (const [key, value] of Object.entries(tree.fields)) {\n\t\t\tconst child = toVisualTree(value);\n\t\t\tchildren[key] = child;\n\t\t}\n\n\t\treturn {\n\t\t\tchildren,\n\t\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\t\ttooltipContents: {\n\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Concatenate allowed types for `ObjectNodeStoredSchema` and `MapNodeStoredSchema`.\n */\nexport function concatenateTypes(fieldTypes: ReadonlySet<string>): string {\n\treturn [...fieldTypes].join(\" | \");\n}\n\n/**\n * Properties that describe schema constraints for a field in the tree\n */\ninterface FieldSchemaProperties {\n\tallowedTypes: ReadonlySet<string> | undefined;\n\n\t/**\n\t * Whether the field is required (true) or optional (false).\n\t *\n\t * `undefined` indicates that the field is implicitly required.\n\t * In this case, no requirement information will be displayed by the devtools.\n\t */\n\tisRequired: boolean | undefined;\n}\n\n/**\n * Processes and visualizes the fields of a verbose tree node.\n *\n * @param treeFields - The fields of the tree node to visualize. Can be either an array of VerboseTree (for array nodes) or a Record of field names to VerboseTree (for object/map nodes).\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Record mapping field names to their schema properties, including allowed types and whether they are required.\n * @param visualizeChildData - Callback function to visualize child node data.\n *\n * @returns A record mapping field names/indices to their visual tree representations.\n */\nasync function visualizeVerboseNodeFields(\n\ttreeFields: readonly VerboseTree[] | Record<string, VerboseTree>,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\tfieldSchemaProperties: Record<string, FieldSchemaProperties>,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<Record<string, VisualSharedTreeNode>> {\n\tconst fields: Record<string | number, VisualSharedTreeNode> = {};\n\n\tfor (const [fieldKey, childField] of Object.entries(treeFields)) {\n\t\tfields[fieldKey] = await visualizeSharedTreeBySchema(\n\t\t\tchildField,\n\t\t\ttreeDefinitions,\n\t\t\t{\n\t\t\t\tallowedTypes: fieldSchemaProperties[fieldKey]?.allowedTypes,\n\t\t\t\tisRequired: fieldSchemaProperties[fieldKey]?.isRequired,\n\t\t\t},\n\t\t\tvisualizeChildData,\n\t\t);\n\t}\n\n\treturn fields;\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ObjectNodeStoredSchema}.\n */\nasync function visualizeObjectNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleObjectNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst objectNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [fieldKey, treeFieldSimpleSchema] of schema.fields) {\n\t\tobjectNodeSchemaProperties[fieldKey] = {\n\t\t\tallowedTypes: treeFieldSimpleSchema.allowedTypesIdentifiers,\n\t\t\tisRequired: treeFieldSimpleSchema.kind === FieldKind.Required ? true : false,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tobjectNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link MapNodeStoredSchema}.\n */\nasync function visualizeMapNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleMapNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst mapNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const key of Object.keys(tree.fields)) {\n\t\tmapNodeSchemaProperties[key] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Map values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tmapNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ArrayNodeStoredSchema}.\n */\nasync function visualizeArrayNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleArrayNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst children = tree.fields;\n\tif (!Array.isArray(children)) {\n\t\tthrow new TypeError(\"Invalid array\");\n\t}\n\n\tconst arrayNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [i] of children.entries()) {\n\t\tarrayNodeSchemaProperties[i] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Array values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tarrayNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Creates the visual representation of non-leaf SharedTree nodes.\n *\n * @remarks\n * Processes internal tree nodes based on their schema type (e.g., ObjectNodeStoredSchema, MapNodeStoredSchema, ArrayNodeStoredSchema),\n * producing the visual representation for each type.\n *\n * @see {@link https://fluidframework.com/docs/data-structures/tree/} for more information on the SharedTree schema.\n *\n * @remarks\n */\nasync function visualizeNodeBySchema(\n\ttree: VerboseTreeNode,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst schema = treeDefinitions.get(tree.type);\n\n\tif (schema === undefined) {\n\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t}\n\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst objectVisualized = visualizeObjectNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn objectVisualized;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst mapVisualized = visualizeMapNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn mapVisualized;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn visualizeArrayNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t\t}\n\t}\n}\n\n/**\n * Creates a visual representation of a SharedTree based on its schema.\n * @param tree - The {@link VerboseTree} to visualize\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition\n * describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Properties describing schema constraints for this field:\n * - `allowedTypes`: Set of type names that are valid for this specific node position in the tree.\n * This is a subset of the types defined in treeDefinitions.\n * - `isRequired`: Whether this field is required in its parent object schema.\n * Only meaningful for direct children of object nodes.\n * Undefined for array/map elements since they are always required within their parent.\n * @param visualizeChildData - Callback function to visualize child node data\n * @returns A visual representation of the tree that includes schema information and node values\n *\n * @remarks\n * This function handles both leaf nodes (primitive values, handles) and internal nodes (objects, maps, arrays).\n * For leaf nodes, it creates a visual representation with the node's schema and value.\n * For internal nodes, it recursively processes the node's fields using {@link visualizeNodeBySchema}.\n */\nexport async function visualizeSharedTreeBySchema(\n\ttree: VerboseTree,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\treturn Tree.is(tree, SchemaFactory.leaves)\n\t\t? {\n\t\t\t\tschema: {\n\t\t\t\t\tschemaName: Tree.schema(tree).identifier,\n\t\t\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\t\t\tisRequired: isRequired?.toString(),\n\t\t\t\t},\n\t\t\t\tvalue: await visualizeChildData(tree),\n\t\t\t\tkind: VisualSharedTreeNodeKind.LeafNode,\n\t\t\t}\n\t\t: visualizeNodeBySchema(\n\t\t\t\ttree,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n}\n"]}
1
+ {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C,KAAK,CAAC,CAAC,CAAC;YACrB,OAAO,kBAAkB,CACxB,IAAI,EACJ,MAAM,EACN,eAAe,EACf,EAAE,YAAY,EAAE,UAAU,EAAE,EAC5B,kBAAkB,CAClB,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAChD,IAAiB,EACjB,eAAsD,EACtD,EAAE,YAAY,EAAE,UAAU,EAAyB,EACnD,kBAAsC;IAEtC,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;QACzC,CAAC,CAAC;YACA,MAAM,EAAE;gBACP,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU;gBACxC,YAAY,EAAE,gBAAgB,CAAC,YAAY,IAAI,IAAI,GAAG,EAAE,CAAC;gBACzD,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE;aAClC;YACD,KAAK,EAAE,MAAM,kBAAkB,CAAC,IAAI,CAAC;YACrC,IAAI,EAAE,wBAAwB,CAAC,QAAQ;SACvC;QACF,CAAC,CAAC,qBAAqB,CACrB,IAAI,EACJ,eAAe,EACf,EAAE,YAAY,EAAE,UAAU,EAAE,EAC5B,kBAAkB,CAClB,CAAC;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FieldKind } from \"@fluidframework/tree\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tVerboseTree,\n\tVerboseTreeNode,\n} from \"@fluidframework/tree/internal\";\nimport { NodeKind, SchemaFactory, Tree } from \"@fluidframework/tree/internal\";\n\nimport type { VisualizeChildData } from \"./DataVisualization.js\";\nimport type { VisualSharedTreeNode, SharedTreeSchemaNode } from \"./VisualSharedTreeTypes.js\";\nimport { VisualSharedTreeNodeKind } from \"./VisualSharedTreeTypes.js\";\nimport {\n\ttype VisualChildNode,\n\tVisualNodeKind,\n\ttype VisualValueNode,\n\ttype VisualTreeNode,\n\ttype FluidHandleNode,\n\ttype UnknownObjectNode,\n} from \"./VisualTree.js\";\n\n/**\n * Returns VisualNodeKind that is compatible to {@link FluidObjectNode} based on the `visualTree`'s node kind.\n */\nexport function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeKind {\n\tswitch (nodeKind) {\n\t\tcase VisualNodeKind.TreeNode:\n\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\treturn VisualNodeKind.FluidTreeNode;\n\t\t}\n\t\tcase VisualNodeKind.ValueNode: {\n\t\t\treturn VisualNodeKind.FluidValueNode;\n\t\t}\n\t\tdefault: {\n\t\t\treturn VisualNodeKind.FluidUnknownObjectNode;\n\t\t}\n\t}\n}\n\n/**\n * Returns allowed types of the non-leaf nodes in the tree.\n * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.\n * @returns a VisualChildNode with the allowed type.\n */\nfunction createAllowedTypesVisualTree(\n\tallowedTypes: string | Record<string, string>,\n): VisualChildNode {\n\tif (typeof allowedTypes === \"string\") {\n\t\treturn {\n\t\t\tvalue: allowedTypes,\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t};\n\t}\n\n\tconst result: Record<string, VisualValueNode> = {};\n\tfor (const [allowedTypeKey, allowedType] of Object.entries(allowedTypes)) {\n\t\tresult[allowedTypeKey] = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: allowedType,\n\t\t};\n\t}\n\n\treturn {\n\t\tchildren: result,\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t};\n}\n\n/**\n * Creates a visual representation of the schema of the tree in {@link VisualTreeNode} format.\n */\nfunction createToolTipContents(schema: SharedTreeSchemaNode): VisualTreeNode {\n\tconst children: Record<string, VisualChildNode> = {\n\t\tname: {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.schemaName,\n\t\t},\n\t};\n\tif (schema.allowedTypes !== undefined) {\n\t\tchildren.allowedTypes = createAllowedTypesVisualTree(schema.allowedTypes);\n\t}\n\tif (schema.isRequired !== undefined) {\n\t\tchildren.isRequired = {\n\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\tvalue: schema.isRequired,\n\t\t};\n\t}\n\treturn {\n\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\tchildren,\n\t};\n}\n\n/**\n * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.\n * @param tree - the visual representation of the SharedTree.\n * @returns the visual representation of type {@link VisualChildNode}\n */\nexport function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode {\n\tif (tree.kind === VisualSharedTreeNodeKind.LeafNode) {\n\t\tswitch (tree.value.nodeKind) {\n\t\t\tcase VisualNodeKind.ValueNode: {\n\t\t\t\tconst result: VisualValueNode = {\n\t\t\t\t\tvalue: tree.value.value,\n\t\t\t\t\tnodeKind: VisualNodeKind.ValueNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tcase VisualNodeKind.FluidHandleNode: {\n\t\t\t\tconst result: FluidHandleNode = {\n\t\t\t\t\tfluidObjectId: tree.value.fluidObjectId,\n\t\t\t\t\tnodeKind: VisualNodeKind.FluidHandleNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconsole.error(`Unknown node kind: ${tree.value.nodeKind}`);\n\t\t\t\tconst result: UnknownObjectNode = {\n\t\t\t\t\tnodeKind: VisualNodeKind.UnknownObjectNode,\n\t\t\t\t\ttooltipContents: {\n\t\t\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst children: Record<string, VisualChildNode> = {};\n\n\t\tfor (const [key, value] of Object.entries(tree.fields)) {\n\t\t\tconst child = toVisualTree(value);\n\t\t\tchildren[key] = child;\n\t\t}\n\n\t\treturn {\n\t\t\tchildren,\n\t\t\tnodeKind: VisualNodeKind.TreeNode,\n\t\t\ttooltipContents: {\n\t\t\t\tschema: createToolTipContents(tree.schema),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Concatenate allowed types for `ObjectNodeStoredSchema` and `MapNodeStoredSchema`.\n */\nexport function concatenateTypes(fieldTypes: ReadonlySet<string>): string {\n\treturn [...fieldTypes].join(\" | \");\n}\n\n/**\n * Properties that describe schema constraints for a field in the tree\n */\ninterface FieldSchemaProperties {\n\tallowedTypes: ReadonlySet<string> | undefined;\n\n\t/**\n\t * Whether the field is required (true) or optional (false).\n\t *\n\t * `undefined` indicates that the field is implicitly required.\n\t * In this case, no requirement information will be displayed by the devtools.\n\t */\n\tisRequired: boolean | undefined;\n}\n\n/**\n * Processes and visualizes the fields of a verbose tree node.\n *\n * @param treeFields - The fields of the tree node to visualize. Can be either an array of VerboseTree (for array nodes) or a Record of field names to VerboseTree (for object/map nodes).\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Record mapping field names to their schema properties, including allowed types and whether they are required.\n * @param visualizeChildData - Callback function to visualize child node data.\n *\n * @returns A record mapping field names/indices to their visual tree representations.\n */\nasync function visualizeVerboseNodeFields(\n\ttreeFields: readonly VerboseTree[] | Record<string, VerboseTree>,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\tfieldSchemaProperties: Record<string, FieldSchemaProperties>,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<Record<string, VisualSharedTreeNode>> {\n\tconst fields: Record<string | number, VisualSharedTreeNode> = {};\n\n\tfor (const [fieldKey, childField] of Object.entries(treeFields)) {\n\t\tfields[fieldKey] = await visualizeSharedTreeBySchema(\n\t\t\tchildField,\n\t\t\ttreeDefinitions,\n\t\t\t{\n\t\t\t\tallowedTypes: fieldSchemaProperties[fieldKey]?.allowedTypes,\n\t\t\t\tisRequired: fieldSchemaProperties[fieldKey]?.isRequired,\n\t\t\t},\n\t\t\tvisualizeChildData,\n\t\t);\n\t}\n\n\treturn fields;\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ObjectNodeStoredSchema}.\n */\nasync function visualizeObjectNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleObjectNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst objectNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [fieldKey, treeFieldSimpleSchema] of schema.fields) {\n\t\tobjectNodeSchemaProperties[fieldKey] = {\n\t\t\tallowedTypes: treeFieldSimpleSchema.allowedTypesIdentifiers,\n\t\t\tisRequired: treeFieldSimpleSchema.kind === FieldKind.Required ? true : false,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tobjectNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link MapNodeStoredSchema}.\n */\nasync function visualizeMapNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleMapNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst mapNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const key of Object.keys(tree.fields)) {\n\t\tmapNodeSchemaProperties[key] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Map values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tmapNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Returns the schema & fields of the node with type {@link ArrayNodeStoredSchema}.\n */\nasync function visualizeArrayNode(\n\ttree: VerboseTreeNode,\n\tschema: SimpleArrayNodeSchema,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst children = tree.fields;\n\tif (!Array.isArray(children)) {\n\t\tthrow new TypeError(\"Invalid array\");\n\t}\n\n\tconst arrayNodeSchemaProperties: Record<string, FieldSchemaProperties> = {};\n\tfor (const [i] of children.entries()) {\n\t\tarrayNodeSchemaProperties[i] = {\n\t\t\tallowedTypes: schema.allowedTypesIdentifiers,\n\t\t\t// Array values are always required. Don't display field requirement information, since that information is redundant.\n\t\t\tisRequired: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\tschema: {\n\t\t\tschemaName: tree.type,\n\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\tisRequired: isRequired?.toString(),\n\t\t},\n\t\tfields: await visualizeVerboseNodeFields(\n\t\t\ttree.fields,\n\t\t\ttreeDefinitions,\n\t\t\tarrayNodeSchemaProperties,\n\t\t\tvisualizeChildData,\n\t\t),\n\t\tkind: VisualSharedTreeNodeKind.InternalNode,\n\t};\n}\n\n/**\n * Creates the visual representation of non-leaf SharedTree nodes.\n *\n * @remarks\n * Processes internal tree nodes based on their schema type (e.g., ObjectNodeStoredSchema, MapNodeStoredSchema, ArrayNodeStoredSchema),\n * producing the visual representation for each type.\n *\n * @see {@link https://fluidframework.com/docs/data-structures/tree/} for more information on the SharedTree schema.\n *\n * @remarks\n */\nasync function visualizeNodeBySchema(\n\ttree: VerboseTreeNode,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\tconst schema = treeDefinitions.get(tree.type);\n\n\tif (schema === undefined) {\n\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t}\n\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst objectVisualized = visualizeObjectNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn objectVisualized;\n\t\t}\n\t\tcase NodeKind.Map: {\n\t\t\tconst mapVisualized = visualizeMapNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t\treturn mapVisualized;\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn visualizeArrayNode(\n\t\t\t\ttree,\n\t\t\t\tschema,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new TypeError(\"Unrecognized schema type.\");\n\t\t}\n\t}\n}\n\n/**\n * Creates a visual representation of a SharedTree based on its schema.\n * @param tree - The {@link VerboseTree} to visualize\n * @param treeDefinitions - Map containing all schema definitions for the entire tree structure. Each definition\n * describes the shape and constraints of a particular node type.\n * @param fieldSchemaProperties - Properties describing schema constraints for this field:\n * - `allowedTypes`: Set of type names that are valid for this specific node position in the tree.\n * This is a subset of the types defined in treeDefinitions.\n * - `isRequired`: Whether this field is required in its parent object schema.\n * Only meaningful for direct children of object nodes.\n * Undefined for array/map elements since they are always required within their parent.\n * @param visualizeChildData - Callback function to visualize child node data\n * @returns A visual representation of the tree that includes schema information and node values\n *\n * @remarks\n * This function handles both leaf nodes (primitive values, handles) and internal nodes (objects, maps, arrays).\n * For leaf nodes, it creates a visual representation with the node's schema and value.\n * For internal nodes, it recursively processes the node's fields using {@link visualizeNodeBySchema}.\n */\nexport async function visualizeSharedTreeBySchema(\n\ttree: VerboseTree,\n\ttreeDefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n\t{ allowedTypes, isRequired }: FieldSchemaProperties,\n\tvisualizeChildData: VisualizeChildData,\n): Promise<VisualSharedTreeNode> {\n\treturn Tree.is(tree, SchemaFactory.leaves)\n\t\t? {\n\t\t\t\tschema: {\n\t\t\t\t\tschemaName: Tree.schema(tree).identifier,\n\t\t\t\t\tallowedTypes: concatenateTypes(allowedTypes ?? new Set()),\n\t\t\t\t\tisRequired: isRequired?.toString(),\n\t\t\t\t},\n\t\t\t\tvalue: await visualizeChildData(tree),\n\t\t\t\tkind: VisualSharedTreeNodeKind.LeafNode,\n\t\t\t}\n\t\t: visualizeNodeBySchema(\n\t\t\t\ttree,\n\t\t\t\ttreeDefinitions,\n\t\t\t\t{ allowedTypes, isRequired },\n\t\t\t\tvisualizeChildData,\n\t\t\t);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/devtools-core";
8
- export declare const pkgVersion = "2.70.0-360753";
8
+ export declare const pkgVersion = "2.70.0-361248";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/devtools-core";
8
- export const pkgVersion = "2.70.0-360753";
8
+ export const pkgVersion = "2.70.0-361248";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/devtools-core\";\nexport const pkgVersion = \"2.70.0-360753\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/devtools-core\";\nexport const pkgVersion = \"2.70.0-361248\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/devtools-core",
3
- "version": "2.70.0-360753",
3
+ "version": "2.70.0-361248",
4
4
  "description": "Fluid Framework developer tools core functionality",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -67,37 +67,37 @@
67
67
  "temp-directory": "nyc/.nyc_output"
68
68
  },
69
69
  "dependencies": {
70
- "@fluid-internal/client-utils": "2.70.0-360753",
71
- "@fluidframework/aqueduct": "2.70.0-360753",
72
- "@fluidframework/cell": "2.70.0-360753",
73
- "@fluidframework/container-definitions": "2.70.0-360753",
74
- "@fluidframework/container-loader": "2.70.0-360753",
75
- "@fluidframework/container-runtime": "2.70.0-360753",
76
- "@fluidframework/container-runtime-definitions": "2.70.0-360753",
77
- "@fluidframework/core-interfaces": "2.70.0-360753",
78
- "@fluidframework/core-utils": "2.70.0-360753",
79
- "@fluidframework/counter": "2.70.0-360753",
80
- "@fluidframework/datastore-definitions": "2.70.0-360753",
81
- "@fluidframework/driver-definitions": "2.70.0-360753",
82
- "@fluidframework/map": "2.70.0-360753",
83
- "@fluidframework/matrix": "2.70.0-360753",
84
- "@fluidframework/runtime-definitions": "2.70.0-360753",
85
- "@fluidframework/sequence": "2.70.0-360753",
86
- "@fluidframework/shared-object-base": "2.70.0-360753",
87
- "@fluidframework/telemetry-utils": "2.70.0-360753",
88
- "@fluidframework/tree": "2.70.0-360753"
70
+ "@fluid-internal/client-utils": "2.70.0-361248",
71
+ "@fluidframework/aqueduct": "2.70.0-361248",
72
+ "@fluidframework/cell": "2.70.0-361248",
73
+ "@fluidframework/container-definitions": "2.70.0-361248",
74
+ "@fluidframework/container-loader": "2.70.0-361248",
75
+ "@fluidframework/container-runtime": "2.70.0-361248",
76
+ "@fluidframework/container-runtime-definitions": "2.70.0-361248",
77
+ "@fluidframework/core-interfaces": "2.70.0-361248",
78
+ "@fluidframework/core-utils": "2.70.0-361248",
79
+ "@fluidframework/counter": "2.70.0-361248",
80
+ "@fluidframework/datastore-definitions": "2.70.0-361248",
81
+ "@fluidframework/driver-definitions": "2.70.0-361248",
82
+ "@fluidframework/map": "2.70.0-361248",
83
+ "@fluidframework/matrix": "2.70.0-361248",
84
+ "@fluidframework/runtime-definitions": "2.70.0-361248",
85
+ "@fluidframework/sequence": "2.70.0-361248",
86
+ "@fluidframework/shared-object-base": "2.70.0-361248",
87
+ "@fluidframework/telemetry-utils": "2.70.0-361248",
88
+ "@fluidframework/tree": "2.70.0-361248"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@arethetypeswrong/cli": "^0.17.1",
92
92
  "@biomejs/biome": "~1.9.3",
93
- "@fluid-internal/mocha-test-setup": "2.70.0-360753",
93
+ "@fluid-internal/mocha-test-setup": "2.70.0-361248",
94
94
  "@fluid-tools/build-cli": "^0.58.3",
95
95
  "@fluidframework/build-common": "^2.0.3",
96
96
  "@fluidframework/build-tools": "^0.58.3",
97
97
  "@fluidframework/devtools-core-previous": "npm:@fluidframework/devtools-core@2.63.0",
98
- "@fluidframework/eslint-config-fluid": "^6.0.0",
99
- "@fluidframework/id-compressor": "2.70.0-360753",
100
- "@fluidframework/test-runtime-utils": "2.70.0-360753",
98
+ "@fluidframework/eslint-config-fluid": "^6.1.0",
99
+ "@fluidframework/id-compressor": "2.70.0-361248",
100
+ "@fluidframework/test-runtime-utils": "2.70.0-361248",
101
101
  "@microsoft/api-extractor": "7.52.11",
102
102
  "@types/chai": "^4.0.0",
103
103
  "@types/mocha": "^10.0.10",
@@ -106,8 +106,8 @@
106
106
  "concurrently": "^8.2.1",
107
107
  "copyfiles": "^2.4.1",
108
108
  "cross-env": "^7.0.3",
109
- "eslint": "~8.55.0",
110
- "eslint-config-prettier": "~9.0.0",
109
+ "eslint": "~8.57.1",
110
+ "eslint-config-prettier": "~10.1.8",
111
111
  "eslint-plugin-chai-expect": "~3.0.0",
112
112
  "mocha": "^10.8.2",
113
113
  "mocha-multi-reporters": "^1.5.1",
@@ -33,7 +33,7 @@ import {
33
33
  * @sealed
34
34
  * @beta
35
35
  */
36
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
36
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface
37
37
  export interface IDevtoolsLogger extends ITelemetryBaseLogger {}
38
38
 
39
39
  /**
@@ -47,7 +47,7 @@ export function determineNodeKind(nodeKind: VisualNodeKind): VisualNodeKind {
47
47
  /**
48
48
  * Returns allowed types of the non-leaf nodes in the tree.
49
49
  * @param allowedTypes - a string if array node, `Record<string, string>` for non-array nodes.
50
- * @returns - a VisualChildNode with the allowed type.
50
+ * @returns a VisualChildNode with the allowed type.
51
51
  */
52
52
  function createAllowedTypesVisualTree(
53
53
  allowedTypes: string | Record<string, string>,
@@ -101,7 +101,7 @@ function createToolTipContents(schema: SharedTreeSchemaNode): VisualTreeNode {
101
101
  /**
102
102
  * Converts the visual representation from {@link visualizeNodeBySchema} to a visual tree compatible with the devtools-view.
103
103
  * @param tree - the visual representation of the SharedTree.
104
- * @returns - the visual representation of type {@link VisualChildNode}
104
+ * @returns the visual representation of type {@link VisualChildNode}
105
105
  */
106
106
  export function toVisualTree(tree: VisualSharedTreeNode): VisualChildNode {
107
107
  if (tree.kind === VisualSharedTreeNodeKind.LeafNode) {
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/devtools-core";
9
- export const pkgVersion = "2.70.0-360753";
9
+ export const pkgVersion = "2.70.0-361248";