@player-tools/devtools-profiler-web-plugin 0.6.1--canary.125.2996

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.
Files changed (38) hide show
  1. package/dist/cjs/index.cjs +847 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/index.legacy-esm.js +812 -0
  4. package/dist/index.mjs +812 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +42 -0
  7. package/src/WrapperComponent.tsx +121 -0
  8. package/src/__tests__/__snapshots__/index.test.tsx.snap +90 -0
  9. package/src/__tests__/index.test.tsx +307 -0
  10. package/src/constants/index.ts +28 -0
  11. package/src/content/common/Screen.tsx +20 -0
  12. package/src/content/common/index.ts +1 -0
  13. package/src/content/index.ts +19 -0
  14. package/src/content/navigation/index.ts +27 -0
  15. package/src/content/schema/index.ts +22 -0
  16. package/src/content/views/ProfilerView.tsx +75 -0
  17. package/src/content/views/index.ts +3 -0
  18. package/src/helpers/__tests__/genDataChangeTransaction.test.ts +40 -0
  19. package/src/helpers/__tests__/profiler.test.ts +104 -0
  20. package/src/helpers/genDataChangeTransaction.ts +39 -0
  21. package/src/helpers/index.ts +2 -0
  22. package/src/helpers/profiler.ts +111 -0
  23. package/src/index.tsx +490 -0
  24. package/src/types.ts +26 -0
  25. package/types/WrapperComponent.d.ts +4 -0
  26. package/types/constants/index.d.ts +15 -0
  27. package/types/content/common/Screen.d.ts +8 -0
  28. package/types/content/common/index.d.ts +2 -0
  29. package/types/content/index.d.ts +31 -0
  30. package/types/content/navigation/index.d.ts +7 -0
  31. package/types/content/schema/index.d.ts +23 -0
  32. package/types/content/views/ProfilerView.d.ts +3 -0
  33. package/types/content/views/index.d.ts +3 -0
  34. package/types/helpers/genDataChangeTransaction.d.ts +16 -0
  35. package/types/helpers/index.d.ts +3 -0
  36. package/types/helpers/profiler.d.ts +18 -0
  37. package/types/index.d.ts +7 -0
  38. package/types/types.d.ts +29 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/profiler/src/index.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/profiler/src/constants/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/profiler/src/WrapperComponent.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/profiler/src/helpers/genDataChangeTransaction.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/profiler/src/helpers/profiler.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/desktop/profiler/_generated/index.json"],"sourcesContent":["import type { ReactPlayer, ReactPlayerPlugin } from \"@player-ui/react\";\nimport React from \"react\";\nimport { PLUGIN_ID } from \"./constants\";\nimport { ProfilerNode } from \"./types\";\nimport { WrapperComponent } from \"./WrapperComponent\";\nimport { profiler } from \"./helpers\";\n\nexport class ProfilerPlugin implements ReactPlayerPlugin {\n name = PLUGIN_ID;\n\n checkIfDevtoolsIsActive() {\n return localStorage.getItem(\"player-ui-devtools-active\") === \"true\";\n }\n\n applyReact({ player, hooks: { webComponent } }: ReactPlayer) {\n if (!this.checkIfDevtoolsIsActive()) {\n return;\n }\n\n const { start, startTimer, endTimer, stopProfiler } = profiler();\n\n /** function to tap into hooks and start the profiler */\n const startProfiler = () => {\n start();\n\n player.hooks.onStart.intercept({\n call: () => {\n startTimer(\"onStart\");\n },\n });\n\n player.hooks.onStart.tap(this.name, () => {\n endTimer({ hookName: \"onStart\" });\n });\n\n player.hooks.flowController.intercept({\n call: (fc) => {\n startTimer(\"flowController\");\n fc.hooks.flow.intercept({\n call: () => {\n startTimer(\"flow\");\n },\n });\n },\n });\n\n player.hooks.flowController.tap(this.name, (fc) => {\n let flowControllerNode: ProfilerNode = {\n name: \"flowController\",\n children: [],\n };\n\n fc.hooks.flow.tap(this.name, () => {\n endTimer({ hookName: \"flow\", parentNode: flowControllerNode });\n });\n\n flowControllerNode = endTimer({\n hookName: flowControllerNode.name,\n children: flowControllerNode.children,\n });\n });\n\n player.hooks.viewController.intercept({\n call: (vc) => {\n startTimer(\"viewController\");\n vc.hooks.resolveView.intercept({\n call: () => {\n startTimer(\"resolveView\");\n },\n });\n vc.hooks.view.intercept({\n call: () => {\n startTimer(\"view\");\n },\n });\n },\n });\n\n player.hooks.viewController.tap(this.name, (vc) => {\n let viewControllerNode: ProfilerNode = {\n name: \"viewController\",\n children: [],\n };\n\n vc.hooks.resolveView.tap(this.name, (asset) => {\n endTimer({ hookName: \"resolveView\", parentNode: viewControllerNode });\n return asset;\n });\n\n viewControllerNode = endTimer({\n hookName: viewControllerNode.name,\n children: viewControllerNode.children,\n });\n });\n\n player.hooks.view.intercept({\n call: (view) => {\n startTimer(\"view\");\n\n view.hooks.onUpdate.intercept({\n call: () => {\n startTimer(\"onUpdate\");\n },\n });\n\n view.hooks.parser.intercept({\n call: () => {\n startTimer(\"parser\");\n },\n });\n\n view.hooks.resolver.intercept({\n call: () => {\n startTimer(\"resolver\");\n },\n });\n\n view.hooks.templatePlugin.intercept({\n call: () => {\n startTimer(\"templatePlugin\");\n },\n });\n },\n });\n\n player.hooks.view.tap(this.name, (view) => {\n let viewNode: ProfilerNode = {\n name: \"view\",\n children: [],\n };\n\n view.hooks.onUpdate.tap(this.name, () => {\n endTimer({ hookName: \"onUpdate\", parentNode: viewNode });\n });\n\n view.hooks.parser.tap(this.name, () => {\n endTimer({ hookName: \"parser\", parentNode: viewNode });\n });\n\n view.hooks.resolver.tap(this.name, () => {\n endTimer({ hookName: \"resolver\", parentNode: viewNode });\n });\n\n view.hooks.templatePlugin.tap(this.name, () => {\n endTimer({ hookName: \"templatePlugin\", parentNode: viewNode });\n });\n\n viewNode = endTimer({\n hookName: viewNode.name,\n children: viewNode.children,\n });\n });\n\n player.hooks.expressionEvaluator.intercept({\n call: (ev) => {\n startTimer(\"expressionEvaluator\");\n\n ev.hooks.resolve.intercept({\n call: () => {\n startTimer(\"resolve\");\n },\n });\n\n ev.hooks.onError.intercept({\n call: () => {\n startTimer(\"onError\");\n },\n });\n },\n });\n\n player.hooks.expressionEvaluator.tap(this.name, (ev) => {\n let expressionEvaluatorNode: ProfilerNode = {\n name: \"expressionEvaluator\",\n children: [],\n };\n\n ev.hooks.resolve.tap(this.name, () => {\n endTimer({\n hookName: \"resolve\",\n parentNode: expressionEvaluatorNode,\n });\n });\n\n ev.hooks.onError.tap(this.name, () => {\n endTimer({\n hookName: \"onError\",\n parentNode: expressionEvaluatorNode,\n });\n return undefined;\n });\n\n expressionEvaluatorNode = endTimer({\n hookName: expressionEvaluatorNode.name,\n children: expressionEvaluatorNode.children,\n });\n });\n\n player.hooks.dataController.intercept({\n call: (dc) => {\n startTimer(\"dataController\");\n\n dc.hooks.resolve.intercept({\n call: () => {\n startTimer(\"resolve\");\n },\n });\n dc.hooks.resolveDataStages.intercept({\n call: () => {\n startTimer(\"resolveDataStages\");\n },\n });\n dc.hooks.resolveDefaultValue.intercept({\n call: () => {\n startTimer(\"resolveDefaultValue\");\n },\n });\n dc.hooks.onDelete.intercept({\n call: () => {\n startTimer(\"onDelete\");\n },\n });\n dc.hooks.onSet.intercept({\n call: () => {\n startTimer(\"onSet\");\n },\n });\n dc.hooks.onGet.intercept({\n call: () => {\n startTimer(\"onGet\");\n },\n });\n dc.hooks.onUpdate.intercept({\n call: () => {\n startTimer(\"onUpdate\");\n },\n });\n dc.hooks.format.intercept({\n call: () => {\n startTimer(\"resolve\");\n },\n });\n dc.hooks.deformat.intercept({\n call: () => {\n startTimer(\"deformat\");\n },\n });\n dc.hooks.serialize.intercept({\n call: () => {\n startTimer(\"serialize\");\n },\n });\n },\n });\n\n player.hooks.dataController.tap(this.name, (dc) => {\n let dataControllerNode: ProfilerNode = {\n name: \"dataController\",\n children: [],\n };\n\n dc.hooks.resolve.tap(this.name, () => {\n endTimer({ hookName: \"resolve\", parentNode: dataControllerNode });\n });\n\n dc.hooks.resolveDataStages.tap(this.name, (dataPipeline) => {\n endTimer({\n hookName: \"resolveDataStages\",\n parentNode: dataControllerNode,\n });\n return dataPipeline;\n });\n\n dc.hooks.resolveDefaultValue.tap(this.name, () => {\n endTimer({\n hookName: \"resolveDefaultValue\",\n parentNode: dataControllerNode,\n });\n });\n\n dc.hooks.onDelete.tap(this.name, () => {\n endTimer({ hookName: \"onDelete\", parentNode: dataControllerNode });\n });\n\n dc.hooks.onSet.tap(this.name, () => {\n endTimer({ hookName: \"onSet\", parentNode: dataControllerNode });\n });\n\n dc.hooks.onGet.tap(this.name, () => {\n endTimer({ hookName: \"onGet\", parentNode: dataControllerNode });\n });\n\n dc.hooks.onUpdate.tap(this.name, () => {\n endTimer({ hookName: \"onUpdate\", parentNode: dataControllerNode });\n });\n\n dc.hooks.format.tap(this.name, () => {\n endTimer({ hookName: \"format\", parentNode: dataControllerNode });\n });\n\n dc.hooks.deformat.tap(this.name, () => {\n endTimer({ hookName: \"deformat\", parentNode: dataControllerNode });\n });\n\n dc.hooks.serialize.tap(this.name, () => {\n endTimer({ hookName: \"serialize\", parentNode: dataControllerNode });\n });\n\n dataControllerNode = endTimer({\n hookName: dataControllerNode.name,\n children: dataControllerNode.children,\n });\n });\n\n player.hooks.schema.intercept({\n call: (sc) => {\n startTimer(\"schema\");\n sc.hooks.resolveTypeForBinding.intercept({\n call: () => {\n startTimer(\"resolveTypeForBinding\");\n },\n });\n },\n });\n\n player.hooks.schema.tap(this.name, (sc) => {\n let schemaNode: ProfilerNode = {\n name: \"schema\",\n children: [],\n };\n\n sc.hooks.resolveTypeForBinding.tap(this.name, (dataType) => {\n endTimer({\n hookName: \"resolveTypeForBinding\",\n parentNode: schemaNode,\n });\n return dataType;\n });\n\n schemaNode = endTimer({\n hookName: schemaNode.name,\n children: schemaNode.children,\n });\n });\n\n player.hooks.validationController.intercept({\n call: (vc) => {\n startTimer(\"validationController\");\n\n vc.hooks.createValidatorRegistry.intercept({\n call: () => {\n startTimer(\"createValidatorRegistry\");\n },\n });\n vc.hooks.onAddValidation.intercept({\n call: () => {\n startTimer(\"onAddValidation\");\n },\n });\n vc.hooks.onRemoveValidation.intercept({\n call: () => {\n startTimer(\"onRemoveValidation\");\n },\n });\n },\n });\n\n player.hooks.validationController.tap(this.name, (vc) => {\n let validationControllerNode: ProfilerNode = {\n name: \"validationController\",\n children: [],\n };\n\n vc.hooks.createValidatorRegistry.tap(this.name, () => {\n endTimer({\n hookName: \"createValidatorRegistry\",\n parentNode: validationControllerNode,\n });\n });\n\n vc.hooks.onAddValidation.tap(this.name, (validationResponse) => {\n endTimer({\n hookName: \"onAddValidation\",\n parentNode: validationControllerNode,\n });\n return validationResponse;\n });\n\n vc.hooks.onRemoveValidation.tap(this.name, (validationResponse) => {\n endTimer({\n hookName: \"onRemoveValidation\",\n parentNode: validationControllerNode,\n });\n return validationResponse;\n });\n\n validationControllerNode = endTimer({\n hookName: validationControllerNode.name,\n children: validationControllerNode.children,\n });\n });\n\n player.hooks.bindingParser.intercept({\n call: (bp) => {\n startTimer(\"bindingParser\");\n bp.hooks.skipOptimization.intercept({\n call: () => {\n startTimer(\"skipOptimization\");\n },\n });\n bp.hooks.beforeResolveNode.intercept({\n call: () => {\n startTimer(\"beforeResolveNode\");\n },\n });\n },\n });\n\n player.hooks.bindingParser.tap(this.name, (bp) => {\n let bindingParserNode: ProfilerNode = {\n name: \"bindingParser\",\n children: [],\n };\n\n bp.hooks.skipOptimization.tap(this.name, () => {\n endTimer({\n hookName: \"skipOptimization\",\n parentNode: bindingParserNode,\n });\n return undefined;\n });\n bp.hooks.beforeResolveNode.tap(this.name, (node) => {\n endTimer({\n hookName: \"beforeResolveNode\",\n parentNode: bindingParserNode,\n });\n return node;\n });\n\n bindingParserNode = endTimer({\n hookName: bindingParserNode.name,\n children: bindingParserNode.children,\n });\n });\n\n player.hooks.state.intercept({\n call: () => {\n startTimer(\"state\");\n },\n });\n\n player.hooks.state.tap(this.name, () => {\n endTimer({ hookName: \"state\" });\n });\n\n player.hooks.onEnd.intercept({\n call: () => {\n startTimer(\"onEnd\");\n },\n });\n\n player.hooks.onEnd.tap(this.name, () => {\n endTimer({ hookName: \"onEnd\" });\n });\n\n player.hooks.resolveFlowContent.intercept({\n call: () => {\n startTimer(\"resolveFlowContent\");\n },\n });\n\n player.hooks.resolveFlowContent.tap(this.name, (flow) => {\n endTimer({ hookName: \"resolveFlowContent\" });\n return flow;\n });\n };\n\n // eslint-disable-next-line react/display-name\n webComponent.tap(this.name, (Comp) => () => {\n return (\n <WrapperComponent\n startProfiler={startProfiler}\n stopProfiler={stopProfiler}\n >\n <Comp />\n </WrapperComponent>\n );\n });\n }\n}\n","import type { PluginData } from \"@player-tools/devtools-types\";\n\nexport const PLUGIN_ID = \"player-ui-profiler-plugin\";\n\nexport const PLUGIN_NAME = \"Player UI Profiler\";\n\nexport const PLUGIN_DESCRIPTION = \"Standard Player UI Profiler\";\n\nexport const PLUGIN_VERSION = \"0.0.1\";\n\nexport const VIEWS_IDS = {\n PROFILER: \"Profiler\",\n};\n\nexport const INTERACTIONS = {\n START_PROFILING: \"start-profiling\",\n STOP_PROFILING: \"stop-profiling\",\n};\n\nexport const BASE_PLUGIN_DATA: Omit<PluginData, \"flow\"> = {\n id: PLUGIN_ID,\n name: PLUGIN_NAME,\n description: PLUGIN_DESCRIPTION,\n version: PLUGIN_VERSION,\n};\n\nexport const PLUGIN_INACTIVE_WARNING =\n \"The plugin has been registered, but the Player development tools are not active. If you are working in a production environment, it is recommended to remove the plugin. Either way, you can activate the Player development tools by clicking on the extension popup and refreshing the page.\";\n","import { usePluginState } from \"@player-tools/devtools-desktop-plugins-common\";\nimport type {\n DevtoolsPluginInteractionEvent,\n PlayerInitEvent,\n PluginData,\n Transaction,\n} from \"@player-tools/devtools-types\";\nimport type { Flow } from \"@player-ui/react\";\nimport { dset } from \"dset/merge\";\nimport { produce } from \"immer\";\nimport React, { useCallback, useEffect } from \"react\";\nimport { BASE_PLUGIN_DATA, INTERACTIONS } from \"./constants\";\nimport type { WrapperComponentProps } from \"./types\";\nimport { genDataChangeTransaction } from \"./helpers\";\nimport flow from \"../_generated/index.json\";\n\nconst pluginData: PluginData = {\n ...BASE_PLUGIN_DATA,\n flow: flow as Flow,\n};\n\n/** Defines the content to be rendered into the extension Player UI and process changes */\nexport const WrapperComponent = ({\n children,\n startProfiler,\n stopProfiler,\n}: WrapperComponentProps): JSX.Element => {\n const [state, playerID, dispatch] = usePluginState();\n const lastProcessedInteraction = React.useRef(0);\n const id = pluginData.id;\n\n // Initial plugin content\n useEffect(() => {\n const transaction: Transaction<PlayerInitEvent> = {\n id: -1,\n type: \"PLAYER_DEVTOOLS_PLAYER_INIT\",\n payload: {\n plugins: {\n [id]: pluginData,\n },\n },\n sender: playerID,\n context: \"player\",\n target: \"player\",\n timestamp: Date.now(),\n _messenger_: true,\n };\n\n dispatch(transaction);\n }, []);\n\n const processInteraction = useCallback(\n (interaction: DevtoolsPluginInteractionEvent) => {\n const {\n payload: { type },\n } = interaction;\n if (type === INTERACTIONS.START_PROFILING) {\n startProfiler();\n lastProcessedInteraction.current += 1;\n\n const newState = produce(state, (draft) => {\n dset(draft, [\"plugins\", id, \"flow\", \"data\", \"rootNode\"], {\n name: \"root\",\n children: [],\n });\n dset(draft, [\"plugins\", id, \"flow\", \"data\", \"durations\"], []);\n dset(draft, [\"plugins\", id, \"flow\", \"data\", \"profiling\"], true);\n dset(\n draft,\n [\"plugins\", id, \"flow\", \"data\", \"displayFlameGraph\"],\n false\n );\n });\n\n const transaction = genDataChangeTransaction({\n playerID,\n data: newState.plugins[id].flow.data,\n pluginID: id,\n });\n\n dispatch(transaction);\n }\n\n if (type === INTERACTIONS.STOP_PROFILING) {\n const { rootNode, durations } = stopProfiler();\n lastProcessedInteraction.current += 1;\n\n const newState = produce(state, (draft) => {\n dset(draft, [\"plugins\", id, \"flow\", \"data\", \"rootNode\"], rootNode);\n dset(draft, [\"plugins\", id, \"flow\", \"data\", \"durations\"], durations);\n dset(draft, [\"plugins\", id, \"flow\", \"data\", \"profiling\"], false);\n dset(\n draft,\n [\"plugins\", id, \"flow\", \"data\", \"displayFlameGraph\"],\n true\n );\n });\n\n const transaction = genDataChangeTransaction({\n playerID,\n data: newState.plugins[id].flow.data,\n pluginID: id,\n });\n\n dispatch(transaction);\n }\n },\n [dispatch, id, state]\n );\n\n // Process interactions\n useEffect(() => {\n if (lastProcessedInteraction.current < (state.interactions.length ?? 0)) {\n state.interactions\n .slice(lastProcessedInteraction.current)\n .forEach(processInteraction);\n }\n }, [state.interactions.length]);\n\n return children as JSX.Element;\n};\n","import type {\n DevtoolsDataChangeEvent,\n Transaction,\n} from \"@player-tools/devtools-types\";\nimport type { Flow } from \"@player-ui/react\";\n\nconst NOOP_ID = -1;\n\n/**\n * Generates a data change transaction for the player devtools plugin.\n *\n * This function creates a transaction object that represents a change in data\n * within a player devtools plugin. The transaction includes details such as the\n * plugin ID, the changed data, and the player ID. It is used to communicate\n * changes between the plugin and devtools.\n */\nexport const genDataChangeTransaction = ({\n playerID,\n data,\n pluginID,\n}: {\n playerID: string;\n data: Flow[\"data\"];\n pluginID: string;\n}): Transaction<DevtoolsDataChangeEvent> => {\n return {\n id: NOOP_ID,\n type: \"PLAYER_DEVTOOLS_PLUGIN_DATA_CHANGE\",\n payload: {\n pluginID,\n data,\n },\n sender: playerID,\n context: \"player\",\n target: \"player\",\n timestamp: Date.now(),\n _messenger_: true,\n };\n};\n","import type { ProfilerNode } from \"../types\";\n\nexport const profiler = () => {\n let rootNode: ProfilerNode = {\n name: \"root\",\n children: [],\n };\n\n let record: { [key: string]: number[] } = {};\n let durations: { hookName: string; duration: number }[] = [];\n\n const start = () => {\n rootNode = {\n name: \"root\",\n startTime: performance.now(),\n children: [],\n };\n record = {};\n durations = [];\n };\n\n const addNodeToTree = (newNode: ProfilerNode, parentNode: ProfilerNode) => {\n parentNode.children.push(newNode);\n return newNode;\n };\n\n const startTimer = (hookName: string) => {\n const startTime = performance.now();\n\n if (!record[hookName] || record[hookName].length === 2) {\n record[hookName] = [];\n record[hookName].push(startTime);\n }\n };\n\n const endTimer = ({\n hookName,\n parentNode = rootNode,\n children,\n }: {\n hookName: string;\n parentNode?: ProfilerNode;\n children?: ProfilerNode[];\n }) => {\n let startTime: number | undefined;\n let duration: number | undefined;\n\n const endTime = performance.now();\n\n for (const key in record) {\n if (key === hookName && record[key].length === 1) {\n [startTime] = record[key];\n duration = endTime - startTime;\n record[key].push(endTime);\n }\n }\n\n const value = Math.ceil((duration || 0.01) * 1000);\n\n const newNode: ProfilerNode = {\n name: hookName,\n startTime,\n endTime,\n value,\n tooltip: `${hookName}, ${(duration || 0.01).toFixed(4)} (ms)`,\n children: children ?? [],\n };\n\n addNodeToTree(newNode, parentNode);\n\n // Push the hookName and duration into durations array\n durations.push({ hookName, duration: duration ? duration : 0.01 });\n\n return newNode;\n };\n\n const stopProfiler = (): {\n rootNode: ProfilerNode;\n durations: { name: string; duration: string }[];\n } => {\n const endTime = performance.now();\n const totalTime = endTime - (rootNode.startTime ?? 0);\n\n rootNode.endTime = endTime;\n // set the stop profiler value is the sum of its children values\n // otherwise the difference of width of the root and the other nodes\n // make it impossible to see them into the flame graph\n rootNode.value =\n rootNode.children.reduce((acc, { value }) => (acc += value ?? 0), 0) ||\n Math.ceil((totalTime || 0.01) * 1000);\n rootNode.tooltip = `Profiler total time span ${totalTime.toFixed(4)} (ms)`;\n\n // Sort durations array in descending order\n durations.sort((a, b) => b.duration - a.duration);\n\n return {\n rootNode,\n durations: durations.map(({ hookName, duration }) => ({\n name: hookName,\n duration: `${duration.toFixed(4)} ms`,\n })),\n };\n };\n\n return {\n start,\n startTimer,\n endTimer,\n stopProfiler,\n };\n};\n","{\n \"id\": \"player-ui-profiler-plugin\",\n \"views\": [\n {\n \"id\": \"Profiler\",\n \"type\": \"stacked-view\",\n \"header\": {\n \"asset\": {\n \"id\": \"Profiler-header\",\n \"type\": \"collection\",\n \"values\": [\n {\n \"asset\": {\n \"id\": \"Profiler-header-values-0\",\n \"type\": \"action\",\n \"applicability\": \" {{profiling}} === true \",\n \"exp\": \"@[ publish('stop-profiling') ]@\",\n \"label\": {\n \"asset\": {\n \"id\": \"Profiler-header-values-0-label\",\n \"type\": \"text\",\n \"value\": \"Stop\"\n }\n }\n }\n },\n {\n \"asset\": {\n \"id\": \"Profiler-header-values-1\",\n \"type\": \"action\",\n \"applicability\": \" {{profiling}} === false \",\n \"exp\": \"@[ publish('start-profiling') ]@\",\n \"label\": {\n \"asset\": {\n \"id\": \"Profiler-header-values-1-label\",\n \"type\": \"text\",\n \"value\": \"Start\"\n }\n }\n }\n }\n ]\n }\n },\n \"main\": {\n \"asset\": {\n \"id\": \"Profiler-main\",\n \"type\": \"collection\",\n \"values\": [\n {\n \"asset\": {\n \"id\": \"Profiler-main-values-0\",\n \"type\": \"table\",\n \"applicability\": \" {{displayFlameGraph}} === true \",\n \"binding\": \"durations\"\n }\n },\n {\n \"asset\": {\n \"id\": \"Profiler-main-values-1\",\n \"type\": \"flame-graph\",\n \"applicability\": \" {{displayFlameGraph}} === true \",\n \"height\": 200,\n \"binding\": \"rootNode\"\n }\n },\n {\n \"asset\": {\n \"id\": \"Profiler-main-values-2\",\n \"type\": \"text\",\n \"applicability\": \" {{displayFlameGraph}} === false && {{profiling}} === true\",\n \"value\": \"Profiling...\"\n }\n },\n {\n \"asset\": {\n \"id\": \"Profiler-main-values-3\",\n \"type\": \"text\",\n \"applicability\": \" {{displayFlameGraph}} === false && {{profiling}} === false \",\n \"value\": \"Start the profiler to generate the flame graph.\"\n }\n }\n ]\n }\n }\n }\n ],\n \"navigation\": {\n \"BEGIN\": \"Plugin\",\n \"Plugin\": {\n \"startState\": \"PROFILER\",\n \"PROFILER\": {\n \"state_type\": \"VIEW\",\n \"ref\": \"Profiler\",\n \"transitions\": {\n \"Profiler\": \"PROFILER\"\n }\n }\n }\n },\n \"schema\": {\n \"ROOT\": {\n \"playerConfig\": {\n \"type\": \"RecordType\"\n },\n \"rootNode\": {\n \"type\": \"RecordType\"\n },\n \"profiling\": {\n \"type\": \"BooleanType\",\n \"default\": false,\n \"validation\": [\n {\n \"type\": \"oneOf\",\n \"message\": \"Value must be true or false\",\n \"options\": [\n true,\n false\n ]\n }\n ]\n },\n \"displayFlameGraph\": {\n \"type\": \"BooleanType\",\n \"default\": false,\n \"validation\": [\n {\n \"type\": \"oneOf\",\n \"message\": \"Value must be true or false\",\n \"options\": [\n true,\n false\n ]\n }\n ]\n },\n \"durations\": {\n \"type\": \"durationsType\",\n \"isArray\": true\n }\n },\n \"durationsType\": {\n \"name\": {\n \"type\": \"StringType\",\n \"default\": \"\",\n \"validation\": [\n {\n \"type\": \"string\"\n }\n ],\n \"format\": {\n \"type\": \"string\"\n }\n },\n \"duration\": {\n \"type\": \"StringType\",\n \"default\": \"\",\n \"validation\": [\n {\n \"type\": \"string\"\n }\n ],\n \"format\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"data\": {\n \"rootNode\": {\n \"name\": \"profiler time span\",\n \"value\": 0\n },\n \"displayFlameGraph\": false,\n \"profiling\": false\n }\n}"],"mappings":";AACA,OAAOA,YAAW;;;ACCX,IAAM,YAAY;AAElB,IAAM,cAAc;AAEpB,IAAM,qBAAqB;AAE3B,IAAM,iBAAiB;AAMvB,IAAM,eAAe;AAAA,EAC1B,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;AAEO,IAAM,mBAA6C;AAAA,EACxD,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;;;ACxBA,SAAS,sBAAsB;AAQ/B,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,OAAO,SAAS,aAAa,iBAAiB;;;ACJ9C,IAAM,UAAU;AAUT,IAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,MAI4C;AAC1C,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAA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AAM,MAAM;AACtC,iBAAS,EAAE,UAAU,QAAQ,CAAC;AAAA,MAChC,CAAC;AAED,aAAO,MAAM,MAAM,UAAU;AAAA,QAC3B,MAAM,MAAM;AACV,qBAAW,OAAO;AAAA,QACpB;AAAA,MACF,CAAC;AAED,aAAO,MAAM,MAAM,IAAI,KAAK,MAAM,MAAM;AACtC,iBAAS,EAAE,UAAU,QAAQ,CAAC;AAAA,MAChC,CAAC;AAED,aAAO,MAAM,mBAAmB,UAAU;AAAA,QACxC,MAAM,MAAM;AACV,qBAAW,oBAAoB;AAAA,QACjC;AAAA,MACF,CAAC;AAED,aAAO,MAAM,mBAAmB,IAAI,KAAK,MAAM,CAAC,SAAS;AACvD,iBAAS,EAAE,UAAU,qBAAqB,CAAC;AAC3C,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAGA,iBAAa,IAAI,KAAK,MAAM,CAAC,SAAS,MAAM;AAC1C,aACE,gBAAAC,OAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA;AAAA,QAEA,gBAAAA,OAAA,cAAC,UAAK;AAAA,MACR;AAAA,IAEJ,CAAC;AAAA,EACH;AACF;","names":["React","React"]}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@player-tools/devtools-profiler-web-plugin",
3
+ "version": "0.6.1--canary.125.2996",
4
+ "main": "dist/cjs/index.cjs",
5
+ "dependencies": {
6
+ "@player-tools/devtools-types": "0.6.1--canary.125.2996",
7
+ "@player-tools/devtools-desktop-plugins-common": "0.6.1--canary.125.2996",
8
+ "@player-tools/dsl": "0.6.1--canary.125.2996",
9
+ "@player-tools/cli": "0.6.1--canary.125.2996",
10
+ "@player-ui/common-types-plugin": "0.7.3",
11
+ "@player-ui/react": "0.7.3",
12
+ "@devtools-ui/plugin": "0.2.0",
13
+ "@player-ui/reference-assets-plugin-react": "0.7.3",
14
+ "@player-ui/types": "0.7.3",
15
+ "@types/react": "^18.2.51",
16
+ "react": "^18.2.0",
17
+ "immer": "^10.0.3",
18
+ "uuid": "^8.3.2",
19
+ "@types/uuid": "^8.3.4",
20
+ "dset": "^3.1.3",
21
+ "dequal": "^2.0.2",
22
+ "tslib": "^2.6.2"
23
+ },
24
+ "module": "dist/index.legacy-esm.js",
25
+ "types": "types/index.d.ts",
26
+ "sideEffects": false,
27
+ "exports": {
28
+ "./package.json": "./package.json",
29
+ "./dist/index.css": "./dist/index.css",
30
+ ".": {
31
+ "types": "./types/index.d.ts",
32
+ "import": "./dist/index.mjs",
33
+ "default": "./dist/cjs/index.cjs"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "src",
39
+ "types"
40
+ ],
41
+ "peerDependencies": {}
42
+ }
@@ -0,0 +1,121 @@
1
+ import { usePluginState } from "@player-tools/devtools-desktop-plugins-common";
2
+ import type {
3
+ DevtoolsPluginInteractionEvent,
4
+ PlayerInitEvent,
5
+ PluginData,
6
+ Transaction,
7
+ } from "@player-tools/devtools-types";
8
+ import type { Flow } from "@player-ui/react";
9
+ import { dset } from "dset/merge";
10
+ import { produce } from "immer";
11
+ import React, { useCallback, useEffect } from "react";
12
+ import { BASE_PLUGIN_DATA, INTERACTIONS } from "./constants";
13
+ import type { WrapperComponentProps } from "./types";
14
+ import { genDataChangeTransaction } from "./helpers";
15
+ import flow from "../_generated/index.json";
16
+
17
+ const pluginData: PluginData = {
18
+ ...BASE_PLUGIN_DATA,
19
+ flow: flow as Flow,
20
+ };
21
+
22
+ /** Defines the content to be rendered into the extension Player UI and process changes */
23
+ export const WrapperComponent = ({
24
+ children,
25
+ startProfiler,
26
+ stopProfiler,
27
+ }: WrapperComponentProps): JSX.Element => {
28
+ const [state, playerID, dispatch] = usePluginState();
29
+ const lastProcessedInteraction = React.useRef(0);
30
+ const id = pluginData.id;
31
+
32
+ // Initial plugin content
33
+ useEffect(() => {
34
+ const transaction: Transaction<PlayerInitEvent> = {
35
+ id: -1,
36
+ type: "PLAYER_DEVTOOLS_PLAYER_INIT",
37
+ payload: {
38
+ plugins: {
39
+ [id]: pluginData,
40
+ },
41
+ },
42
+ sender: playerID,
43
+ context: "player",
44
+ target: "player",
45
+ timestamp: Date.now(),
46
+ _messenger_: true,
47
+ };
48
+
49
+ dispatch(transaction);
50
+ }, []);
51
+
52
+ const processInteraction = useCallback(
53
+ (interaction: DevtoolsPluginInteractionEvent) => {
54
+ const {
55
+ payload: { type },
56
+ } = interaction;
57
+ if (type === INTERACTIONS.START_PROFILING) {
58
+ startProfiler();
59
+ lastProcessedInteraction.current += 1;
60
+
61
+ const newState = produce(state, (draft) => {
62
+ dset(draft, ["plugins", id, "flow", "data", "rootNode"], {
63
+ name: "root",
64
+ children: [],
65
+ });
66
+ dset(draft, ["plugins", id, "flow", "data", "durations"], []);
67
+ dset(draft, ["plugins", id, "flow", "data", "profiling"], true);
68
+ dset(
69
+ draft,
70
+ ["plugins", id, "flow", "data", "displayFlameGraph"],
71
+ false
72
+ );
73
+ });
74
+
75
+ const transaction = genDataChangeTransaction({
76
+ playerID,
77
+ data: newState.plugins[id].flow.data,
78
+ pluginID: id,
79
+ });
80
+
81
+ dispatch(transaction);
82
+ }
83
+
84
+ if (type === INTERACTIONS.STOP_PROFILING) {
85
+ const { rootNode, durations } = stopProfiler();
86
+ lastProcessedInteraction.current += 1;
87
+
88
+ const newState = produce(state, (draft) => {
89
+ dset(draft, ["plugins", id, "flow", "data", "rootNode"], rootNode);
90
+ dset(draft, ["plugins", id, "flow", "data", "durations"], durations);
91
+ dset(draft, ["plugins", id, "flow", "data", "profiling"], false);
92
+ dset(
93
+ draft,
94
+ ["plugins", id, "flow", "data", "displayFlameGraph"],
95
+ true
96
+ );
97
+ });
98
+
99
+ const transaction = genDataChangeTransaction({
100
+ playerID,
101
+ data: newState.plugins[id].flow.data,
102
+ pluginID: id,
103
+ });
104
+
105
+ dispatch(transaction);
106
+ }
107
+ },
108
+ [dispatch, id, state]
109
+ );
110
+
111
+ // Process interactions
112
+ useEffect(() => {
113
+ if (lastProcessedInteraction.current < (state.interactions.length ?? 0)) {
114
+ state.interactions
115
+ .slice(lastProcessedInteraction.current)
116
+ .forEach(processInteraction);
117
+ }
118
+ }, [state.interactions.length]);
119
+
120
+ return children as JSX.Element;
121
+ };
@@ -0,0 +1,90 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`ProfilerPlugin > snapshot 1`] = `
4
+ {
5
+ "asFragment": [Function],
6
+ "baseElement": <body>
7
+ <div
8
+ id="chakra-toast-portal"
9
+ >
10
+ <ul
11
+ id="chakra-toast-manager-top"
12
+ style="position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; margin: 0px auto;"
13
+ />
14
+ <ul
15
+ id="chakra-toast-manager-top-left"
16
+ style="position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column;"
17
+ />
18
+ <ul
19
+ id="chakra-toast-manager-top-right"
20
+ style="position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column;"
21
+ />
22
+ <ul
23
+ id="chakra-toast-manager-bottom-left"
24
+ style="position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column;"
25
+ />
26
+ <ul
27
+ id="chakra-toast-manager-bottom"
28
+ style="position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; margin: 0px auto;"
29
+ />
30
+ <ul
31
+ id="chakra-toast-manager-bottom-right"
32
+ style="position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column;"
33
+ />
34
+ </div>
35
+ <div />
36
+ </body>,
37
+ "container": <div />,
38
+ "debug": [Function],
39
+ "findAllByAltText": [Function],
40
+ "findAllByDisplayValue": [Function],
41
+ "findAllByLabelText": [Function],
42
+ "findAllByPlaceholderText": [Function],
43
+ "findAllByRole": [Function],
44
+ "findAllByTestId": [Function],
45
+ "findAllByText": [Function],
46
+ "findAllByTitle": [Function],
47
+ "findByAltText": [Function],
48
+ "findByDisplayValue": [Function],
49
+ "findByLabelText": [Function],
50
+ "findByPlaceholderText": [Function],
51
+ "findByRole": [Function],
52
+ "findByTestId": [Function],
53
+ "findByText": [Function],
54
+ "findByTitle": [Function],
55
+ "getAllByAltText": [Function],
56
+ "getAllByDisplayValue": [Function],
57
+ "getAllByLabelText": [Function],
58
+ "getAllByPlaceholderText": [Function],
59
+ "getAllByRole": [Function],
60
+ "getAllByTestId": [Function],
61
+ "getAllByText": [Function],
62
+ "getAllByTitle": [Function],
63
+ "getByAltText": [Function],
64
+ "getByDisplayValue": [Function],
65
+ "getByLabelText": [Function],
66
+ "getByPlaceholderText": [Function],
67
+ "getByRole": [Function],
68
+ "getByTestId": [Function],
69
+ "getByText": [Function],
70
+ "getByTitle": [Function],
71
+ "queryAllByAltText": [Function],
72
+ "queryAllByDisplayValue": [Function],
73
+ "queryAllByLabelText": [Function],
74
+ "queryAllByPlaceholderText": [Function],
75
+ "queryAllByRole": [Function],
76
+ "queryAllByTestId": [Function],
77
+ "queryAllByText": [Function],
78
+ "queryAllByTitle": [Function],
79
+ "queryByAltText": [Function],
80
+ "queryByDisplayValue": [Function],
81
+ "queryByLabelText": [Function],
82
+ "queryByPlaceholderText": [Function],
83
+ "queryByRole": [Function],
84
+ "queryByTestId": [Function],
85
+ "queryByText": [Function],
86
+ "queryByTitle": [Function],
87
+ "rerender": [Function],
88
+ "unmount": [Function],
89
+ }
90
+ `;
@@ -0,0 +1,307 @@
1
+ import React from "react";
2
+ import { ReferenceAssetsPlugin } from "@player-ui/reference-assets-plugin-react";
3
+ import { Flow, ReactPlayer } from "@player-ui/react";
4
+ import { test, vi, describe, expect } from "vitest";
5
+ import { render } from "@testing-library/react";
6
+ import { ProfilerPlugin } from "..";
7
+
8
+ vi.mock("../WrapperComponent.tsx", () => ({
9
+ WrapperComponent: vi.fn(),
10
+ }));
11
+
12
+ let count = 2490.0;
13
+
14
+ const now = vi.fn(() => {
15
+ count += 0.1;
16
+ return count;
17
+ });
18
+
19
+ global.performance = { ...global.performance, now };
20
+
21
+ const flow: Flow = {
22
+ id: "flow_1",
23
+ views: [
24
+ {
25
+ id: "test",
26
+ type: "text",
27
+ value: "TEST",
28
+ },
29
+ ],
30
+ navigation: {
31
+ BEGIN: "flow_1",
32
+ flow_1: {
33
+ startState: "view_1",
34
+ view_1: {
35
+ state_type: "VIEW",
36
+ ref: "test",
37
+ transitions: {
38
+ "*": "end_1",
39
+ },
40
+ },
41
+ end_1: {
42
+ state_type: "END",
43
+ outcome: "end",
44
+ },
45
+ },
46
+ },
47
+ };
48
+
49
+ function waitForMicrotasks() {
50
+ return new Promise((resolve) => {
51
+ queueMicrotask(() => {
52
+ resolve({});
53
+ });
54
+ });
55
+ }
56
+
57
+ class MockPlayer {
58
+ callbacks: any[] = [];
59
+
60
+ createHandles() {
61
+ return {
62
+ tap: (name: string, cb: any) => {
63
+ this.callbacks.push(cb);
64
+ },
65
+ intercept: ({ call }: { call: any }) => {
66
+ this.callbacks.push(call);
67
+ },
68
+ };
69
+ }
70
+
71
+ hooks = {
72
+ onStart: this.createHandles(),
73
+ flowController: this.createHandles(),
74
+ flow: this.createHandles(),
75
+ viewController: this.createHandles(),
76
+ resolveView: this.createHandles(),
77
+ view: this.createHandles(),
78
+ onUpdate: this.createHandles(),
79
+ parser: this.createHandles(),
80
+ resolver: this.createHandles(),
81
+ templatePlugin: this.createHandles(),
82
+ expressionEvaluator: this.createHandles(),
83
+ resolve: this.createHandles(),
84
+ onError: this.createHandles(),
85
+ dataController: this.createHandles(),
86
+ resolveDataStages: this.createHandles(),
87
+ resolveDefaultValue: this.createHandles(),
88
+ onDelete: this.createHandles(),
89
+ onSet: this.createHandles(),
90
+ onGet: this.createHandles(),
91
+ format: this.createHandles(),
92
+ deformat: this.createHandles(),
93
+ serialize: this.createHandles(),
94
+ schema: this.createHandles(),
95
+ resolveTypeForBinding: this.createHandles(),
96
+ validationController: this.createHandles(),
97
+ createValidatorRegistry: this.createHandles(),
98
+ onAddValidation: this.createHandles(),
99
+ onRemoveValidation: this.createHandles(),
100
+ bindingParser: this.createHandles(),
101
+ skipOptimization: this.createHandles(),
102
+ beforeResolveNode: this.createHandles(),
103
+ state: this.createHandles(),
104
+ onEnd: this.createHandles(),
105
+ resolveFlowContent: this.createHandles(),
106
+ };
107
+
108
+ runAllCallbacks() {
109
+ this.callbacks.forEach((cb) => cb({ hooks: this.hooks }));
110
+ }
111
+ }
112
+
113
+ describe("ProfilerPlugin", () => {
114
+ test("profiling all hooks", () => {
115
+ localStorage.setItem("player-ui-devtools-active", "true");
116
+ const plugin = new ProfilerPlugin();
117
+ const mockPlayer = new MockPlayer();
118
+ let props: any;
119
+
120
+ plugin.applyReact({
121
+ player: mockPlayer,
122
+ hooks: {
123
+ webComponent: {
124
+ tap: (_: string, cb: any) => {
125
+ props = cb(() => <div />)().props;
126
+ },
127
+ },
128
+ },
129
+ } as any);
130
+
131
+ const { startProfiler, stopProfiler } = props;
132
+
133
+ startProfiler();
134
+
135
+ mockPlayer.runAllCallbacks();
136
+
137
+ const result = stopProfiler();
138
+
139
+ expect(result).toStrictEqual({
140
+ durations: [
141
+ {
142
+ duration: "0.1000 ms",
143
+ name: "onStart",
144
+ },
145
+ {
146
+ duration: "0.1000 ms",
147
+ name: "flowController",
148
+ },
149
+ {
150
+ duration: "0.1000 ms",
151
+ name: "viewController",
152
+ },
153
+ {
154
+ duration: "0.1000 ms",
155
+ name: "view",
156
+ },
157
+ {
158
+ duration: "0.1000 ms",
159
+ name: "expressionEvaluator",
160
+ },
161
+ {
162
+ duration: "0.1000 ms",
163
+ name: "dataController",
164
+ },
165
+ {
166
+ duration: "0.1000 ms",
167
+ name: "schema",
168
+ },
169
+ {
170
+ duration: "0.1000 ms",
171
+ name: "validationController",
172
+ },
173
+ {
174
+ duration: "0.1000 ms",
175
+ name: "bindingParser",
176
+ },
177
+ {
178
+ duration: "0.1000 ms",
179
+ name: "state",
180
+ },
181
+ {
182
+ duration: "0.1000 ms",
183
+ name: "onEnd",
184
+ },
185
+ {
186
+ duration: "0.1000 ms",
187
+ name: "resolveFlowContent",
188
+ },
189
+ ],
190
+ rootNode: {
191
+ children: [
192
+ {
193
+ children: [],
194
+ endTime: 2490.2999999999997,
195
+ name: "onStart",
196
+ startTime: 2490.2,
197
+ tooltip: "onStart, 0.1000 (ms)",
198
+ value: 100,
199
+ },
200
+ {
201
+ children: [],
202
+ endTime: 2490.4999999999995,
203
+ name: "flowController",
204
+ startTime: 2490.3999999999996,
205
+ tooltip: "flowController, 0.1000 (ms)",
206
+ value: 100,
207
+ },
208
+ {
209
+ children: [],
210
+ endTime: 2490.6999999999994,
211
+ name: "viewController",
212
+ startTime: 2490.5999999999995,
213
+ tooltip: "viewController, 0.1000 (ms)",
214
+ value: 100,
215
+ },
216
+ {
217
+ children: [],
218
+ endTime: 2490.899999999999,
219
+ name: "view",
220
+ startTime: 2490.7999999999993,
221
+ tooltip: "view, 0.1000 (ms)",
222
+ value: 100,
223
+ },
224
+ {
225
+ children: [],
226
+ endTime: 2491.099999999999,
227
+ name: "expressionEvaluator",
228
+ startTime: 2490.999999999999,
229
+ tooltip: "expressionEvaluator, 0.1000 (ms)",
230
+ value: 100,
231
+ },
232
+ {
233
+ children: [],
234
+ endTime: 2491.299999999999,
235
+ name: "dataController",
236
+ startTime: 2491.199999999999,
237
+ tooltip: "dataController, 0.1000 (ms)",
238
+ value: 100,
239
+ },
240
+ {
241
+ children: [],
242
+ endTime: 2491.4999999999986,
243
+ name: "schema",
244
+ startTime: 2491.3999999999987,
245
+ tooltip: "schema, 0.1000 (ms)",
246
+ value: 100,
247
+ },
248
+ {
249
+ children: [],
250
+ endTime: 2491.6999999999985,
251
+ name: "validationController",
252
+ startTime: 2491.5999999999985,
253
+ tooltip: "validationController, 0.1000 (ms)",
254
+ value: 100,
255
+ },
256
+ {
257
+ children: [],
258
+ endTime: 2491.8999999999983,
259
+ name: "bindingParser",
260
+ startTime: 2491.7999999999984,
261
+ tooltip: "bindingParser, 0.1000 (ms)",
262
+ value: 100,
263
+ },
264
+ {
265
+ children: [],
266
+ endTime: 2492.099999999998,
267
+ name: "state",
268
+ startTime: 2491.999999999998,
269
+ tooltip: "state, 0.1000 (ms)",
270
+ value: 100,
271
+ },
272
+ {
273
+ children: [],
274
+ endTime: 2492.299999999998,
275
+ name: "onEnd",
276
+ startTime: 2492.199999999998,
277
+ tooltip: "onEnd, 0.1000 (ms)",
278
+ value: 100,
279
+ },
280
+ {
281
+ children: [],
282
+ endTime: 2492.4999999999977,
283
+ name: "resolveFlowContent",
284
+ startTime: 2492.399999999998,
285
+ tooltip: "resolveFlowContent, 0.1000 (ms)",
286
+ value: 100,
287
+ },
288
+ ],
289
+ endTime: 2492.5999999999976,
290
+ name: "root",
291
+ startTime: 2490.1,
292
+ tooltip: "Profiler total time span 2.5000 (ms)",
293
+ value: 1200,
294
+ },
295
+ });
296
+ });
297
+
298
+ test("snapshot", async () => {
299
+ const rp = new ReactPlayer({
300
+ plugins: [new ProfilerPlugin(), new ReferenceAssetsPlugin()],
301
+ });
302
+ rp.start(flow);
303
+ await waitForMicrotasks();
304
+ const el = render(<rp.Component />);
305
+ expect(el).toMatchSnapshot();
306
+ });
307
+ });