{
  "version": 3,
  "sources": ["../../src/canvas-sandbox/index.tsx", "../../src/renderer/DebugRenderingFeatures.ts", "../../src/renderer/DeferredRendering.ts", "../../src/renderer/RenderingStateTracker.ts", "../../src/utils/debounce.ts", "../../src/canvas-sandbox/checkTextWordBreakForRichTextNodes.ts", "../../src/canvas-sandbox/layout-measuring/measureQueueForRenderedNodes.ts", "../../src/canvas-sandbox/viewBoxMeasurementsForRichTextNodes.tsx", "../../src/canvas-sandbox/CanvasSandboxApp.ts"],
  "sourcesContent": ["// Please keep this as the first import in the file, to make sure\n// Sentry initializes before any other imports\nimport \"sentry/entrypoints/canvas-sandbox.ts\"\nimport \"app/styles/canvas.css\"\nimport \"./index.styles.ts\"\nimport { assertEditorApp } from \"@framerjs/framer-environment/domains.ts\"\nimport { initializeEnvironment } from \"environment/index.ts\"\nimport * as Framer from \"library/index.ts\"\nimport React from \"react\"\n// IMPORTANT: initialize the base environment before using any ServiceChannels or setting up the Runtime.\n// Only move imports above this statement if you're sure they don't cause side-effects directly on import.\ninitializeEnvironment({\n\tname: \"canvas\",\n\tsecurity: {\n\t\tallowChannelToOpenerWithOrigin: assertEditorApp(document.referrer).origin,\n\t},\n})\nimport { initializeRuntime } from \"@framerjs/framer-runtime\"\nimport { getLogger } from \"@framerjs/shared\"\nimport type { CanvasRendererStateHook } from \"renderer/CanvasRenderer.tsx\"\nimport { CanvasRenderer } from \"renderer/CanvasRenderer.tsx\"\nimport { initializeAssetResolver } from \"renderer/getAssetResolver.ts\"\nimport { getBuiltInFontList } from \"renderer/getBuiltInFontListFetcher.ts\"\nimport { renderReact } from \"utils/renderReact.ts\"\nimport { loadTracing } from \"utils/tracing.ts\"\nimport { useSet } from \"utils/useSet.ts\"\nimport { experiments } from \"../app/experiments.ts\"\nimport { projectFeatures } from \"../app/projectFeatures.ts\"\nimport { getFontshareFontList } from \"../renderer/getFontshareFontListFetcher.ts\"\nimport { getGoogleFontsList } from \"../renderer/getGoogleFontListFetcher.ts\"\nimport { ModulesRuntimeContext } from \"../utils/ModulesRuntimeContext.ts\"\nimport { CanvasSandboxApp } from \"./CanvasSandboxApp.ts\"\n\ngetLogger(\"app\").info(\"Framer Sandbox Starting\", {\n\ttype: process.env.BUILD_TYPE,\n\tversion: process.env.VERSION,\n})\n\nconst log = getLogger(\"canvas-sandbox\")\n\nconst app = new CanvasSandboxApp()\n// We need Framer as a global variable to be accessible by the modules at evaluation time.\nObject.assign(window, { Framer, sandboxApp: app })\n\nlog.debug({ assetMap: app.assetMap })\nconst assetResolver = initializeAssetResolver(app.assetMap)\n\ninitializeRuntime({\n\tassetResolver,\n\tfetchGoogleFontsList: getGoogleFontsList,\n\tfetchFontshareFontsList: getFontshareFontList,\n\tfetchBuiltInFontsList: getBuiltInFontList,\n\tenableFontStore: true,\n\texecutionTimeBudgets: {\n\t\tframe: 500,\n\t\tcomponent: 150,\n\t},\n\tqueueMeasureRequest(...args) {\n\t\tapp.layoutMeasureQueue.add(...args)\n\t},\n\texperiments,\n\tprojectFeatures,\n\tuseImageSource: app.imageLoader.useImageSource,\n\tuseImageElement: app.imageLoader.useImageElement,\n\tcanRenderOptimizedCanvasImage: app.optimizedCanvasImageRenderer.canRenderCanvasImage,\n\trenderOptimizedCanvasImage: app.optimizedCanvasImageRenderer.renderCanvasImage,\n\tgetLogger(name: string) {\n\t\treturn log.extend(name)\n\t},\n})\n\nloadTracing()\n\n// The sandbox object serves as the state that drives CanvasRenderer\nconst useCanvasRendererState: CanvasRendererStateHook = () => {\n\tconst [update, setUpdate] = React.useState(0)\n\tconst renderCallbacks = useSet<() => void>()\n\n\tapp.triggerRenderer = (callback?: () => void) => {\n\t\tif (callback) renderCallbacks.add(callback)\n\t\tapp.beforeRendering()\n\t\tsetUpdate(update + 1)\n\t}\n\n\tReact.useEffect(() => {\n\t\tfor (const callback of renderCallbacks) {\n\t\t\trenderCallbacks.delete(callback)\n\t\t\tcallback()\n\t\t}\n\t})\n\n\t// Make sure cache and ground nodes in viewport are up to date.\n\tapp.startRendering()\n\treturn app\n}\n\nrenderReact(\n\t<React.StrictMode>\n\t\t<ModulesRuntimeContext.Provider value={app.modulesRuntime}>\n\t\t\t<CanvasRenderer useState={useCanvasRendererState} />\n\t\t</ModulesRuntimeContext.Provider>\n\t</React.StrictMode>,\n\tdocument.querySelector(\"main\"),\n)\n", "/** To aid debugging performance problems and other issues, we can selectively hide certain aspects\n * of rendering in the sandbox via this interface. Only when some are turned on, and\n * updateDebugRenderingFeatures is called, will this inject css in the sandbox, and start effecting\n * rendering. */\nexport interface DebugRenderingFeatures {\n\thideCanvas: boolean\n\thideFilters: boolean\n\thideShadows: boolean\n\thideGradients: boolean\n\thideBackgrounds: boolean\n\thideLayers: boolean\n\thideTexts: boolean\n\thideImages: boolean\n\thideSVGs: boolean\n\thideGraphics: boolean\n\thideCodeComponents: boolean\n\thideExternalComponents: boolean\n\thideLocalComponents: boolean\n}\n\ninterface WithDebugRenderingFeatures {\n\tdebugRenderingFeatures?: Partial<DebugRenderingFeatures>\n\tupdateAllNodes(): void\n}\n\nexport function updateDebugRenderingFeatures(\n\tfeatures: Partial<DebugRenderingFeatures>,\n\tstateTracker: WithDebugRenderingFeatures,\n) {\n\t// Some states use the RenderingStateTracker and need a re-render to take effect.\n\tstateTracker.debugRenderingFeatures = features\n\tstateTracker.updateAllNodes()\n\n\t// Other states we toggle via css.\n\tfor (const [key, value] of Object.entries(features)) {\n\t\tdocument.body.classList.toggle(`framerdebug-${key}`, value)\n\t}\n\n\t// First time around, inject a stylesheet if needed.\n\tconst styleSheetId = \"debugRenderingFeaturesStyles\"\n\tif (document.getElementById(styleSheetId)) return\n\n\tconst styleSheet = document.createElement(\"style\")\n\tstyleSheet.id = styleSheetId\n\tstyleSheet.setAttribute(\"type\", \"text/css\")\n\tstyleSheet.setAttribute(\"data-framer-css\", \"true\")\n\tstyleSheet.innerText = `\n        .framerdebug-hideCanvas {\n            display: none !important;\n        }\n        .framerdebug-hideShadows * {\n            box-shadow: none !important;\n            text-shadow: none !important;\n        }\n        .framerdebug-hideFilters * {\n            filter: none !important;\n            backdrop-filter: none !important;\n        }\n        .framerdebug-hideBackgrounds * {\n            background: none !important;\n        }\n        .framerdebug-hideLayers * {\n            will-change: unset !important;\n        }\n        .framerdebug-hideImages img {\n            display: none !important;\n        }\n    `\n\tdocument.head.appendChild(styleSheet)\n}\n", "import { RenderingTaskPriority, renderingTaskQueues } from \"@framerjs/framer-runtime/sandbox\"\nimport { getLogger } from \"@framerjs/shared\"\nimport type { CanvasNode, MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { CodeComponentNode } from \"document/models/CanvasTree/index.ts\"\nimport { debounce } from \"library/render/utils/debounce.ts\"\nimport type { ModulesRuntime } from \"modulesRuntime/ModulesRuntime.ts\"\nimport { unstable_batchedUpdates } from \"react-dom\"\nimport { isUndefined } from \"utils/typeChecks.ts\"\n\nexport type RenderingPhase = \"Normal\" | \"Deferred\" | \"Unknown\"\n\nconst log = getLogger(\"DeferredRendering\")\n\nrenderingTaskQueues.setTaskWrapper(unstable_batchedUpdates)\n\nconst CODE_COMPONENT_PENALTY = 10\nconst MAX_RENDER_BUDGET = 1000\n\nexport class DeferredRendering {\n\trenderingPhase: RenderingPhase = \"Unknown\"\n\tprivate isReadyToRender = false\n\tprivate activeScopeId?: MaybeNodeID\n\n\tprivate nodeResourceCounters: Record<NodeID, number> = {}\n\n\tprivate groundNodeBatches: NodeID[][] = []\n\tprivate mutableNodesDeferredRendering = new Set<NodeID>()\n\tprivate mutableNodesLoadingResources = new Set<NodeID>()\n\n\tnodesDeferredRendering: ReadonlySet<NodeID> = new Set()\n\tnodesLoadingResources: ReadonlySet<NodeID> = new Set()\n\n\t/** Needed to know why a collection is missing. */\n\n\tconstructor(\n\t\tprivate readonly modulesRuntime: ModulesRuntime,\n\t\tprivate readonly renderCanvas: (callback?: () => void) => void,\n\t\tprivate readonly onFinishedLoading: () => void,\n\t) {}\n\n\thasScheduledUpdateCanvas = false\n\tprivate scheduleUpdateCanvas = () => {\n\t\tif (this.hasScheduledUpdateCanvas) return\n\n\t\tthis.hasScheduledUpdateCanvas = true\n\t\tsetTimeout(this.updateCanvas)\n\t}\n\n\tprivate updateCanvas = () => {\n\t\tthis.hasScheduledUpdateCanvas = false\n\n\t\t// Scripts and assets are not ready\n\t\tif (!this.isReadyToRender) return\n\n\t\tthis.prepareNextBatch()\n\t\tthis.nodesDeferredRendering = new Set(this.mutableNodesDeferredRendering)\n\t\tthis.nodesLoadingResources = new Set(this.mutableNodesLoadingResources)\n\n\t\t// First we finish rendering nodes.\n\t\tconst renderingNodes = this.nodesLoadingResources.size > 0 || this.nodesDeferredRendering.size > 0\n\t\tif (renderingNodes) {\n\t\t\trenderingTaskQueues.setPriority(RenderingTaskPriority.Highest)\n\t\t\tthis.renderCanvas(this.scheduleUpdateCanvas)\n\t\t\treturn\n\t\t}\n\n\t\t// Then we drain all the run queues in order of priority.\n\t\tlet priority = renderingTaskQueues.getPriority()\n\t\twhile (priority > RenderingTaskPriority.All && !renderingTaskQueues.hasImmediateTasksToRun()) {\n\t\t\tpriority -= 1\n\t\t\trenderingTaskQueues.setPriority(priority)\n\t\t}\n\t\tif (renderingTaskQueues.hasImmediateTasksToRun()) {\n\t\t\tthis.renderCanvas(this.scheduleUpdateCanvas)\n\t\t\treturn\n\t\t}\n\n\t\t// Then we signal the canvas has loaded.\n\t\tthis.renderingPhase = \"Normal\"\n\t\tlog.debug(\"finished\", this.activeScopeId)\n\t\tthis.renderCanvas(this.onFinishedLoading)\n\t}\n\n\tprivate prepareNextBatch() {\n\t\tconst batch = this.groundNodeBatches.shift()\n\t\tif (batch === undefined) return\n\n\t\tfor (const nodeId of batch) {\n\t\t\tthis.mutableNodesDeferredRendering.delete(nodeId)\n\t\t\tthis.mutableNodesLoadingResources.add(nodeId)\n\t\t}\n\t}\n\n\tprivate batchUpdateResourceLoading = debounce(this.scheduleUpdateCanvas, 200)\n\n\tprivate groundNodeHasLoadedResources(nodeId: NodeID) {\n\t\tdelete this.nodeResourceCounters[nodeId]\n\t\tthis.mutableNodesLoadingResources.delete(nodeId)\n\n\t\t// Don't show nodes if we are still deferring nodes\n\t\tif (this.nodesDeferredRendering.size !== 0) return\n\n\t\tthis.batchUpdateResourceLoading()\n\t}\n\n\tsetReadyToRender(isReadyToRender: boolean) {\n\t\tif (this.isReadyToRender !== isReadyToRender) {\n\t\t\tthis.isReadyToRender = isReadyToRender\n\t\t\tthis.scheduleUpdateCanvas()\n\t\t}\n\t}\n\n\tisLoadingResourcesOrModules(): boolean {\n\t\t// @TODO: We are not handling external modules yet.\n\t\t// Should make sure external modules are handled like module subscriptions.\n\t\treturn this.mutableNodesLoadingResources.size > 0 || this.modulesRuntime.isLoadingSubscriptions()\n\t}\n\n\tprivate createNodeBatches(groundNodes: Set<CanvasNode>, continueBudget = 0): number {\n\t\tlet currentBudget = 0\n\t\tlet currentBatch: NodeID[] = []\n\n\t\t// Try and continue a batch that was created with a different set of canvas nodes.\n\t\tif (continueBudget > 0 && this.groundNodeBatches.length > 0) {\n\t\t\tcurrentBudget = continueBudget\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked\n\t\t\tcurrentBatch = this.groundNodeBatches.pop()!\n\t\t}\n\n\t\tconst finishBatch = () => {\n\t\t\tthis.groundNodeBatches.push(currentBatch)\n\t\t\tcurrentBudget = 0\n\t\t\tcurrentBatch = []\n\t\t}\n\n\t\tfor (const node of groundNodes) {\n\t\t\tif (currentBudget >= MAX_RENDER_BUDGET) {\n\t\t\t\tfinishBatch()\n\t\t\t}\n\n\t\t\tcurrentBudget += getRenderBudget(node)\n\t\t\tcurrentBatch.push(node.id)\n\t\t}\n\n\t\t// Finish the last batch\n\t\tif (currentBatch.length > 0) {\n\t\t\tconst result = currentBudget\n\t\t\tfinishBatch()\n\t\t\treturn result\n\t\t}\n\n\t\treturn 0\n\t}\n\n\tprivate hasGroundNodes = false\n\tsetGroundNodes(groundNodes: CanvasNode[], groundNodeIdsInViewport: Set<NodeID>, scopeId?: MaybeNodeID) {\n\t\t// We want to load resources when switching the scope\n\t\tif (this.activeScopeId !== scopeId) {\n\t\t\tthis.activeScopeId = scopeId\n\t\t\tthis.renderingPhase = \"Deferred\"\n\t\t\tlog.debug(\"switching scope id:\", scopeId)\n\n\t\t\tthis.nodeResourceCounters = {}\n\n\t\t\tthis.groundNodeBatches = []\n\t\t\tthis.mutableNodesDeferredRendering = new Set()\n\t\t\tthis.mutableNodesLoadingResources = new Set()\n\n\t\t\tthis.nodesDeferredRendering = new Set()\n\t\t\tthis.nodesLoadingResources = new Set()\n\n\t\t\tthis.hasGroundNodes = false\n\t\t}\n\n\t\tif (!this.activeScopeId) return\n\n\t\t// As soon as we provide the first set of ground nodes we don't want to create new loading placeholders\n\t\tif (this.hasGroundNodes) return\n\t\tthis.hasGroundNodes = true\n\n\t\t// Document is empty, finish loading immediately\n\t\tif (groundNodes.length === 0) {\n\t\t\tthis.renderingPhase = \"Normal\"\n\t\t\tlog.debug(\"finished\", this.activeScopeId, \"groundNodes.length === 0\")\n\t\t\treturn this.onFinishedLoading()\n\t\t}\n\n\t\tconst nodesInsideViewport = new Set<CanvasNode>()\n\t\tconst nodesOutsideViewport = new Set<CanvasNode>()\n\n\t\tfor (const node of groundNodes) {\n\t\t\tconst nodeId = node.id\n\n\t\t\tthis.nodeResourceCounters[nodeId] = 0\n\t\t\tthis.mutableNodesDeferredRendering.add(nodeId)\n\n\t\t\tconst isInsideViewport = groundNodeIdsInViewport.has(nodeId)\n\n\t\t\tif (isInsideViewport) {\n\t\t\t\tnodesInsideViewport.add(node)\n\t\t\t} else {\n\t\t\t\tnodesOutsideViewport.add(node)\n\t\t\t}\n\t\t}\n\n\t\tthis.nodesDeferredRendering = new Set(this.mutableNodesDeferredRendering)\n\n\t\t// Render nodes inside the viewport first\n\t\tlet budgetLeftOver = this.createNodeBatches(nodesInsideViewport)\n\t\t// Then nodes outside the viewport\n\t\tbudgetLeftOver = this.createNodeBatches(nodesOutsideViewport, budgetLeftOver)\n\n\t\tif (this.groundNodeBatches.length <= 1 && budgetLeftOver < MAX_RENDER_BUDGET) {\n\t\t\t// If there is only one batch, and it is rather light, immediately render it.\n\t\t\tthis.updateCanvas()\n\t\t\treturn\n\t\t}\n\n\t\t// Otherwise, we schedule a render, so we quickly render an empty canvas, clearing the old canvas.\n\t\tthis.scheduleUpdateCanvas()\n\t}\n\n\tprivate shouldTrackResources(nodeId: NodeID) {\n\t\tconst isLoadingResources = this.nodesLoadingResources.has(nodeId)\n\t\tconst isDeferredRendering = this.nodesDeferredRendering.has(nodeId)\n\n\t\treturn isLoadingResources && !isDeferredRendering\n\t}\n\n\ttrackResourceLoading(nodeId: NodeID, load: () => Promise<void>) {\n\t\tconst shouldTrackResources = this.shouldTrackResources(nodeId)\n\n\t\t// TODO: We were asserting here before but we realized this crashes on creating the blog sample.\n\t\t// Created an issue to fix that. After we should add back the assertions.\n\t\tif (shouldTrackResources) {\n\t\t\tconst counter = this.nodeResourceCounters[nodeId] ?? 0\n\t\t\tthis.nodeResourceCounters[nodeId] = counter + 1\n\n\t\t\tconst afterLoading = () => {\n\t\t\t\tif (isUndefined(this.nodeResourceCounters[nodeId])) return\n\t\t\t\tthis.nodeResourceCounters[nodeId]--\n\t\t\t\tthis.checkLoadingState(nodeId)\n\t\t\t}\n\n\t\t\tload().then(afterLoading).catch(afterLoading)\n\t\t}\n\t}\n\n\tcheckLoadingState(nodeId: NodeID) {\n\t\tconst shouldTrackResources = this.shouldTrackResources(nodeId)\n\n\t\tif (shouldTrackResources && this.nodeResourceCounters[nodeId] === 0) {\n\t\t\tthis.groundNodeHasLoadedResources(nodeId)\n\t\t}\n\t}\n}\n\nfunction getRenderBudget(node: CanvasNode) {\n\tlet budget = 1\n\n\tif (node instanceof CodeComponentNode) {\n\t\tbudget += CODE_COMPONENT_PENALTY\n\t}\n\n\tfor (const child of node.children ?? []) {\n\t\tbudget += getRenderBudget(child)\n\t}\n\n\treturn budget\n}\n", "import type { SandboxComponentLoader } from \"@framerjs/framer-runtime/sandbox\"\nimport {\n\tassert,\n\ttype ExternalModuleIdentifierString,\n\ttype LocalModuleIdentifierString,\n\ttype ModuleExportIdentifierString,\n\tgetLogger,\n\tparseModuleIdentifier,\n} from \"@framerjs/shared\"\nimport { SandboxRepeaterData } from \"document/SandboxRepeaterData.ts\"\nimport { SandboxVisibility } from \"document/SandboxVisibility.ts\"\nimport { isStatusGestureVariant } from \"document/components/chrome/properties/utils/gestureStatusVariant.ts\"\nimport { hasLoadMoreActions } from \"document/models/CanvasTree/actions/paginationActions.ts\"\nimport type { CanvasNode, CanvasTree, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { stringFromNodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport type { FetchDataValue } from \"document/models/CanvasTree/traits/FetchDataValue.ts\"\nimport { fillVariablesInURL, patchFetchValue } from \"document/models/CanvasTree/traits/FetchDataValue.ts\"\nimport type {\n\tCombinedVariableProviderControlMap,\n\tCombinedVariableProviderValueMap,\n} from \"document/models/CanvasTree/traits/VariableProvider.ts\"\nimport { hasCollectionDataSourceLoader } from \"document/models/CanvasTree/traits/WithCollectionDataSourceLoader.ts\"\nimport { hasDataLoaderDisabledVariant } from \"document/models/CanvasTree/traits/WithDataLoaderVariants.ts\"\nimport type { WithSize } from \"document/models/CanvasTree/traits/WithSize.ts\"\nimport { withSize } from \"document/models/CanvasTree/traits/WithSize.ts\"\nimport { isCanvasScopeWithVariables } from \"document/models/CanvasTree/traits/WithVariables.ts\"\nimport { isGestureVariant } from \"document/models/CanvasTree/traits/WithVariant.ts\"\nimport type { WithViewport } from \"document/models/CanvasTree/traits/WithViewport.ts\"\nimport { canNodeProvideViewportRect } from \"document/models/CanvasTree/traits/utils/viewportHelpers.ts\"\nimport type { RepeatersShowingEmptyState } from \"document/stores/RepeaterStore.ts\"\nimport { type RenderId, getNodeIdFromRenderId, isPrimaryRenderId } from \"document/utils/RenderId.ts\"\nimport { FetchClient, getRequestCacheKey } from \"library/modules/FetchClient.tsx\"\nimport { QueryCache } from \"library/modules/cms/QueryCache.ts\"\nimport { QueryEngine, type QueryResult } from \"library/modules/cms/QueryEngine.ts\"\nimport type { Query } from \"library/modules/cms/types.ts\"\nimport type { Locale } from \"library/router/types.ts\"\nimport type { ModulesRuntime } from \"modulesRuntime/ModulesRuntime.ts\"\nimport type { DebugRenderingFeatures } from \"./DebugRenderingFeatures.ts\"\nimport { getFetchDataFallbackValue, getFetchDataReturnValue, isValidFetchDataValue } from \"./fetchDataRenderUtils.ts\"\n\n// The CanvasNodeRenderer uses a this state tracker to re-render nodes when their data hasn't\n// changed, but other variables influencing rendering have, like the zoom level, or code component\n// hash, placeholders, viewports, etc.\n//\n// As nodes render, they hook into a state by doing something like this:\n// `node.cache.useRenderingState(\"zoom\")`. They will then re-render when the zoom changes, but not\n// when other rendering states change.\n\n// TODO:\n// - Move variables/controls/locale from props to state.\n\nconst log = getLogger(\"RenderingStateTracker\")\n\ninterface RenderingState {\n\t// Every new state has at least an new update number.\n\tupdate: number\n\n\t// Global rendering properties that might change.\n\tzoom: number\n\tassetHash: number\n\tcomponentLoaderHash: string\n\tcollectionItemId: string | null\n\tcollectionQueryUpdate: number\n\tfetchResultUpdate: number\n\ttokenColorRevision: number\n\tselectionCount: number\n\tpreviewState: \"active\" | \"inactive\"\n}\n\nexport type RenderingStateKeys = keyof RenderingState\ntype RenderingStateCallback = (state: RenderingState) => void\n\nconst DefaultRenderingState: RenderingState = {\n\tupdate: 0,\n\tzoom: 1,\n\tassetHash: 0,\n\tcomponentLoaderHash: \"\",\n\tcollectionItemId: null,\n\tcollectionQueryUpdate: 0,\n\tfetchResultUpdate: 0,\n\ttokenColorRevision: 0,\n\tselectionCount: 0,\n\tpreviewState: \"inactive\",\n}\n\nconst allRenderingStateKeys = Object.keys(DefaultRenderingState) as RenderingStateKeys[]\n\n/** Normally each node renders once, but cms content might repeatedly render the same node, or\n * children of code components might render the same nodes. To signal each such rendering when non\n * node properties change that require rerendering, like the component hash, or zoom level, we track\n * each rendering by assigning a NodeRendering. */\nexport class NodeRendering {\n\t/**\n\t * True if this rendering is directly off the node, and not via cms content, or code component\n\t * child content. Usually the primary renderings is editable, might have placeholders, etc.\n\t */\n\treadonly isPrimary: boolean\n\n\t// Only mutable because we don't want to create a new instance when the ground node changes.\n\tgroundNodeId: NodeID\n\n\tmounted = 1\n\tstates: Set<RenderingStateKeys> | null = null\n\n\t// A small cache for cms repeater items.\n\tcachedControlMap: CombinedVariableProviderControlMap | undefined = undefined\n\tcachedCombinedValueMapPerItem: CombinedVariableProviderValueMap[] | undefined = undefined\n\n\t// Used to store the last query result on the canvas to avoid white flashes\n\t// when changing the query in the properties panel.\n\tcachedQueryResult: QueryResult | undefined = undefined\n\n\t// The error that occurred during the last rendering and was caught by the error boundary.\n\tprivate _lastRenderingError: Error | null = null\n\n\tconstructor(\n\t\treadonly id: RenderId,\n\t\tgroundNodeId: NodeID,\n\t\tpublic callback: RenderingStateCallback,\n\t\tpublic repeaterShowingEmptyState: boolean = false,\n\t) {\n\t\tthis.isPrimary = isPrimaryRenderId(id)\n\t\tthis.groundNodeId = groundNodeId\n\t}\n\n\tget elementId(): string {\n\t\treturn stringFromNodeID(this.id)\n\t}\n\n\tsetLastRenderingError = (error: Error | null) => {\n\t\tthis._lastRenderingError = error\n\t}\n\n\tget lastRenderingError(): Error | null {\n\t\treturn this._lastRenderingError\n\t}\n}\n\nexport class RenderingStateTracker {\n\tstate: RenderingState = DefaultRenderingState\n\tprivate update = 0\n\n\treadonly componentLoader: SandboxComponentLoader\n\n\t/** Used to track mounts and unmounts of CanvasNodeRenderer instances. And used to signal the\n\t * primary rendering of a node directly.\n\t *\n\t * Notice these entries are often by node id, but sometimes a node is rendered more then once on\n\t * the canvas. For example when linked as children of a code component, or when part of a cms\n\t * repeater. Those secondary renderings use a different id computed from the place the node is\n\t * rendered. */\n\tprivate renderingById: Map<RenderId, NodeRendering> = new Map()\n\n\t/** Tracks renders that depend on a certain kind of global rendering state. */\n\tprivate renderingsByStateKey: Map<RenderingStateKeys, Set<NodeRendering>> = new Map()\n\n\t/** Tracks renders that depend on the viewport of their ground node. */\n\tprivate renderingsByViewportProvider: Map<string, Set<NodeRendering>> = new Map()\n\n\t/** Tracks renders that depend on the ground node being in view on the canvas. */\n\tprivate renderingsByGroundNodeInViewport: Map<NodeID, Set<NodeRendering>> = new Map()\n\n\t/** Tracks renders that depend on the node's measured rect */\n\tprivate entriesByNodeRectMeasured: Map<RenderId, Set<NodeRendering>> = new Map()\n\n\t/** Needed when updating variables for a scope node. */\n\treadonly sandboxRepeaterData = new SandboxRepeaterData(\"sandbox\")\n\treadonly sandboxVisibility = new SandboxVisibility(\"sandbox\")\n\n\t/** To selectively disable rendering features for debugging. */\n\tdebugRenderingFeatures?: Partial<DebugRenderingFeatures> = undefined\n\n\tlayoutTemplatesToLoad = new Set<ModuleExportIdentifierString>()\n\tprivate repeatersShowingEmptyState: RepeatersShowingEmptyState = new Set()\n\n\t// When things change, we don't immediately update renderings, we buffer and signal when asked.\n\tprivate nextState: RenderingState = DefaultRenderingState\n\tprivate renderingsToSignal = new Set<NodeRendering>()\n\tprivate renderingsOutsideViewportToSignal = new Set<NodeRendering>()\n\n\tprivate loadingRenderings: Set<RenderId> = new Set()\n\tprivate loadingRenderingsInViewport: Set<RenderId> = new Set()\n\n\t// Can be `undefined` for testing, in which case all ground nodes are considered visible.\n\tprivate groundNodeIdsInViewport: Set<NodeID> | undefined = undefined\n\n\t/** Called once, the first time `loadingRenderingsInViewport` transitions back to empty after\n\t * having been non-empty. Used for loader-timeline diagnostics; never called more than once. */\n\tonFirstIdleAfterLoading?: () => void\n\tprivate hasEverHadLoadingInViewport = false\n\tprivate hasNotifiedFirstIdleAfterLoading = false\n\n\tconstructor(readonly modulesRuntime: ModulesRuntime) {\n\t\tthis.componentLoader = modulesRuntime.componentLoader\n\t}\n\n\tisLoading() {\n\t\treturn this.loadingRenderingsInViewport.size > 0\n\t}\n\n\tprivate notifyFirstIdleAfterLoadingIfReady(): void {\n\t\tif (this.hasNotifiedFirstIdleAfterLoading) return\n\t\tif (!this.hasEverHadLoadingInViewport) return\n\t\tif (this.loadingRenderingsInViewport.size !== 0) return\n\t\tthis.hasNotifiedFirstIdleAfterLoading = true\n\t\tthis.onFirstIdleAfterLoading?.()\n\t}\n\n\ttrackLoading(id: RenderId): void {\n\t\tconst rendering = this.renderingById.get(id)\n\t\tif (!rendering) return\n\n\t\tthis.loadingRenderings.add(id)\n\n\t\tconst inViewport = this.groundNodeIdsInViewport?.has(rendering.groundNodeId) ?? true\n\t\tif (inViewport) {\n\t\t\tthis.loadingRenderingsInViewport.add(id)\n\t\t\tthis.hasEverHadLoadingInViewport = true\n\t\t}\n\t}\n\n\ttrackLoaded(id: RenderId): void {\n\t\tthis.loadingRenderings.delete(id)\n\t\tthis.loadingRenderingsInViewport.delete(id)\n\t\tthis.notifyFirstIdleAfterLoadingIfReady()\n\t}\n\n\t/** Every call with a *different* callback should be balanced with an unmount. This is done in\n\t * this weird way to support both production react and react in strict and dev mode. */\n\trenderingInstanceFor(renderId: RenderId, groundNodeId: NodeID, callback: RenderingStateCallback): NodeRendering {\n\t\tlet rendering = this.renderingById.get(renderId)\n\t\tif (!rendering) {\n\t\t\tlog.trace(\"new rendering:\", renderId)\n\t\t\tconst nodeId = getNodeIdFromRenderId(renderId)\n\t\t\tconst repeaterShowingEmptyState = this.repeatersShowingEmptyState.has(nodeId)\n\t\t\trendering = new NodeRendering(renderId, groundNodeId, callback, repeaterShowingEmptyState)\n\t\t\tthis.renderingById.set(renderId, rendering)\n\t\t} else if (rendering.callback !== callback) {\n\t\t\t// In react debug mode it will run the render method twice\n\t\t\tlog.trace(\"updating existing rendering:\", renderId)\n\t\t\trendering.callback = callback\n\t\t\trendering.mounted += 1\n\t\t} else {\n\t\t\tlog.trace(\"same rendering:\", renderId)\n\t\t}\n\t\trendering.groundNodeId = groundNodeId\n\t\treturn rendering\n\t}\n\n\tunmount(rendering: NodeRendering) {\n\t\tlog.trace(\"unmount:\", rendering.id, rendering.mounted)\n\t\trendering.mounted -= 1\n\t\tif (rendering.mounted > 0) return\n\n\t\t// if we are unmounting the primary rendering,\n\t\t// we need to mark the node as loaded, so it doesn't count as a loading node anymore\n\t\tthis.trackLoaded(rendering.id)\n\n\t\t// Remove this rendering from all indexes it can appear in.\n\t\tthis.renderingById.delete(rendering.id)\n\t\tthis.renderingsByViewportProvider.delete(rendering.id)\n\t\tthis.entriesByNodeRectMeasured.delete(rendering.id)\n\t\tthis.renderingsOutsideViewportToSignal.delete(rendering)\n\n\t\tfor (const renderings of this.renderingsByGroundNodeInViewport.values()) {\n\t\t\trenderings.delete(rendering)\n\t\t}\n\n\t\tfor (const renderings of this.renderingsByStateKey.values()) {\n\t\t\trenderings.delete(rendering)\n\t\t}\n\t\tfor (const renderings of this.renderingsByViewportProvider.values()) {\n\t\t\trenderings.delete(rendering)\n\t\t}\n\n\t\tfor (const entries of this.entriesByNodeRectMeasured.values()) {\n\t\t\tentries.delete(rendering)\n\t\t}\n\t}\n\n\tprivate startNextStateIfNeeded() {\n\t\tif (this.nextState.update > this.update) return\n\t\tthis.nextState = { ...this.state, update: this.update + 1 }\n\t}\n\n\t/** Flag that some global rendering state has changed. Does nothing when the new properties are\n\t * the same as the old properties. */\n\tupdateState(partialState: Partial<RenderingState>) {\n\t\tfor (const key of allRenderingStateKeys) {\n\t\t\tconst newValue = partialState[key]\n\t\t\tif (!newValue) continue\n\t\t\tif (this.nextState[key] === newValue) continue\n\n\t\t\tthis.startNextStateIfNeeded()\n\t\t\t;(this.nextState as any)[key] = newValue\n\t\t}\n\t}\n\n\t/** Flag that the primary rendering of a node should re-render. Used for insertion rects, hiding\n\t * nodes while vekter edits them, and such. */\n\tupdateRendering(renderId: RenderId) {\n\t\tconst rendering = this.renderingById.get(renderId)\n\t\tif (!rendering) return\n\n\t\tthis.startNextStateIfNeeded()\n\t\tthis.renderingsToSignal.add(rendering)\n\t}\n\n\t/**\n\t * Flags all renderings associated with the given node for re-rendering. This method should be\n\t * used when multiple renderings of a node need to be updated, such as when a change affects all\n\t * instances of the node. Use `updateRendering` instead if only the primary rendering needs to\n\t * be updated.\n\t */\n\tupdateAllRenderingsForNode(nodeId: NodeID) {\n\t\tthis.startNextStateIfNeeded()\n\n\t\tfor (const [renderId, rendering] of this.renderingById) {\n\t\t\tconst renderingNodeId = getNodeIdFromRenderId(renderId)\n\t\t\tif (renderingNodeId !== nodeId) continue\n\n\t\t\tthis.renderingsToSignal.add(rendering)\n\t\t}\n\t}\n\n\tupdateAllNodes() {\n\t\tthis.startNextStateIfNeeded()\n\t\tfor (const rendering of this.renderingById.values()) {\n\t\t\tthis.renderingsToSignal.add(rendering)\n\t\t}\n\t}\n\n\tprivate updateRepeaterShowingEmptyState(nodeId: NodeID, empty: boolean) {\n\t\tthis.startNextStateIfNeeded()\n\n\t\tfor (const [renderId, rendering] of this.renderingById) {\n\t\t\tconst renderingNodeId = getNodeIdFromRenderId(renderId)\n\t\t\tif (nodeId === renderingNodeId) {\n\t\t\t\trendering.repeaterShowingEmptyState = empty\n\t\t\t\tthis.renderingsToSignal.add(rendering)\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateRepeatersShowingEmptyState(newRepeaters: RepeatersShowingEmptyState, tree: CanvasTree) {\n\t\tconst previousRepeaters = this.repeatersShowingEmptyState\n\n\t\tfor (const nodeId of newRepeaters) {\n\t\t\tif (!previousRepeaters.has(nodeId)) {\n\t\t\t\tthis.updateRepeaterShowingEmptyState(nodeId, true)\n\t\t\t\tthis.updateLoadersForRepeater(nodeId, tree)\n\t\t\t}\n\t\t}\n\n\t\tfor (const nodeId of previousRepeaters) {\n\t\t\tif (!newRepeaters.has(nodeId)) {\n\t\t\t\tthis.updateRepeaterShowingEmptyState(nodeId, false)\n\t\t\t\tthis.updateLoadersForRepeater(nodeId, tree)\n\t\t\t}\n\t\t}\n\n\t\tthis.repeatersShowingEmptyState = newRepeaters\n\t}\n\n\tprivate updateLoadersForRepeater(repeaterId: NodeID, tree: CanvasTree) {\n\t\tconst repeater = tree.get(repeaterId)\n\t\tif (!repeater) return\n\n\t\t// Infinite Scroll: connected via dataSourceLoaderId\n\t\tif (hasCollectionDataSourceLoader(repeater)) {\n\t\t\tthis.updateAllRenderingsForNode(repeater.dataSourceLoaderId)\n\t\t}\n\n\t\t// Load More: find descendants with load more actions and disabled variant configured\n\t\tfor (const descendant of repeater.walk()) {\n\t\t\tif (hasDataLoaderDisabledVariant(descendant) && hasLoadMoreActions(this.componentLoader, descendant)) {\n\t\t\t\t// Note: Since we don't stop the walk on nested repeaters, this might update nested load more buttons unrelated to our repeater.\n\t\t\t\t// Since it's just causing a rerender and a rare edge case, that's fine.\n\t\t\t\tthis.updateAllRenderingsForNode(descendant.id)\n\t\t\t}\n\t\t}\n\t}\n\n\tisRepeaterShowingEmptyState(nodeId: NodeID): boolean {\n\t\treturn this.repeatersShowingEmptyState.has(nodeId)\n\t}\n\n\tupdateGroundNodeIdsInViewport(groundNodeIdsInViewport: Set<NodeID>) {\n\t\tfor (const groundNodeId of groundNodeIdsInViewport) {\n\t\t\tconst renderings = this.renderingsByGroundNodeInViewport.get(groundNodeId)\n\t\t\tif (!renderings || renderings.size === 0) continue\n\n\t\t\t// if the ground node was already in the viewport, skip\n\t\t\tif (this.groundNodeIdsInViewport?.has(groundNodeId)) continue\n\n\t\t\tthis.startNextStateIfNeeded()\n\t\t\tfor (const rendering of renderings) {\n\t\t\t\tthis.renderingsToSignal.add(rendering)\n\t\t\t}\n\t\t}\n\n\t\tthis.groundNodeIdsInViewport = groundNodeIdsInViewport\n\n\t\t// Recalculate which loading renderings are in viewport\n\t\tthis.loadingRenderingsInViewport.clear()\n\t\tfor (const renderingId of this.loadingRenderings) {\n\t\t\tconst rendering = this.renderingById.get(renderingId)\n\t\t\tif (!rendering) continue\n\n\t\t\tconst inViewport = groundNodeIdsInViewport.has(rendering.groundNodeId)\n\t\t\tif (inViewport) {\n\t\t\t\tthis.loadingRenderingsInViewport.add(renderingId)\n\t\t\t\tthis.hasEverHadLoadingInViewport = true\n\t\t\t}\n\t\t}\n\t\tthis.notifyFirstIdleAfterLoadingIfReady()\n\t}\n\n\t/** Signal all nodes that should re-render due to state changes, viewport changes, or direct\n\t * node updates. Should be called while starting to render. */\n\tsignalChanges(groundNodes: CanvasNode[], scope?: CanvasNode | null) {\n\t\t// TODO: this can be cleaned up when we remove the old renderer. Then renderElement can pass\n\t\t// in the scope.\n\t\tconst variablesChanged = isCanvasScopeWithVariables(scope) && scope.hasUpdatedVariablesForStateTracker()\n\t\tfor (const groundNode of groundNodes) {\n\t\t\tif (variablesChanged) {\n\t\t\t\tthis.scheduleNode(groundNode)\n\t\t\t}\n\t\t\tif (!canNodeProvideViewportRect(groundNode) || !withSize(groundNode)) continue\n\t\t\tthis.scheduleNodesForViewportChanges(groundNode)\n\t\t}\n\t\tthis.scheduleNodesForStateChanges()\n\n\t\t// No changes to signal\n\t\tif (this.nextState.update === this.update) {\n\t\t\tassert(this.renderingsToSignal.size === 0, \"No changes, yet there are renderings to signal?\")\n\t\t}\n\n\t\tfor (const invisible of this.renderingsOutsideViewportToSignal) {\n\t\t\tconst inViewport = this.groundNodeIdsInViewport?.has(invisible.groundNodeId) ?? true\n\t\t\tif (inViewport) {\n\t\t\t\tthis.renderingsToSignal.add(invisible)\n\t\t\t\tthis.renderingsOutsideViewportToSignal.delete(invisible)\n\t\t\t}\n\t\t}\n\n\t\tif (this.renderingsToSignal.size === 0) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.update = this.nextState.update\n\t\tthis.state = this.nextState\n\t\tfor (const rendering of this.renderingsToSignal) {\n\t\t\tconst inViewport = this.groundNodeIdsInViewport?.has(rendering.groundNodeId) ?? true\n\t\t\tif (inViewport) {\n\t\t\t\trendering.callback(this.nextState)\n\t\t\t} else {\n\t\t\t\tthis.renderingsOutsideViewportToSignal.add(rendering)\n\t\t\t}\n\t\t}\n\t\tlog.trace(\"updateState:\", this.renderingsToSignal.size, \"/\", this.renderingById.size, this.state)\n\t\tthis.renderingsToSignal.clear()\n\t}\n\n\tprivate scheduleNodesForStateChanges(): void {\n\t\tfor (const key of allRenderingStateKeys) {\n\t\t\tconst newValue = this.nextState[key]\n\t\t\tif (this.state[key] === newValue) continue\n\n\t\t\tthis.scheduleNodes(this.renderingsByStateKey.get(key))\n\t\t}\n\t}\n\n\tprivate scheduleNodesForViewportChanges(groundNode: CanvasNode & WithViewport & WithSize): void {\n\t\tif (\n\t\t\tgroundNode.cache.viewportHeight === groundNode.viewportHeight &&\n\t\t\tgroundNode.cache.height === groundNode.height &&\n\t\t\tgroundNode.cache.width === groundNode.width\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\tgroundNode.cache.width = groundNode.width\n\t\tgroundNode.cache.height = groundNode.height\n\t\tgroundNode.cache.viewportHeight = groundNode.viewportHeight\n\n\t\tthis.startNextStateIfNeeded()\n\t\tthis.scheduleNodes(this.renderingsByViewportProvider.get(groundNode.id))\n\t}\n\n\tprivate scheduleNode(node: CanvasNode) {\n\t\tconst rendering = this.renderingById.get(node.id)\n\t\tif (!rendering) return\n\n\t\tthis.startNextStateIfNeeded()\n\t\tthis.renderingsToSignal.add(rendering)\n\t}\n\n\tprivate scheduleNodes(renderings: Set<NodeRendering> | undefined): void {\n\t\tif (!renderings) return\n\n\t\tfor (const rendering of renderings) {\n\t\t\tthis.renderingsToSignal.add(rendering)\n\t\t}\n\t}\n\n\t/** Flags that this rendering depends on the ground node viewport. */\n\tuseViewport(rendering: NodeRendering, groundNodeId: string) {\n\t\tlet renderings = this.renderingsByViewportProvider.get(groundNodeId)\n\t\tif (!renderings) {\n\t\t\trenderings = new Set()\n\t\t\tthis.renderingsByViewportProvider.set(groundNodeId, renderings)\n\t\t}\n\t\trenderings.add(rendering)\n\t}\n\n\t/** Flags that this rendering depends on the ground node being in view on the canvas */\n\tuseGroundNodeInViewport(rendering: NodeRendering, groundNodeId: NodeID) {\n\t\tlet renderings = this.renderingsByGroundNodeInViewport.get(groundNodeId)\n\t\tif (!renderings) {\n\t\t\trenderings = new Set()\n\t\t\tthis.renderingsByGroundNodeInViewport.set(groundNodeId, renderings)\n\t\t}\n\t\trenderings.add(rendering)\n\t}\n\n\tclearEntriesByNodeRectMeasured() {\n\t\tlog.trace(\"clearEntriedByNodeRectMeasured\", this.entriesByNodeRectMeasured.size)\n\t\tthis.entriesByNodeRectMeasured.clear()\n\t}\n\n\tprocessNodesWithChangedRects(renderIds: Set<RenderId>) {\n\t\tif (this.entriesByNodeRectMeasured.size === 0) return\n\n\t\tconst affectedEntries: Set<NodeRendering> = new Set()\n\t\tfor (const renderId of renderIds) {\n\t\t\tconst entries = this.entriesByNodeRectMeasured.get(renderId)\n\t\t\tif (!entries) continue\n\n\t\t\tfor (const entry of entries) {\n\t\t\t\taffectedEntries.add(entry)\n\t\t\t}\n\t\t}\n\n\t\tif (affectedEntries.size === 0) return\n\t\tthis.updateNodeRect(affectedEntries)\n\t}\n\n\tupdateNodeRect(renderings: Set<NodeRendering>) {\n\t\tthis.startNextStateIfNeeded()\n\t\tfor (const rendering of renderings) {\n\t\t\tthis.renderingsToSignal.add(rendering)\n\t\t}\n\t}\n\n\t/** Signals that a rendering depends on another node's rect */\n\tuseNodeRect(entry: NodeRendering, renderIds: Set<RenderId>) {\n\t\tfor (const renderId of renderIds) {\n\t\t\tif (!renderId) continue\n\n\t\t\tlet renderings = this.entriesByNodeRectMeasured.get(renderId)\n\t\t\tif (!renderings) {\n\t\t\t\trenderings = new Set()\n\t\t\t\tthis.entriesByNodeRectMeasured.set(renderId, renderings)\n\t\t\t}\n\t\t\trenderings.add(entry)\n\t\t}\n\t}\n\n\t/** Update the states that were used to render. */\n\tuseStates(rendering: NodeRendering, states: Set<RenderingStateKeys> | null) {\n\t\tconst previous = rendering.states\n\t\trendering.states = states\n\n\t\tif (states) {\n\t\t\tfor (const state of states) {\n\t\t\t\tconst alreadyTracking = previous ? previous.delete(state) : false\n\t\t\t\tif (alreadyTracking) continue\n\t\t\t\tthis.addRenderingToState(state, rendering)\n\t\t\t}\n\t\t}\n\n\t\tif (previous) {\n\t\t\tfor (const state of previous) {\n\t\t\t\tthis.removeRenderingFromState(state, rendering)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addRenderingToState(key: RenderingStateKeys, rendering: NodeRendering) {\n\t\tlet renderings = this.renderingsByStateKey.get(key)\n\t\tif (!renderings) {\n\t\t\trenderings = new Set()\n\t\t\tthis.renderingsByStateKey.set(key, renderings)\n\t\t}\n\t\trenderings.add(rendering)\n\t}\n\n\tprivate removeRenderingFromState(key: RenderingStateKeys, rendering: NodeRendering) {\n\t\tthis.renderingsByStateKey.get(key)?.delete(rendering)\n\t}\n\n\treadonly queryEngine = new QueryEngine()\n\treadonly queryCache = new QueryCache(this.queryEngine, 500)\n\n\tprivate readonly fetchClient = new FetchClient()\n\tprivate readonly seenFetchResults = new WeakSet<object>()\n\tprivate loadingModules = new Map<LocalModuleIdentifierString, VoidFunction | undefined>()\n\tprivate waitingForCollections = 0\n\n\tisWaitingForCollections() {\n\t\treturn this.waitingForCollections !== 0\n\t}\n\n\tisWaitingForLayoutTemplates() {\n\t\treturn this.layoutTemplatesToLoad.size > 0\n\t}\n\n\tqueryCollection(rendering: NodeRendering, query: Query, locale: Locale | undefined) {\n\t\tconst cachedQuery = this.queryCache.get(query, locale)\n\t\tconst promise = cachedQuery.preload()\n\n\t\tif (promise) {\n\t\t\tthis.waitingForCollections++\n\n\t\t\tvoid promise.finally(() => {\n\t\t\t\tthis.updateState({\n\t\t\t\t\tcollectionQueryUpdate: this.state.collectionQueryUpdate + 1,\n\t\t\t\t})\n\n\t\t\t\tthis.signalChanges([])\n\n\t\t\t\tthis.waitingForCollections--\n\t\t\t})\n\t\t} else {\n\t\t\trendering.cachedQueryResult = cachedQuery.read()\n\t\t}\n\n\t\treturn rendering.cachedQueryResult\n\t}\n\n\tisWaitingForModules() {\n\t\treturn this.loadingModules.size > 0\n\t}\n\n\tloadLocalModule(identifier: LocalModuleIdentifierString, renderId: RenderId) {\n\t\tif (this.loadingModules.has(identifier)) return\n\n\t\tconst unsubscribeToLocalModuleExports = this.modulesRuntime.subscribeToLocalModuleExports(identifier, () => {\n\t\t\t// We need to trigger a rerender on the node that is waiting for this module to load.\n\t\t\tthis.updateRendering(renderId)\n\t\t\tthis.signalChanges([])\n\n\t\t\tconst unsubscribe = this.loadingModules.get(identifier)\n\t\t\tif (unsubscribe) unsubscribe()\n\n\t\t\tthis.loadingModules.delete(identifier)\n\t\t})\n\n\t\tthis.loadingModules.set(identifier, unsubscribeToLocalModuleExports)\n\t}\n\n\tasync waitForExternalModule(identifier: ExternalModuleIdentifierString, renderId: RenderId) {\n\t\tconst parsedIdentifier = parseModuleIdentifier(identifier)\n\t\tawait this.modulesRuntime.ensureExternalModuleLoaded(parsedIdentifier)\n\n\t\tthis.updateRendering(renderId)\n\t\tthis.signalChanges([])\n\t}\n\n\tprivate waitingForFetchValueToResolve = 0\n\n\tisWaitingForFetchValueToResolve() {\n\t\treturn this.waitingForFetchValueToResolve !== 0\n\t}\n\n\tcreateFetchDataValueResolver(node: CanvasNode) {\n\t\t// biome-ignore lint/correctness/useHookAtTopLevel: This is not a hook.\n\t\tnode.cache.useRenderingState(\"fetchResultUpdate\")\n\n\t\tconst signalStateChange = () => {\n\t\t\tthis.updateState({\n\t\t\t\tfetchResultUpdate: this.state.fetchResultUpdate + 1,\n\t\t\t})\n\t\t\tthis.signalChanges([])\n\t\t}\n\n\t\treturn (value: FetchDataValue) => {\n\t\t\tconst safeValue = patchFetchValue(value)\n\n\t\t\tconst fallbackValue = getFetchDataFallbackValue(node, safeValue.controlProp)\n\n\t\t\tif (!isValidFetchDataValue(safeValue)) {\n\t\t\t\treturn fallbackValue\n\t\t\t}\n\n\t\t\tconst groundNode = node.tree()?.getGroundNodeFor(node)\n\t\t\t// For Loading or Error variants we always display the fallback value.\n\t\t\tif (groundNode && isGestureVariant(groundNode) && isStatusGestureVariant(groundNode.gesture)) {\n\t\t\t\treturn fallbackValue\n\t\t\t}\n\n\t\t\tconst url = fillVariablesInURL(value, variable => String(node.cache.getVariableReferenceValue(variable)))\n\n\t\t\tconst cacheKey = getRequestCacheKey({ url, credentials: value.credentials })\n\t\t\tconst fetchValue = this.fetchClient.getValue(cacheKey)\n\n\t\t\tif (!fetchValue) {\n\t\t\t\tthis.waitingForFetchValueToResolve++\n\n\t\t\t\tvoid this.fetchClient\n\t\t\t\t\t.fetchWithCache({\n\t\t\t\t\t\turl: url,\n\t\t\t\t\t\tcacheDuration: value.cacheDuration,\n\t\t\t\t\t\tcredentials: value.credentials,\n\t\t\t\t\t})\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tthis.waitingForFetchValueToResolve--\n\n\t\t\t\t\t\tsignalStateChange()\n\t\t\t\t\t})\n\n\t\t\t\treturn fallbackValue\n\t\t\t}\n\n\t\t\tif (!this.seenFetchResults.has(fetchValue)) {\n\t\t\t\tthis.seenFetchResults.add(fetchValue)\n\t\t\t\tvoid Promise.resolve().then(signalStateChange)\n\t\t\t}\n\n\t\t\treturn getFetchDataReturnValue(node, safeValue, fetchValue)\n\t\t}\n\t}\n\n\tgetRenderingErrorForNode(nodeId: NodeID): Error | null {\n\t\treturn this.renderingById.get(nodeId)?.lastRenderingError ?? null\n\t}\n}\n", "/**\n * Vekter based debounce function that schedule 2 timers.\n * One timer is scheduled for one frame long / idles while .\n *\n * @see engine.scheduler.debounce\n */\nexport function multiTimerDebounce<T extends unknown[]>(fn: (...args: T) => void, timer: number) {\n\tconst minimumDelay = 60\n\tconst lastUpdateEndTime = performance.now()\n\t// biome-ignore lint/suspicious/noExplicitAny: @TODO add explanation\n\tlet timeout: any = 0\n\n\tconst handler = (...args: T) => {\n\t\tif (performance.now() - lastUpdateEndTime > minimumDelay) {\n\t\t\ttimeout = undefined\n\t\t\tfn(...args)\n\t\t} else {\n\t\t\ttimeout = setTimeout(handler, minimumDelay, ...args)\n\t\t}\n\t}\n\n\treturn (...args: T) => {\n\t\tif (timeout) clearTimeout(timeout)\n\t\ttimeout = setTimeout(handler, timer, ...args)\n\t}\n}\n", "import type { CanvasTree, NodeID, RichTextNode } from \"document/models/CanvasTree/index.ts\"\nimport { isRichTextNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\n\nconst wordCharacterRegex = /[\\p{L}\\p{N}]/u\n\nfunction isWordCharacter(character: string | undefined): boolean {\n\treturn Boolean(character && wordCharacterRegex.test(character))\n}\n\nfunction hasMidWordRenderedWrap(textNode: ChildNode): boolean {\n\tif (textNode.nodeType !== Node.TEXT_NODE) return false\n\tconst text = textNode.textContent\n\tif (!text) return false\n\n\tconst range = document.createRange()\n\n\ttry {\n\t\t// Scan contiguous word runs and only read layout at each run's first and last character.\n\t\tfor (let index = 0; index < text.length; index++) {\n\t\t\tif (!isWordCharacter(text.at(index))) continue\n\t\t\tconst wordStartIndex = index\n\t\t\twhile (index + 1 < text.length && isWordCharacter(text.at(index + 1))) {\n\t\t\t\tindex += 1\n\t\t\t}\n\t\t\tconst wordEndIndex = index\n\n\t\t\trange.setStart(textNode, 0)\n\t\t\trange.setEnd(textNode, wordStartIndex + 1)\n\t\t\tconst wordStartLineIndex = range.getClientRects().length - 1\n\n\t\t\trange.setStart(textNode, 0)\n\t\t\trange.setEnd(textNode, wordEndIndex + 1)\n\t\t\tconst wordEndLineIndex = range.getClientRects().length - 1\n\n\t\t\t// `-1` means the browser produced no visual rects (e.g. collapsed/hidden text).\n\t\t\tif (wordStartLineIndex < 0 || wordEndLineIndex < 0) continue\n\t\t\tif (wordStartLineIndex !== wordEndLineIndex) return true\n\t\t}\n\t} catch {\n\t\treturn false\n\t}\n\n\treturn false\n}\n\nfunction hasMidWordWrapInRichTextNode(node: RichTextNode): boolean {\n\t// Use the rendered DOM snapshot for this node id; without a rendered element we cannot reason\n\t// about visual line breaks, so we conservatively report no issue.\n\tconst renderedElement = node.cache.elementByRenderId?.get(node.id)\n\tif (!(renderedElement instanceof Element)) return false\n\n\t// Traverse only text nodes; inline markup boundaries are ignored so wrap detection operates on\n\t// the actual rendered text runs the browser lays out.\n\tconst walker = document.createTreeWalker(renderedElement, NodeFilter.SHOW_TEXT)\n\tlet currentNode = walker.nextNode()\n\twhile (currentNode) {\n\t\t// Early return on first problematic text run to keep this check linear and cheap in practice.\n\t\tif (currentNode instanceof Text && hasMidWordRenderedWrap(currentNode)) return true\n\t\tcurrentNode = walker.nextNode()\n\t}\n\n\treturn false\n}\n\nexport function checkTextWordBreakForRichTextNodes(tree: CanvasTree, ids: NodeID[]): NodeID[] {\n\tconst nodes = tree.getNodesWithTrait(ids, isRichTextNode)\n\tconst result: NodeID[] = []\n\tfor (const node of nodes) {\n\t\tif (hasMidWordWrapInRichTextNode(node)) result.push(node.id)\n\t}\n\treturn result\n}\n", "import type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { CodeComponentNode } from \"document/models/CanvasTree/index.ts\"\nimport { stringFromNodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { getMeasurableCodeComponentChildren } from \"library/render/utils/getMeasurableCodeComponentChildren.ts\"\nimport { LayoutMeasureQueue } from \"./LayoutMeasureQueue.ts\"\n\n/**\n * A helper that creates a measure queue for a set of nodes that have already\n * been rendered (i.e. have an HTML element in the document that represents that\n * node)\n * @param nodes\n */\nexport function measureQueueForRenderedNodes(nodes: CanvasNode[]) {\n\tconst queue = new LayoutMeasureQueue()\n\tfor (const node of nodes) {\n\t\tconst element = document.getElementById(stringFromNodeID(node.id))\n\t\tif (!element) continue\n\n\t\tqueue.add(node.id, element, htmlChildrenForRenderedNode(node, element))\n\t}\n\treturn queue\n}\n\n/**\n * Returns the HTML children that should be used in content size calculation for\n * a specific node. The returned result should be the same as the result of the\n * `GetChildrenFn` specified in the `useMeasureLayout` hook:\n * https://github.com/framer/FramerStudio/blob/master/src/library/src/render/utils/useMeasureLayout.ts#L12\n *\n * Note: only used for code components at the moment, because they're the only\n * node that needs on-demand measurements for \"Fit Content\". If other nodes need to support the\n * same functionality, they'll need their own logic in this function (e.g.\n * measuring stack children by skipping over the stack gap wrapper).\n *\n * @param node\n * @param element the rendered HTML element representing this node\n */\nfunction htmlChildrenForRenderedNode(node: CanvasNode, element: Element): Element[] {\n\tif (node instanceof CodeComponentNode) {\n\t\treturn getMeasurableCodeComponentChildren(element)\n\t}\n\n\treturn []\n}\n", "import { getCompatibleNonNullLocalizedValue } from \"document/components/chrome/localization/getCompatibleLocalizedValue.ts\"\nimport { getLocalizationSourceTextType } from \"document/components/chrome/localization/getLocalizationSourceTextType.ts\"\nimport { getStyledLocalizedRichTextHTML } from \"document/components/chrome/localization/getStyledLocalizedRichTextHTML.ts\"\nimport { CanvasTree, type NodeID, type RichTextNode } from \"document/models/CanvasTree/index.ts\"\nimport { nodeIDFromString } from \"document/models/CanvasTree/index.ts\"\nimport { defaultLocaleId } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { sizeConstraintsDefaults } from \"document/models/CanvasTree/traits/WithSizeConstraints.ts\"\nimport { DimensionType } from \"library/render/types/Constraints.ts\"\nimport type React from \"react\"\nimport { useLayoutEffect } from \"react\"\nimport { createRoot } from \"react-dom/client\"\nimport { CanvasNodeRenderer } from \"renderer/CanvasNodeRenderer.tsx\"\nimport type { RenderingStateTracker } from \"renderer/RenderingStateTracker.ts\"\nimport { getId } from \"utils/getId.ts\"\n\nexport interface ViewBoxMeasurement {\n\tnodeId: string\n\tlocaleId?: string\n\twidth: number\n\theight: number\n}\n\nfunction RichTextContainer({ resolve, children }: React.PropsWithChildren<{ resolve: () => void }>) {\n\tuseLayoutEffect(resolve)\n\treturn <>{children}</>\n}\n\n/**\n * To safely measure the size of rich text to capture its view box, we render\n * each requested node outside of a canvas in a new hidden React root. This\n * allows measurements to skip the canvas sandbox cycle and not impact other\n * aspects of the editor.\n */\nexport async function viewBoxMeasurementsForRichTextNodes(\n\ttracker: RenderingStateTracker,\n\ttree: CanvasTree,\n\tids: NodeID[],\n): Promise<ViewBoxMeasurement[]> {\n\tconst container = document.createElement(\"div\")\n\tcontainer.style.visibility = \"hidden\"\n\tcontainer.style.position = \"absolute\"\n\tcontainer.style.pointerEvents = \"none\"\n\tdocument.body.appendChild(container)\n\n\tconst root = createRoot(container)\n\tconst localesIds = [defaultLocaleId, ...(tree.root.locales ?? []).map(getId)]\n\n\tconst elements: React.ReactElement[] = []\n\n\tconst renderTree = CanvasTree.createWithRouteSegmentRoot()\n\n\tfor (const nodeId of ids) {\n\t\tconst node = tree.get<RichTextNode>(nodeId)\n\t\tif (!node) continue\n\n\t\tconst textType = getLocalizationSourceTextType(node.html)\n\n\t\tfor (const localeId of localesIds) {\n\t\t\tlet html = node.html\n\n\t\t\tif (localeId !== defaultLocaleId) {\n\t\t\t\tconst localizedValue = getCompatibleNonNullLocalizedValue(textType, node.htmlLocalized?.[localeId], html)\n\n\t\t\t\t// If there is no localized value we don't need to measure the\n\t\t\t\t// text because we want to fallback to the size of the fallback\n\t\t\t\t// locale.\n\t\t\t\tif (!localizedValue) continue\n\n\t\t\t\thtml = getStyledLocalizedRichTextHTML(node.html, localizedValue)\n\t\t\t}\n\n\t\t\tconst clone = node.clone({\n\t\t\t\t...sizeConstraintsDefaults,\n\t\t\t\ttextFitViewBoxSize: undefined,\n\t\t\t\twidthType: DimensionType.Auto,\n\t\t\t\theightType: DimensionType.Auto,\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\t// This ID needs to be unique because this node will exist among\n\t\t\t\t// other real nodes in the sandbox.\n\t\t\t\tid: `${nodeId}-${localeId}`,\n\t\t\t\thtml,\n\t\t\t})\n\n\t\t\trenderTree.insertNode(clone, renderTree.root.id)\n\n\t\t\telements.push(\n\t\t\t\t<CanvasNodeRenderer\n\t\t\t\t\ttracker={tracker}\n\t\t\t\t\tnode={clone}\n\t\t\t\t\tparent={renderTree.root}\n\t\t\t\t\tparentRenderId={renderTree.root.id}\n\t\t\t\t\tgroundNodeId={clone.id}\n\t\t\t\t\toptionalSelectedCollectionItemId={undefined}\n\t\t\t\t/>,\n\t\t\t)\n\t\t}\n\t}\n\n\tawait new Promise<void>(resolve => {\n\t\troot.render(<RichTextContainer resolve={resolve}>{elements}</RichTextContainer>)\n\t})\n\n\tconst measurements: ViewBoxMeasurement[] = []\n\n\tfor (const element of container.children) {\n\t\tconst { clientWidth: width, clientHeight: height, id } = element\n\t\tconst [nodeId, localeId] = nodeIDFromString(id).split(\"-\", 2)\n\n\t\tmeasurements.push({ nodeId, localeId, width, height })\n\t}\n\n\troot.unmount()\n\tdocument.body.removeChild(container)\n\n\treturn measurements\n}\n", "import type { Patch } from \"@framerjs/app-shared/src/lib/immer.ts\"\nimport { AssetMap } from \"@framerjs/assets\"\nimport { environment } from \"@framerjs/framer-environment\"\nimport { waitUntilPlaceholdersSettled } from \"@framerjs/framer-runtime/components/RenderPlaceholder\"\nimport { type SandboxEntityDefinition, renderingTaskQueues } from \"@framerjs/framer-runtime/sandbox\"\nimport type { Assets, ModulesUpdates } from \"@framerjs/framer-services\"\nimport {\n\ttype ExternalModuleBareIdentifierString,\n\tassert,\n\tdebounce,\n\tgetLogger,\n\tgetServiceMap,\n\tResolvablePromise,\n\tsetLogLevel,\n\tsetLogTimestamps,\n\tunhandledError,\n} from \"@framerjs/shared\"\nimport type { FlagsUpdates, FlagsValues } from \"app/FlagsUpdater.ts\"\nimport { employeesOnlySettings } from \"app/employeesOnlySettings.ts\"\nimport { experiments } from \"app/experiments.ts\"\nimport { projectFeatures } from \"app/projectFeatures.ts\"\nimport type { CanvasTransform, DocumentUpdate, SandboxUpdate } from \"canvas-sandbox/CanvasSandboxMessagesIn.ts\"\nimport { isSandboxUpdate } from \"canvas-sandbox/CanvasSandboxMessagesIn.ts\"\nimport { CanvasTreeVersion } from \"document/models/CanvasTree/CanvasTreeVersion.ts\"\nimport { PartialTreeReceiver } from \"document/models/CanvasTree/PartialTreeReceiver.ts\"\nimport { jsonApplyChanges } from \"document/models/CanvasTree/TreeDiff.ts\"\nimport type { CanvasNode, MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { CanvasTree, FrameNode, NullID, RichTextNode, ScopeNode, TextNode } from \"document/models/CanvasTree/index.ts\"\nimport { ColorStyleTokenListNode } from \"document/models/CanvasTree/nodes/ColorStyleTokenListNode.ts\"\nimport { PresetsListNode } from \"document/models/CanvasTree/nodes/PresetsListNode.ts\"\nimport { FormPlainTextInputNode } from \"document/models/CanvasTree/nodes/forms/FormPlainTextInputNode.ts\"\nimport { FormSelectNode } from \"document/models/CanvasTree/nodes/forms/FormSelectNode.ts\"\nimport {\n\tisComponentPresetNode,\n\tisRichTextNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { hasFloatingPosition } from \"document/models/CanvasTree/traits/WithFloatingPosition.ts\"\nimport type { WithLoadableFonts } from \"document/models/CanvasTree/traits/WithLoadableFonts.ts\"\nimport { withLoadableFonts } from \"document/models/CanvasTree/traits/WithLoadableFonts.ts\"\nimport { isVisibleNode } from \"document/models/CanvasTree/traits/WithVisibility.ts\"\nimport { getGroundNodeOverflowRect } from \"document/models/CanvasTree/utils/getGroundNodeRect.ts\"\nimport { FramerFontStore } from \"document/stores/FramerFontStore.ts\"\nimport type { RepeatersShowingEmptyState } from \"document/stores/RepeaterStore.ts\"\nimport type { NodeWithPlaceholders } from \"document/stores/ToolStore.ts\"\nimport type { EffectPreviewType } from \"document/utils/EffectPreviewType.ts\"\nimport type { FontPreview } from \"document/utils/FontPreviewTypes.ts\"\nimport { isStylePresetFontPreview } from \"document/utils/FontPreviewTypes.ts\"\nimport type { ActiveLinkStyle } from \"document/utils/activeLinkStylePreset.ts\"\nimport { nodeForExporting } from \"export/nodeForExporting.ts\"\nimport * as Framer from \"library/index.ts\"\nimport { type RenderTarget, isEqual } from \"library/index.ts\"\nimport { fontStore } from \"library/render/fonts/fontStore.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport type { LocaleId } from \"library/router/types.ts\"\nimport type { ModuleRuntimeStateChangedListener, SandboxLoadingMark } from \"modulesRuntime/ModulesRuntime.ts\"\nimport { ModulesRuntime } from \"modulesRuntime/ModulesRuntime.ts\"\nimport { serializeSandboxEntities } from \"modulesRuntime/serializeSandboxEntities.ts\"\nimport type { CanvasRendererStateHook } from \"renderer/CanvasRenderer.tsx\"\nimport { updateDebugRenderingFeatures } from \"renderer/DebugRenderingFeatures.ts\"\nimport { DeferredRendering } from \"renderer/DeferredRendering.ts\"\nimport { ImageAssetLoader } from \"renderer/ImageAssetLoader.ts\"\nimport { OptimizedCanvasImageRenderer } from \"renderer/OptimizedCanvasImageRenderer.ts\"\nimport { RenderingStateTracker } from \"renderer/RenderingStateTracker.ts\"\nimport { SVGRenderer } from \"renderer/staticSVGRenderer.tsx\"\nimport { multiTimerDebounce } from \"utils/debounce.ts\"\nimport { isShallowArrayEqual } from \"utils/isShallowEqual.ts\"\nimport type { InitialModuleLoadStats } from \"utils/performanceTracker.ts\"\nimport { ChannelController } from \"utils/rpc/ChannelController.ts\"\nimport {\n\ttype RendererInterface,\n\ttype RendererListenerInterface,\n\ttype SandboxError,\n\ttype SandboxHeartbeatVitals,\n\tsandboxInterface,\n} from \"utils/rpc/shared/definitions.ts\"\nimport type {\n\tLoadedExternalModulesStoreDefinition,\n\tSandboxComponentLoaderDefinition,\n} from \"utils/rpc/shared/sandboxComponentLoader.ts\"\nimport type { Remote } from \"utils/rpc/types.ts\"\nimport { setOverlayAndDescendantVisibility } from \"utils/setOverlayAndDescendantVisibility.ts\"\nimport { isNonNull, isObject, isString, isUndefined } from \"utils/typeChecks.ts\"\nimport {\n\tperformanceClearMarks,\n\tperformanceClearMeasures,\n\tperformanceMark,\n\tperformanceMeasure,\n} from \"utils/userTiming.ts\"\nimport { ControlsVisibility } from \"./ControlsVisibility.ts\"\nimport type { MinMaxSize, SandboxCommand } from \"./SandboxCommand.ts\"\nimport { isSandboxCommand } from \"./SandboxCommand.ts\"\nimport { SandboxUtils } from \"./SandboxUtils.ts\"\nimport { checkTextWordBreakForRichTextNodes } from \"./checkTextWordBreakForRichTextNodes.ts\"\nimport { LayoutMeasureQueue, type LayoutMeasurement } from \"./layout-measuring/LayoutMeasureQueue.ts\"\nimport { measureQueueForRenderedNodes } from \"./layout-measuring/measureQueueForRenderedNodes.ts\"\nimport { type ViewBoxMeasurement, viewBoxMeasurementsForRichTextNodes } from \"./viewBoxMeasurementsForRichTextNodes.tsx\"\n\nconst log = getLogger(\"canvas-sandbox\")\n\nconst resolveAndWarnAfterTimeout = (timeout: number, message: string) =>\n\tnew Promise<void>(resolve => {\n\t\tsetTimeout(() => {\n\t\t\tlog.warn(message)\n\t\t\tresolve()\n\t\t}, timeout)\n\t})\n\nconst waitForAnimationFrames = async (frames: number = 1) => {\n\tfor (let i = 0; i < frames; i++) {\n\t\tawait new Promise(resolve => {\n\t\t\trequestAnimationFrame(resolve)\n\t\t})\n\t}\n}\n\ninterface ModulesUpdateOpts {\n\tpatches: readonly ModulesUpdates.Patch[]\n\tprioritizedModules: readonly string[]\n\tdependentModules: readonly string[]\n\tinitialized: boolean\n\trevision: number\n\trerenderCanvas: (modulesRevision: number | null) => void\n}\n\nexport interface AssetsUpdates {\n\tupdateAssets(assets: readonly Assets.Asset[]): void\n}\n\nexport interface ModuleUpdates {\n\tupdateModules(\n\t\tpatches: readonly ModulesUpdates.Patch[],\n\t\tprioritizedModules: readonly string[],\n\t\tdependentModules: readonly string[],\n\t\tinitialized: boolean,\n\t\trevision: number,\n\t): Promise<void>\n}\n\nexport class CanvasSandboxApp\n\timplements\n\t\tReturnType<CanvasRendererStateHook>,\n\t\tModuleRuntimeStateChangedListener,\n\t\tRendererInterface,\n\t\tAssetsUpdates,\n\t\tFlagsUpdates,\n\t\tModuleUpdates\n{\n\treadonly modulesRuntime = new ModulesRuntime(\"waiting\", this)\n\treadonly componentLoader = this.modulesRuntime.componentLoader\n\n\tprivate readonly sandboxUtils = new SandboxUtils(this.componentLoader)\n\n\t/** When nodes didn't change, but other variables did that still influence how certain nodes\n\t * render, then we can signal that via the rendering state tracker. Things like the zoom level,\n\t * component loader hash, insertion rects, etc. */\n\treadonly tracker = new RenderingStateTracker(this.modulesRuntime)\n\n\trenderTarget = Framer.RenderTarget.canvas\n\n\t/** The last engine.update the sandbox received. */\n\tlastEngineUpdate = 0\n\n\tpartialTreeReceiver?: PartialTreeReceiver\n\ttree = CanvasTree.createWithRouteSegmentRoot()\n\n\t// Track if we're currently receiving chunks to prevent premature rendering\n\tprivate isReceivingChunks = false\n\tsandboxRepeaterData = this.tracker.sandboxRepeaterData\n\tsandboxVisibility = this.tracker.sandboxVisibility\n\tselection: NodeID[] = []\n\n\tactiveLocaleId: LocaleId | undefined\n\n\trootFontSize: number | undefined\n\n\tinRelativeOverlayEditMode: boolean = false\n\n\tshouldSetMinHeight: boolean = false\n\n\tactiveLinkStyle: ActiveLinkStyle | undefined = undefined\n\n\toptionalSelectedCollectionItemId: NodeID | undefined\n\n\trepeatersShowingEmptyState: RepeatersShowingEmptyState = new Set()\n\n\t/**\n\t * \"Revision\" of the modules.\n\t *\n\t * `null` - there are no modules loaded yet\n\t * `0` - modules are initially loaded\n\t * `> 0` - subsequent module updates\n\t */\n\tprivate modulesRevision: number | null = null\n\n\t/**\n\t * We don't evaluate all modules, some we evaluate on demand. Every time we do, we increment this number.\n\t */\n\tprivate lazyModulesRevision: number = 0\n\n\t/**\n\t * \"Legacy\" bundle hash.\n\t */\n\tprivate componentHash: string | null = null\n\n\tget codeRevision(): string {\n\t\t// Note: ComponentsStore relies on this format to know when modules have\n\t\t// been updated and evaluated in the sandbox!\n\t\t//\n\t\t// See ComponentsStore.activeBundleModulesRevision\n\t\tif (this.lazyModulesRevision <= 0) {\n\t\t\treturn this.componentHash + \"_\" + this.modulesRevision\n\t\t}\n\n\t\treturn this.componentHash + \"_\" + this.modulesRevision + \".\" + this.lazyModulesRevision\n\t}\n\n\t// implements ModuleRuntimeStateChangedListener\n\tlocalModulesLoaded(\n\t\tentitiesToUpdate: SandboxEntityDefinition<unknown>[],\n\t\tentitiesToDelete: string[],\n\t\tmodulesRevision: number,\n\t\tlazyModulesRevision: number,\n\t): void {\n\t\tthis.modulesRevision = modulesRevision\n\t\tthis.lazyModulesRevision = lazyModulesRevision\n\n\t\tvoid this.remoteModuleStore.update(\n\t\t\tserializeSandboxEntities(entitiesToUpdate),\n\t\t\tentitiesToDelete,\n\t\t\tmodulesRevision,\n\t\t\tlazyModulesRevision,\n\t\t)\n\n\t\tthis.tracker.updateState({ componentLoaderHash: this.codeRevision })\n\n\t\tthis.scheduleEmitRenderUpdate()\n\t}\n\n\tprivate scheduledEmitRenderUpdate: boolean = false\n\t/**\n\t * Send an update to the host, because this event might be the only reason some of this data\n\t * changes. And we don't want to wait on some next re-render that might happen only very late.\n\t */\n\tprivate scheduleEmitRenderUpdate() {\n\t\tif (this.scheduledEmitRenderUpdate) return\n\t\tthis.scheduledEmitRenderUpdate = true\n\t\tsetTimeout(() => {\n\t\t\tthis.scheduledEmitRenderUpdate = false\n\t\t\tconst isLoadingModules = this.isLoadingModules\n\t\t\tconst initialModuleLoadStats = this.initialModuleLoadStatsForRenderedUpdate(isLoadingModules)\n\n\t\t\tthis.remoteRendererListener.oneway.renderedUpdate({\n\t\t\t\tupdate: -1,\n\t\t\t\tupdateTime: 0,\n\t\t\t\trenderTime: 0,\n\t\t\t\trenderingPhase: this.deferredRendering.renderingPhase,\n\t\t\t\tmoduleRuntimePhase: this.modulesRuntime.phase,\n\t\t\t\tisLoadingModules,\n\t\t\t\t...(initialModuleLoadStats ? { initialModuleLoadStats } : {}),\n\t\t\t\tlayoutMeasurements: [],\n\t\t\t\trepeaterUpdates: this.sandboxRepeaterData.export(),\n\t\t\t\tvisibilityUpdates: this.sandboxVisibility.export(),\n\t\t\t\tscopeId: this.scopeId,\n\t\t\t\tupdateEndTime: 0,\n\t\t\t\trenderEndTime: 0,\n\t\t\t\tscopeSwitchStartTime: 0,\n\t\t\t})\n\t\t}, 0)\n\t}\n\n\t// implements ModuleRuntimeStateChangedListener\n\texternalModulesLoadingStateChange(loading: boolean): void {\n\t\tif (loading) return\n\t\tthis.rerenderComponentPresets()\n\t}\n\n\t// implements ModuleRuntimeStateChangedListener\n\tloadingStateChanged(loading: boolean): void {\n\t\tif (loading) return\n\n\t\t// When modules finish loading, we want to update the engine state just in case we had a loading state stuck for some reason.\n\t\tthis.scheduleEmitRenderUpdate()\n\t}\n\n\t// implements ModuleRuntimeStateChangedListener\n\texternalModuleLoaded(\n\t\tidentifier: ExternalModuleBareIdentifierString,\n\t\tentities: SandboxEntityDefinition<unknown>[],\n\t): void {\n\t\tvoid this.remoteLoadedExternalModulesStore.signalExternalModuleLoaded(\n\t\t\tidentifier,\n\t\t\tserializeSandboxEntities(entities),\n\t\t)\n\t\tif (this.modulesRuntime.status === \"Done\") {\n\t\t\tthis.scheduleEmitRenderUpdate()\n\t\t}\n\t}\n\n\t// implements ModuleRuntimeStateChangedListener\n\tmarkLoadingPerf(mark: SandboxLoadingMark): void {\n\t\tthis.remoteRendererListener.oneway.markLoadingPerf(mark)\n\t}\n\n\t// implements ModuleRuntimeStateChangedListener\n\tmarkLoadingPerfDynamic(name: string, label: string): void {\n\t\tthis.remoteRendererListener.oneway.markLoadingPerfDynamic(name, label)\n\t}\n\n\t/** Will be set to true after the tree contains the first user data. */\n\tprivate loadedSomeUserData = false\n\n\t/** Tracks scopes that have been been rendered and fully loaded their modules, images, etc. */\n\tprivate initialLoadingOfScopesWasDone = new Set<NodeID>()\n\n\tget isLoadingModules(): boolean {\n\t\tif (this.initialLoadingOfScopesWasDone.has(this.scopeId)) return false\n\t\tif (this.deferredRendering.renderingPhase !== \"Normal\") return true\n\t\treturn this.modulesRuntime.isLoadingAnything() || this.tracker.isLoading()\n\t}\n\n\tprivate pendingInitialModuleLoadStats: InitialModuleLoadStats | undefined\n\n\tprivate initialModuleLoadStatsForRenderedUpdate(isLoadingModules: boolean): InitialModuleLoadStats | undefined {\n\t\tif (!this.pendingInitialModuleLoadStats && !this.modulesRuntime.isLoadingAnything()) {\n\t\t\tthis.pendingInitialModuleLoadStats = this.modulesRuntime.takeInitialModuleLoadStats()\n\t\t}\n\t\tif (isLoadingModules) return undefined\n\n\t\tconst stats = this.pendingInitialModuleLoadStats\n\t\tthis.pendingInitialModuleLoadStats = undefined\n\t\treturn stats\n\t}\n\n\tisInitialLoad = true\n\tisDarkMode = false\n\t// Time tracking values for events sent via renderedUpdateEmitter\n\tscopeSwitchStartTime = 0\n\tscopeSwitchUpdateEndTime = 0\n\n\tscopeId: string = \"\"\n\tgroundNodeMap?: Record<NodeID, Rect>\n\tgroundNodes: CanvasNode[] = []\n\tgroundNodeIdsInViewport = new Set<NodeID>()\n\tprivate visibleRect: Rect = { x: 0, y: 0, width: 0, height: 0 }\n\tprivate readonly nodeIdsToRerender = new Set<NodeID>()\n\tprivate lastPresetsListNodeUpdate = 0\n\n\tprivate hasEmittedScopeLoadingDebounceMark = false\n\tprivate hasEmittedTrackerIdleMark = false\n\n\ttrackScopeLoading = debounce(\n\t\t(scopeId: string) => {\n\t\t\tif (this.scopeId !== scopeId) {\n\t\t\t\tlog.reportError(\"CanvasSandboxApp: addScopeToLoadedDebounced called with different scopeId\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (this.tracker.isLoading()) return\n\n\t\t\tif (this.initialLoadingOfScopesWasDone.has(scopeId)) return\n\t\t\tlog.debug(\"scope marked as loaded and triggering re-render\", scopeId)\n\t\t\tif (!this.hasEmittedScopeLoadingDebounceMark) {\n\t\t\t\tthis.hasEmittedScopeLoadingDebounceMark = true\n\t\t\t\tthis.markLoadingPerf(\"sandboxScopeLoadingDebounceEnter\")\n\t\t\t}\n\t\t\tthis.initialLoadingOfScopesWasDone.add(scopeId)\n\t\t\t// Trigger re-render since isLoadingModules will now return false for this scope\n\t\t\tthis.triggerRenderer()\n\t\t},\n\t\tenvironment.isAutomation ? 0 : 300,\n\t)\n\n\t// The layout queue also observes certain components to track them resizing, then after a small\n\t// delay it will call this callback.\n\tmeasureLayoutAndEmitUpdate = () => {\n\t\tconst start = performance.now()\n\t\tconst update = this.lastRendering.update\n\t\tconst layoutMeasurements = this.measureLayout(update)\n\t\tconst repeaterUpdates = this.sandboxRepeaterData.export()\n\t\tconst visibilityUpdates = this.sandboxVisibility.export()\n\n\t\tconst layoutMeasureCount = layoutMeasurements.length\n\t\t// If there are no measurements and no collection record changes, no need to emit an update.\n\t\tif (layoutMeasureCount === 0 && !repeaterUpdates && !visibilityUpdates) {\n\t\t\treturn\n\t\t}\n\n\t\tlog.trace(\n\t\t\t\"measureLayoutAndEmitUpdate\",\n\t\t\t\"layoutMeasurementCount:\",\n\t\t\tlayoutMeasureCount,\n\t\t\t\"collectionRecordUpdateCount:\",\n\t\t\trepeaterUpdates?.dataUpdates.length ?? 0,\n\t\t\t\"collectionItemIdsUpdateCount:\",\n\t\t\trepeaterUpdates?.itemIdsUpdates.length ?? 0,\n\t\t)\n\n\t\tthis.updateTime += performance.now() - start\n\t\tconst { updateTime, renderTime } = this.getAndResetTimings()\n\n\t\tthis.trackScopeLoading(this.scopeId)\n\t\tconst isLoadingModules = this.isLoadingModules\n\t\tconst initialModuleLoadStats = this.initialModuleLoadStatsForRenderedUpdate(isLoadingModules)\n\n\t\tthis.remoteRendererListener.oneway.renderedUpdate({\n\t\t\tupdate,\n\t\t\tupdateTime,\n\t\t\trenderTime,\n\t\t\trenderingPhase: this.deferredRendering.renderingPhase,\n\t\t\tmoduleRuntimePhase: this.modulesRuntime.phase,\n\t\t\tisLoadingModules,\n\t\t\t...(initialModuleLoadStats ? { initialModuleLoadStats } : {}),\n\t\t\tlayoutMeasurements,\n\t\t\trepeaterUpdates,\n\t\t\tvisibilityUpdates,\n\t\t\tscopeId: this.scopeId,\n\t\t\tupdateEndTime: 0,\n\t\t\trenderEndTime: 0,\n\t\t\tscopeSwitchStartTime: 0,\n\t\t})\n\t}\n\n\t// We render elements in phases, when finally done, the deferred renderer will call this\n\t// callback.\n\tdeferredRenderingFinished = (): void => {\n\t\tthis.isLoadingResourcesPromise.resolve()\n\n\t\tthis.isInitialLoad = false\n\n\t\tconst update = this.lastRendering.update\n\t\tconst layoutMeasurements = this.measureLayout(update)\n\t\tif (layoutMeasurements.length > 0) {\n\t\t\tlog.trace(\"deferredRenderingFinished\", layoutMeasurements.length)\n\t\t}\n\n\t\tconst { updateTime, renderTime } = this.getAndResetTimings()\n\t\tconst isLoadingModules = this.isLoadingModules\n\t\tconst initialModuleLoadStats = this.initialModuleLoadStatsForRenderedUpdate(isLoadingModules)\n\t\tthis.remoteRendererListener.oneway.renderedUpdate({\n\t\t\tupdate,\n\t\t\tupdateTime,\n\t\t\trenderTime,\n\t\t\trenderingPhase: \"Normal\",\n\t\t\tmoduleRuntimePhase: this.modulesRuntime.phase,\n\t\t\tisLoadingModules,\n\t\t\t...(initialModuleLoadStats ? { initialModuleLoadStats } : {}),\n\t\t\tlayoutMeasurements,\n\t\t\trepeaterUpdates: this.sandboxRepeaterData.export(),\n\t\t\tvisibilityUpdates: this.sandboxVisibility.export(),\n\t\t\tscopeId: this.scopeId,\n\t\t\t// We only report scope switch times from the deferred rendering finished callback. Note\n\t\t\t// these numbers don't work the same way as the updateTime/renderTime numbers for legacy\n\t\t\t// reasons.\n\t\t\tupdateEndTime: this.scopeSwitchUpdateEndTime,\n\t\t\trenderEndTime: performance.now(),\n\t\t\tscopeSwitchStartTime: this.scopeSwitchStartTime,\n\t\t})\n\n\t\tif (this.scopeSwitchStartTime && this.scopeSwitchUpdateEndTime) {\n\t\t\tthis.scopeSwitchStartTime = 0\n\t\t\tthis.scopeSwitchUpdateEndTime = 0\n\t\t}\n\t}\n\n\treadonly deferredRendering = new DeferredRendering(\n\t\tthis.modulesRuntime,\n\t\t(callback?: () => void) => this.triggerRenderer(callback),\n\t\tthis.deferredRenderingFinished,\n\t)\n\n\ttrackThumbnailLoad = (nodeId: string | undefined, load: () => Promise<void>) => {\n\t\tconst node = this.tree.get(nodeId)\n\t\tif (!node) return\n\t\tconst groundNode = this.tree.getGroundNodeFor(node)\n\t\tthis.deferredRendering.trackResourceLoading(groundNode.id, load)\n\t}\n\n\treadonly imageLoader = new ImageAssetLoader(this.trackThumbnailLoad)\n\treadonly optimizedCanvasImageRenderer = new OptimizedCanvasImageRenderer(this.trackThumbnailLoad)\n\n\tperformanceMode = false\n\n\toffsetX = 0\n\toffsetY = 0\n\tcanvasZoom = 1\n\tliveZoom: number | undefined = undefined\n\tinMoveTool = false\n\n\t/** Captures time spend on anything but react rendering */\n\tprivate updateTime = 0\n\n\t/** Captures time spend on react rendering */\n\tprivate renderTime = 0\n\n\tprivate previousNodesWithPlaceholders: NodeWithPlaceholders[] | null = null\n\tprivate previousNodeInTextEditor: MaybeNodeID = NullID\n\tprivate previousNodesInEffectPreview: NodeID[] = []\n\tprivate previousNodesInMoveToolRootFontSize: Record<NodeID, number> = {}\n\tprivate previousActiveEffect: EffectPreviewType | null = null\n\n\tprivate previousFontPreviewByNodeId: ReadonlyMap<NodeID, FontPreview> = new Map()\n\t/** Used by InjectStylePresets.tsx to know which presets' CSS needs to be updated */\n\tfontPreviewByNodeId: ReadonlyMap<NodeID, FontPreview> = new Map()\n\n\tprivate previousActiveOverlayNodes: ReadonlySet<NodeID> = new Set()\n\n\treadonly controlsVisibilityService = new ControlsVisibility(this.componentLoader, this)\n\n\treadonly layoutMeasureQueue = new LayoutMeasureQueue({\n\t\tshouldMeasureCallback: this.measureLayoutAndEmitUpdate,\n\t\trenderingStateTracker: this.tracker,\n\t})\n\n\tprivate forceRender = 1000\n\n\treadonly assetMap = new AssetMap()\n\tget assetMapHash(): number {\n\t\treturn this.assetMap.hash ^ this.forceRender\n\t}\n\n\treadonly svgRenderer = SVGRenderer.shared()\n\n\tprivate remoteModuleStore: Remote<SandboxComponentLoaderDefinition>\n\tprivate remoteLoadedExternalModulesStore: Remote<LoadedExternalModulesStoreDefinition>\n\tprivate remoteRendererListener: Remote<RendererListenerInterface>\n\n\tprivate readonly instanceId = Math.random().toString(36).slice(2, 8)\n\n\tconstructor() {\n\t\tconst rpc = new ChannelController(sandboxInterface)\n\t\trpc.setLocal(sandboxInterface.channels.renderer, this)\n\t\trpc.setLocal(sandboxInterface.channels.assets, this)\n\t\trpc.setLocal(sandboxInterface.channels.modules, this)\n\t\trpc.setLocal(sandboxInterface.channels.modulesRuntime, this.modulesRuntime)\n\t\trpc.setLocal(sandboxInterface.channels.utils, this.sandboxUtils)\n\t\trpc.setLocal(sandboxInterface.channels.controlsVisibility, this.controlsVisibilityService)\n\t\trpc.setLocal(sandboxInterface.channels.flags, this)\n\n\t\tthis.tracker.onFirstIdleAfterLoading = () => {\n\t\t\tif (this.hasEmittedTrackerIdleMark) return\n\t\t\tthis.hasEmittedTrackerIdleMark = true\n\t\t\tthis.markLoadingPerf(\"sandboxTrackerIdle\")\n\t\t}\n\n\t\tthis.remoteRendererListener = rpc.getRemote(sandboxInterface.channels.rendererListener)\n\t\tthis.remoteModuleStore = rpc.getRemote(sandboxInterface.channels.componentsStore)\n\t\tthis.remoteLoadedExternalModulesStore = rpc.getRemote(sandboxInterface.channels.loadedExternalModulesStore)\n\n\t\tconst trustedOrigin = getServiceMap().app\n\n\t\t// Actually connect\n\t\trpc\n\t\t\t.connect({ url: trustedOrigin, allowDynamicTarget: true })\n\t\t\t.then(() => {\n\t\t\t\t// Immediately after connecting, update the remote modules store. To send the build in components.\n\t\t\t\tconst entities = serializeSandboxEntities(this.componentLoader.entities.values())\n\t\t\t\tvoid this.remoteModuleStore.update(entities, [], -1, -1)\n\t\t\t})\n\t\t\t.catch(reportError)\n\n\t\twindow.addEventListener(\"resize\", this.updateViewportSize)\n\t\tsetTimeout(this.updateViewportSize)\n\n\t\t// When loading projects in the background window.innerWidth and window.innerHeight are both 0\n\t\t// which results in all ground nodes being out of the viewport and not being rendered correctly.\n\t\t// We need to read the actual window dimensions as soon as the tab becomes visible and re-render the canvas.\n\t\twindow.addEventListener(\"visibilitychange\", () => {\n\t\t\tif (document.visibilityState !== \"visible\") return\n\n\t\t\tconst didUpdateViewport = this.updateViewportSize()\n\n\t\t\t// FIXME: We need a clearer path to render when any of these values change and unify it with the rendering logic inside the update function.\n\t\t\tif (didUpdateViewport) {\n\t\t\t\tthis.updateViewportRect()\n\t\t\t\tthis.updateGroundNodesInViewport()\n\t\t\t\tthis.triggerRenderer()\n\t\t\t}\n\t\t})\n\n\t\t// Hook up nodes that potentially load resources or fonts and want to get re-rendered.\n\t\tFrameNode.updateNodes = this.updateNodes\n\t\tTextNode.updateNodes = this.updateNodes\n\t\tRichTextNode.updateNodes = this.updateNodes\n\t\tFormPlainTextInputNode.updateNodes = this.updateNodes\n\t\tFormSelectNode.updateNodes = this.updateNodes\n\t}\n\n\tprivate requestNodesRerender = multiTimerDebounce(() => {\n\t\tthis.invalidateNodes(this.nodeIdsToRerender)\n\t\tthis.nodeIdsToRerender.clear()\n\t\tthis.triggerRenderer()\n\t}, 250)\n\n\tprivate updateNodes = (nodeIds: string[]) => {\n\t\tfor (const nodeId of nodeIds) {\n\t\t\tthis.nodeIdsToRerender.add(nodeId)\n\t\t}\n\t\tthis.requestNodesRerender()\n\t}\n\n\tprivate rerenderCanvas = (modulesRevision: number | null) => {\n\t\tif (isNonNull(modulesRevision) && isNonNull(this.modulesRevision) && modulesRevision < this.modulesRevision) {\n\t\t\tlog.reportError(new Error(\"Assertion error: processing modules update out of order.\"))\n\t\t}\n\n\t\tif (isNonNull(modulesRevision)) {\n\t\t\tthis.modulesRevision = modulesRevision\n\t\t}\n\n\t\tthis.markGroundNodesNeedRendering()\n\t\tthis.rerenderGroundNodesIfNeeded()\n\t}\n\n\tasync updateModules(\n\t\tpatches: readonly ModulesUpdates.Patch[],\n\t\tprioritizedModules: readonly string[],\n\t\tdependentModules: readonly string[],\n\t\tinitialized: boolean,\n\t\trevision: number,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tconst moduleUpdateHandler = experiments.isOn(\"prioritizedModuleEvaluation\")\n\t\t\t\t? this.handleModulesUpdate\n\t\t\t\t: this.legacyHandleModulesUpdate\n\n\t\t\tawait moduleUpdateHandler.call(this, {\n\t\t\t\tpatches,\n\t\t\t\tprioritizedModules,\n\t\t\t\tdependentModules,\n\t\t\t\tinitialized,\n\t\t\t\trevision,\n\t\t\t\trerenderCanvas: this.rerenderCanvas,\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tlog.reportError(err, { context: \"Failed to handle modules update\" })\n\t\t}\n\t}\n\n\tupdateAssets(assets: readonly Assets.Asset[]) {\n\t\tthis.assetMap.set(assets)\n\t\tfontStore.importCustomFonts(this.assetMap.items(), experiments.isOn(\"customFontGrouping\"))\n\t\tthis.triggerRenderer()\n\t}\n\n\tupdateExperiments(update: FlagsValues) {\n\t\tlog.trace(\"updateExperiments\", update)\n\t\texperiments.update(update)\n\t}\n\n\tupdateProjectFeatures(update: FlagsValues) {\n\t\tlog.trace(\"updateProjectFeatures\", update)\n\t\tprojectFeatures.update(update)\n\t}\n\n\tupdateEmployeesOnlySettings(update: FlagsValues) {\n\t\tlog.trace(\"updateEmployeesOnlySettings\", update)\n\t\temployeesOnlySettings.update(update)\n\t}\n\n\tprivate async handleModulesUpdate({\n\t\tpatches,\n\t\tprioritizedModules: visibleModulesAndDependencies,\n\t\tinitialized,\n\t\trevision,\n\t\trerenderCanvas,\n\t\tdependentModules,\n\t}: ModulesUpdateOpts) {\n\t\tif (visibleModulesAndDependencies.length > 0) {\n\t\t\t// Prioritize evaluating modules that are visible in the current\n\t\t\t// scope. This ensures we can show them asap, without waiting to\n\t\t\t// evaluate modules that won't be visible.\n\t\t\tconst prioritizeModulesStartMark = `Prioritize modules start ${revision}`\n\t\t\tperformanceMark(prioritizeModulesStartMark)\n\t\t\tawait this.modulesRuntime.handleLocalModulesUpdate({\n\t\t\t\tpatches: patches as unknown as Patch[],\n\t\t\t\tdependentModules: visibleModulesAndDependencies,\n\t\t\t\tinitialized,\n\t\t\t\trevision,\n\t\t\t})\n\t\t\tperformanceMeasure(`Prioritize modules ${revision}`, prioritizeModulesStartMark)\n\t\t\tperformanceClearMarks(prioritizeModulesStartMark)\n\n\t\t\t// If there are only visible modules and patches, we have nothing to\n\t\t\t// do here, we just need to update the canvas and immediately report\n\t\t\t// the revision.\n\t\t\tif (dependentModules.length === 0) {\n\t\t\t\tlog.debug(\"No dependent modules to evaluate\", revision)\n\t\t\t\trerenderCanvas(revision)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Otherwise we rerender but don't report the revision,marking the\n\t\t\t// revision as achieved would be preemptive since we haven't\n\t\t\t// evaluated all modules yet.\n\t\t\trerenderCanvas(null)\n\n\t\t\t// Since we have already processed the patches, we can reset them so\n\t\t\t// we don't evaluate them 2x.\n\t\t\tpatches = []\n\t\t}\n\n\t\tconst lowPriorityModulesStartMark = `lowPriorityModules start ${revision}`\n\t\tperformanceMark(lowPriorityModulesStartMark)\n\n\t\t// Process the remaining low priority evaluations. If we didn't have any\n\t\t// high priority evaluations, also process the patches. Usually we\n\t\t// should always have an entry in the set for the patches, but might not\n\t\t// for persisted modules etc which aren't in the current scope.\n\t\tvoid this.modulesRuntime\n\t\t\t.handleLocalModulesUpdate({\n\t\t\t\tpatches: patches as unknown as Patch[],\n\t\t\t\tdependentModules,\n\t\t\t\tinitialized,\n\t\t\t\trevision,\n\t\t\t})\n\t\t\t.catch(err => log.reportError(err, { context: \"Failed to handle modules update\" }))\n\t\t\t.finally(() => {\n\t\t\t\t// We update the revision only after all modules updates modules\n\t\t\t\t// runtime process tasks one by one, so we can be sure that this\n\t\t\t\t// callback will also be sequential and have no race conditions.\n\t\t\t\tperformanceMeasure(`lowPriorityModules ${revision}`, lowPriorityModulesStartMark)\n\t\t\t\tperformanceClearMarks(lowPriorityModulesStartMark)\n\t\t\t\trerenderCanvas(revision)\n\t\t\t})\n\t}\n\n\tprivate async legacyHandleModulesUpdate({\n\t\tpatches,\n\t\tprioritizedModules,\n\t\tinitialized,\n\t\trevision,\n\t\trerenderCanvas,\n\t\tdependentModules,\n\t}: ModulesUpdateOpts) {\n\t\tawait this.modulesRuntime.handleLocalModulesUpdate({\n\t\t\tpatches: patches as unknown as Patch[],\n\t\t\tdependentModules: prioritizedModules.concat(dependentModules),\n\t\t\tinitialized,\n\t\t\trevision,\n\t\t})\n\t\trerenderCanvas(revision)\n\t}\n\n\tprivate startedHeartbeat = false\n\tprivate emitHeartbeat = () => {\n\t\t// Beat around every 10 seconds\n\t\tconst next = 10000\n\n\t\t// Collect vitals\n\t\tconst vitals: SandboxHeartbeatVitals = {}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: @TODO add explanation\n\t\tconst { memory } = performance as any\n\t\tif (memory) {\n\t\t\tvitals.memoryTotal = memory.totalJSHeapSize\n\t\t\tvitals.memoryUsed = memory.usedJSHeapSize\n\t\t\tvitals.memoryLimit = memory.jsHeapSizeLimit\n\t\t}\n\t\tvitals.domNodes = document.querySelectorAll(\"*\").length\n\n\t\t// Beat the heart\n\t\tthis.remoteRendererListener.oneway.heartbeat({ vitals, next })\n\n\t\t// Schedule the next heartbeat\n\t\twindow.setTimeout(this.emitHeartbeat, next)\n\t}\n\n\tprivate invalidateNodes(nodeIds: Iterable<NodeID>) {\n\t\tfor (const nodeId of nodeIds) {\n\t\t\tconst node = this.tree.get(nodeId)\n\t\t\tif (!node) continue\n\n\t\t\tthis.rerenderNode(node)\n\t\t}\n\n\t\t// Getting a new array of ground nodes, ensures CanvasElements is re-rendering.\n\t\tthis.groundNodes = this.getGroundNodes(isVisibleNode)\n\t}\n\n\tprivate updateTransform(transform: CanvasTransform) {\n\t\tthis.offsetX = transform[0]\n\t\tthis.offsetY = transform[1]\n\t\tthis.canvasZoom = transform[2]\n\t\tthis.liveZoom = transform[3]\n\t\tthis.inMoveTool = transform[4] ?? false\n\t}\n\n\tviewportSize = {\n\t\twidth: 800,\n\t\theight: 800,\n\t}\n\n\tprivate updateViewportSize = () => {\n\t\t// NOTE: Fallback on documentElement.clientWidth/Height _should_ not be\n\t\t// necessary, but there are cases where innerWidth/Height is 0 in\n\t\t// Safari, but the fallback works.\n\t\tconst viewportSize = {\n\t\t\twidth: window.innerWidth || document.documentElement.clientWidth,\n\t\t\theight: window.innerHeight || document.documentElement.clientHeight,\n\t\t}\n\n\t\tif (isEqual(viewportSize, this.viewportSize)) return false\n\n\t\tthis.viewportSize = viewportSize\n\t\treturn true\n\t}\n\n\tprivate updateViewportRect() {\n\t\tconst zoom = this.liveZoom || this.canvasZoom\n\t\tconst obscuredLeft = 0\n\t\tconst obscuredRight = 0\n\t\tconst obscuredTop = 0\n\t\tconst obscuredBottom = 0\n\n\t\tthis.visibleRect = {\n\t\t\tx: this.offsetX + obscuredLeft / zoom,\n\t\t\ty: this.offsetY + obscuredTop / zoom,\n\t\t\twidth: (this.viewportSize.width - obscuredLeft - obscuredRight) / zoom,\n\t\t\theight: (this.viewportSize.height - obscuredTop - obscuredBottom) / zoom,\n\t\t}\n\t}\n\n\tprivate updateGroundNodesInViewport() {\n\t\tif (this.liveZoom) return\n\n\t\tconst visibleRect = this.visibleRect\n\t\tconst inVisibleRect = new Set<NodeID>()\n\t\tconst previousInVisibleRect = this.groundNodeIdsInViewport\n\t\tconst groundNodes = this.groundNodes\n\n\t\tlet same = true\n\t\tfor (let i = 0, il = groundNodes.length; i < il; i++) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: fast c style loop\n\t\t\tconst groundNode = groundNodes[i]!\n\t\t\tconst id = groundNode.id\n\t\t\tif (Rect.intersects(getGroundNodeOverflowRect(groundNode), visibleRect)) {\n\t\t\t\tinVisibleRect.add(id)\n\t\t\t\tif (same && !previousInVisibleRect.has(id)) {\n\t\t\t\t\tsame = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!same || inVisibleRect.size !== previousInVisibleRect.size) {\n\t\t\tthis.groundNodeIdsInViewport = inVisibleRect\n\n\t\t\tthis.tracker.updateGroundNodeIdsInViewport(this.groundNodeIdsInViewport)\n\t\t}\n\n\t\t// Check if we need to measure texts again because some style presets\n\t\t// have changed.\n\t\tconst listNode = PresetsListNode.get(this.tree)\n\t\tif (listNode && listNode.update !== this.lastPresetsListNodeUpdate) {\n\t\t\tthis.lastPresetsListNodeUpdate = listNode.update\n\t\t\tthis.loadStylePresetFontsAndThenMeasure()\n\t\t}\n\t}\n\n\tprivate previousCachedScopeId?: MaybeNodeID\n\n\tupdateCache() {\n\t\tthis.previousCachedScopeId = this.scopeId\n\t}\n\n\tprivate _needsRender = false\n\n\t// Only allow rendering when not receiving chunks\n\tprivate get needsRender(): boolean {\n\t\treturn this._needsRender && !this.isReceivingChunks\n\t}\n\n\tprivate set needsRender(value: boolean) {\n\t\tthis._needsRender = value\n\t}\n\n\t/**\n\t * When the sandbox receives data from Vekter, this signals a need to\n\t * rerender using React, which is not always needed (for example, when the\n\t * focus changes).\n\t */\n\tprivate markNeedsReactRendering() {\n\t\tthis.needsRender = true\n\t}\n\n\t/**\n\t * Sometime the tree data does not change, but the rendering of a node still\n\t * changes due to other data like updating the module scripts, the image\n\t * base url, etc. In that case we need to force a React rendering of the\n\t * ground nodes.\n\t */\n\tprivate markGroundNodesNeedRendering() {\n\t\tthis.needsRender = true\n\t\tthis.groundNodes = []\n\t}\n\n\tprivate rerenderNode(node: CanvasNode) {\n\t\tthis.needsRender = true\n\t\tthis.tracker.updateAllRenderingsForNode(node.id)\n\t}\n\n\tprivate lastTokenListNode: InstanceType<typeof ColorStyleTokenListNode> | null = null\n\tprivate tokenColorHash = \"\"\n\n\tprivate setTree(tree: CanvasTree) {\n\t\tthis.tree = tree\n\t\tthis.markGroundNodesNeedRendering()\n\t}\n\n\tprivate updateTokenColorRevisionIfNeeded(tree: CanvasTree) {\n\t\tconst tokenListNode = ColorStyleTokenListNode.get(tree)\n\t\tif (tokenListNode === this.lastTokenListNode) return\n\t\tthis.lastTokenListNode = tokenListNode\n\n\t\tconst tokenNodes = tokenListNode?.children ?? []\n\t\tlet hash = \"\"\n\t\tfor (const token of tokenNodes) {\n\t\t\thash += token.id + token.light + (token.dark ?? \"\")\n\t\t}\n\t\tif (hash === this.tokenColorHash) return\n\t\tthis.tokenColorHash = hash\n\t\tthis.tracker.updateState({ tokenColorRevision: this.tracker.state.tokenColorRevision + 1 })\n\t}\n\n\tprivate _update(update: SandboxUpdate) {\n\t\tthis.needsRender = false\n\n\t\t// Write current update to window.name, which doReport in the main frame\n\t\t// can read to create more useful reports. Not possible to read out when\n\t\t// running fully sandboxed.\n\t\twindow.name = JSON.stringify(update.update)\n\t\tthis.svgRenderer.update()\n\n\t\tif (update.transform) {\n\t\t\tthis.updateTransform(update.transform)\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tconst document: DocumentUpdate = update.document ?? {}\n\n\t\tif (document.loadedAllUserData) {\n\t\t\tthis.loadedSomeUserData = true\n\t\t\t// When exporting we want lazy mode to load modules as\n\t\t\t// we only want to request the modules we need.\n\t\t\tif (this.renderTarget === Framer.RenderTarget.export && !employeesOnlySettings.isOn(\"disableLazyModuleLoading\")) {\n\t\t\t\tthis.modulesRuntime.setEvaluationMode(\"lazy\")\n\t\t\t} else {\n\t\t\t\tthis.modulesRuntime.setEvaluationMode(\"eager\")\n\t\t\t}\n\t\t} else if (document.loadedSomeUserData) {\n\t\t\tthis.loadedSomeUserData = true\n\t\t\tif (!employeesOnlySettings.isOn(\"disableLazyModuleLoading\")) {\n\t\t\t\tthis.modulesRuntime.setEvaluationMode(\"lazy\")\n\t\t\t} else {\n\t\t\t\t// Experiments aren't available when the sandbox initializes so the modulesRuntime\n\t\t\t\t// always starts in \"waiting\" mode. But when the experiment is off, we skip \"lazy\"\n\t\t\t\t// mode and go directly to \"eager\" mode.\n\t\t\t\tthis.modulesRuntime.setEvaluationMode(\"eager\")\n\t\t\t}\n\t\t}\n\n\t\tif (document.renderScope) {\n\t\t\tif (this.scopeId !== document.renderScope) {\n\t\t\t\tthis.trackScopeLoading.flush()\n\t\t\t}\n\t\t\tthis.scopeId = document.renderScope\n\t\t\tthis.groundNodeMap = undefined\n\n\t\t\t// Track the start time of a scope/page switch\n\t\t\tif (!this.isInitialLoad) {\n\t\t\t\tthis.scopeSwitchStartTime = performance.now()\n\t\t\t}\n\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (document.renderNodes) {\n\t\t\tthis.scopeId = \"\"\n\t\t\tthis.groundNodeMap = document.renderNodes\n\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (document.activeLocaleId) {\n\t\t\tthis.activeLocaleId = document.activeLocaleId\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tconst partialTreeUpdate = document.partialTreeUpdate\n\t\tif (partialTreeUpdate) {\n\t\t\tthis.partialTreeReceiver ??= new PartialTreeReceiver(this.componentLoader)\n\t\t\tconst tree = this.partialTreeReceiver.update(partialTreeUpdate)\n\n\t\t\t// Only update tree when chunking is complete (tree is not null)\n\t\t\tif (tree) {\n\t\t\t\t// Chunking complete, update tree and clear flag\n\t\t\t\tthis.isReceivingChunks = false\n\t\t\t\tthis.setTree(tree)\n\t\t\t\t// Always load fonts when tree is complete (whether from chunks or regular tree)\n\t\t\t\tthis.loadStylePresetFontsAndThenMeasure()\n\t\t\t\tlog.debug(\"tree updated\")\n\t\t\t} else {\n\t\t\t\tthis.isReceivingChunks = true\n\t\t\t\tlog.debug(\"waiting for more chunks before rendering\")\n\t\t\t}\n\t\t} else {\n\t\t\tif (document.tree) {\n\t\t\t\tlog.debug(\"update\", `took ${Date.now() - (document.timestamp || 0)}ms to receive update`)\n\t\t\t\tconst tree = CanvasTree.fromJS(document.tree, this.componentLoader) ?? undefined\n\t\t\t\tif (isUndefined(tree)) {\n\t\t\t\t\tthrow Error(\"[Sandbox] Unable to build tree: \" + document.tree)\n\t\t\t\t}\n\t\t\t\t// Regular tree update, ensure chunking flag is cleared\n\t\t\t\tthis.isReceivingChunks = false\n\t\t\t\tthis.setTree(tree)\n\t\t\t\tthis.loadStylePresetFontsAndThenMeasure()\n\t\t\t}\n\t\t\tif (document.changes && document.changes.length > 0) {\n\t\t\t\tjsonApplyChanges(this.tree, document.changes)\n\t\t\t\tthis.setTree(this.tree.commitDiffs(this.componentLoader))\n\t\t\t}\n\t\t}\n\n\t\t// If setTree() wasn't called, we might still need to update the cache if the current scope has changed.\n\t\tif (this.previousCachedScopeId !== this.scopeId) {\n\t\t\tthis.markGroundNodesNeedRendering()\n\t\t}\n\n\t\t// We send the root font size in case we are in a Scope that does not have\n\t\t// a breakpoint (like SmartComponent) or the node is off a breakpoint.\n\t\tif (!isUndefined(document.rootFontSize)) {\n\t\t\tif (this.rootFontSize !== document.rootFontSize) {\n\t\t\t\tthis.rootFontSize = document.rootFontSize ?? undefined\n\t\t\t\tthis.markNeedsReactRendering()\n\t\t\t}\n\t\t}\n\n\t\tif (!isUndefined(document.selection)) {\n\t\t\tfor (const id of this.selection) {\n\t\t\t\tconst node = this.tree.get(id)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.selected = false\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.selection = document.selection\n\t\t\tfor (const id of document.selection) {\n\t\t\t\tconst node = this.tree.get(id)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.selected = true\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.tracker.updateState({ selectionCount: document.selection.length })\n\t\t}\n\n\t\tif (!isUndefined(document.nodeInTextEditorId)) {\n\t\t\t// If Vekter is in the text editor tool, the node itself must know so it won't render.\n\t\t\tif (this.previousNodeInTextEditor) {\n\t\t\t\tconst previous = this.tree.get(this.previousNodeInTextEditor)\n\t\t\t\tif (previous) {\n\t\t\t\t\tprevious.cache.isEditable = false\n\t\t\t\t\tthis.rerenderNode(previous)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.previousNodeInTextEditor = document.nodeInTextEditorId\n\t\t\tconst node = this.tree.get(document.nodeInTextEditorId)\n\t\t\tif (node) {\n\t\t\t\tnode.cache.isEditable = true\n\t\t\t\tthis.rerenderNode(node)\n\t\t\t}\n\t\t}\n\n\t\tif (!isUndefined(document.nodesInEffectPreview)) {\n\t\t\tif (this.previousNodesInEffectPreview) {\n\t\t\t\tconst current = new Set(document.nodesInEffectPreview)\n\t\t\t\tfor (const previousEffectNodeId of this.previousNodesInEffectPreview) {\n\t\t\t\t\tif (current.has(previousEffectNodeId)) continue\n\n\t\t\t\t\tconst previous = this.tree.get(previousEffectNodeId)\n\n\t\t\t\t\tif (previous) {\n\t\t\t\t\t\tprevious.cache.isEffectPreview = false\n\t\t\t\t\t\tprevious.cache.effectType = null\n\t\t\t\t\t\tprevious.cache.effectIds = null\n\t\t\t\t\t\tprevious.cache.webPageEffect = undefined\n\t\t\t\t\t\tthis.rerenderNode(previous)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.previousActiveEffect = document.activeEffect ?? this.previousActiveEffect\n\t\t\tthis.previousNodesInEffectPreview = document.nodesInEffectPreview\n\n\t\t\tconst scopeNode = this.tree.get<ScopeNode>(this.scopeId)\n\t\t\tconst isWebPage = isWebPageNode(scopeNode)\n\t\t\tfor (const effectNodeId of document.nodesInEffectPreview) {\n\t\t\t\tconst node = this.tree.get(effectNodeId)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.isEffectPreview = true\n\t\t\t\t\tnode.cache.effectType = document.activeEffect ?? this.previousActiveEffect\n\t\t\t\t\tnode.cache.effectIds = document.activeEffectIds ?? null\n\t\t\t\t\tnode.cache.webPageEffect = isWebPage\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Handle font preview\n\t\tif (!isUndefined(document.fontPreviewByNodeId)) {\n\t\t\tconst newFontPreviewByNodeId = document.fontPreviewByNodeId\n\n\t\t\t// Clear nodes no longer in preview\n\t\t\tfor (const previousNodeId of this.previousFontPreviewByNodeId.keys()) {\n\t\t\t\tif (newFontPreviewByNodeId.has(previousNodeId)) continue\n\t\t\t\tconst node = this.tree.get(previousNodeId)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.fontPreview = null\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.previousFontPreviewByNodeId = newFontPreviewByNodeId\n\n\t\t\tconst applyFontPreview = (map: ReadonlyMap<NodeID, FontPreview>) => {\n\t\t\t\t// Only apply if this is the latest update (prevents out-of-order updates)\n\t\t\t\tif (map !== this.previousFontPreviewByNodeId) return false\n\n\t\t\t\tfor (const [nodeId, fontPreview] of map) {\n\t\t\t\t\tconst node = this.tree.get(nodeId)\n\t\t\t\t\tif (!node) continue\n\t\t\t\t\tnode.cache.fontPreview = fontPreview\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\n\t\t\t\tthis.fontPreviewByNodeId = map\n\t\t\t\tthis.markNeedsReactRendering()\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tconst uniqueFontSelectors = new Set<string | undefined>()\n\t\t\tfor (const fontPreview of newFontPreviewByNodeId.values()) {\n\t\t\t\tuniqueFontSelectors.add(fontPreview.fontSelector)\n\t\t\t\tif (isStylePresetFontPreview(fontPreview)) {\n\t\t\t\t\tuniqueFontSelectors.add(fontPreview.variantSelectors?.fontBold)\n\t\t\t\t\tuniqueFontSelectors.add(fontPreview.variantSelectors?.fontItalic)\n\t\t\t\t\tuniqueFontSelectors.add(fontPreview.variantSelectors?.fontBoldItalic)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst fontSelectorsToLoad = Array.from(uniqueFontSelectors).filter(\n\t\t\t\t(s): s is string => isString(s) && !fontStore.isSelectorLoaded(s),\n\t\t\t)\n\n\t\t\tif (fontSelectorsToLoad.length === 0) {\n\t\t\t\tapplyFontPreview(newFontPreviewByNodeId)\n\t\t\t} else {\n\t\t\t\tvoid fontStore.loadFonts(fontSelectorsToLoad).then(() => {\n\t\t\t\t\tif (applyFontPreview(newFontPreviewByNodeId)) {\n\t\t\t\t\t\t// Manually trigger renderer since the fonts were loaded async and applied out\n\t\t\t\t\t\t// of the sync render phase\n\t\t\t\t\t\tthis.triggerRenderer()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tif (!isUndefined(document.nodesInMoveToolBaseFontSize)) {\n\t\t\tif (this.previousNodesInMoveToolRootFontSize) {\n\t\t\t\tconst current = { ...document.nodesInMoveToolBaseFontSize }\n\t\t\t\tfor (const previousNodeId in this.previousNodesInMoveToolRootFontSize) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tpreviousNodeId in current &&\n\t\t\t\t\t\tcurrent[previousNodeId] === this.previousNodesInMoveToolRootFontSize[previousNodeId]\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tconst previous = this.tree.get(previousNodeId)\n\n\t\t\t\t\tif (previous) {\n\t\t\t\t\t\tprevious.cache.rootFontSizeOverride = null\n\t\t\t\t\t\tthis.rerenderNode(previous)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.previousNodesInMoveToolRootFontSize = document.nodesInMoveToolBaseFontSize\n\n\t\t\tfor (const nodeId in document.nodesInMoveToolBaseFontSize) {\n\t\t\t\tconst node = this.tree.get(nodeId)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.rootFontSizeOverride = document.nodesInMoveToolBaseFontSize[nodeId] ?? null\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!isUndefined(document.activeOverlayNodes)) {\n\t\t\tif (this.previousActiveOverlayNodes.size > 0) {\n\t\t\t\tconst current = document.activeOverlayNodes\n\t\t\t\tfor (const previousActiveOverlayNodeId of this.previousActiveOverlayNodes) {\n\t\t\t\t\tif (current.has(previousActiveOverlayNodeId)) continue\n\n\t\t\t\t\tconst previous = this.tree.get(previousActiveOverlayNodeId)\n\n\t\t\t\t\tif (previous) {\n\t\t\t\t\t\t// When we invalidate the rendering path to a node, we\n\t\t\t\t\t\t// also have to make sure CanvasElements re-renders,\n\t\t\t\t\t\t// which we do by making sure groundNodes is recomputed.\n\t\t\t\t\t\tsetOverlayAndDescendantVisibility(this.tree, previous, false)\n\t\t\t\t\t\tthis.rerenderNode(previous)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (document.activeOverlayNodes.size === 0) {\n\t\t\t\tthis.tracker.clearEntriesByNodeRectMeasured()\n\t\t\t}\n\t\t\tthis.previousActiveOverlayNodes = document.activeOverlayNodes\n\n\t\t\tlet inRelativeOverlayEditMode = false\n\t\t\tfor (const activeOverlayNodeId of document.activeOverlayNodes) {\n\t\t\t\tconst node = this.tree.get(activeOverlayNodeId)\n\t\t\t\tif (node) {\n\t\t\t\t\tsetOverlayAndDescendantVisibility(this.tree, node, true)\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t\tinRelativeOverlayEditMode ||= hasFloatingPosition(node)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inRelativeOverlayEditMode !== this.inRelativeOverlayEditMode) {\n\t\t\t\tthis.inRelativeOverlayEditMode = inRelativeOverlayEditMode\n\t\t\t\tthis.markNeedsReactRendering()\n\t\t\t}\n\t\t}\n\n\t\t// Clear the placeholder every time the value changes, a new one will be\n\t\t// assigned later if the new value is not null.\n\t\tif (this.previousNodesWithPlaceholders && document.nodesWithPlaceholders !== undefined) {\n\t\t\tfor (const nodeWithPlaceholders of this.previousNodesWithPlaceholders) {\n\t\t\t\tconst node = this.tree.get(nodeWithPlaceholders.id)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.placeholders = null\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.previousNodesWithPlaceholders = null\n\t\t}\n\n\t\tif (document.nodesWithPlaceholders) {\n\t\t\tfor (const nodeWithPlaceholders of document.nodesWithPlaceholders) {\n\t\t\t\tconst { id, placeholders } = nodeWithPlaceholders\n\t\t\t\tconst node = this.tree.get(id)\n\t\t\t\tif (node) {\n\t\t\t\t\tnode.cache.placeholders = placeholders\n\t\t\t\t\tthis.rerenderNode(node)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.previousNodesWithPlaceholders = document.nodesWithPlaceholders\n\t\t}\n\n\t\tif (typeof document.isReadyToRender === \"boolean\") {\n\t\t\tthis.deferredRendering.setReadyToRender(document.isReadyToRender)\n\t\t}\n\n\t\tif (typeof document.isDarkMode === \"boolean\") {\n\t\t\tthis.updateDarkMode(document.isDarkMode)\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (typeof document.isPreviewActive === \"boolean\") {\n\t\t\tthis.tracker.updateState({\n\t\t\t\tpreviewState: document.isPreviewActive ? \"active\" : \"inactive\",\n\t\t\t})\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (typeof document.performanceMode === \"boolean\") {\n\t\t\tthis.performanceMode = document.performanceMode\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (typeof document.shouldSetMinHeight === \"boolean\") {\n\t\t\tthis.shouldSetMinHeight = document.shouldSetMinHeight\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (document.optionalSelectedCollectionItemId) {\n\t\t\tthis.optionalSelectedCollectionItemId = document.optionalSelectedCollectionItemId\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (!isUndefined(document.activeLinkStyle)) {\n\t\t\tthis.activeLinkStyle = document.activeLinkStyle ?? undefined\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (!isUndefined(document.repeatersShowingEmptyState)) {\n\t\t\tthis.tracker.updateRepeatersShowingEmptyState(document.repeatersShowingEmptyState, this.tree)\n\t\t\tthis.markNeedsReactRendering()\n\t\t}\n\n\t\tif (this.needsRender) {\n\t\t\tthis.rerenderGroundNodesIfNeeded()\n\t\t}\n\t}\n\n\tupdateGroundNodeOverflowSizes(groundNodeSizes: Record<string, MinMaxSize>) {\n\t\tfor (const [id, size] of Object.entries(groundNodeSizes)) {\n\t\t\tconst node = this.tree.get(id)\n\t\t\tif (!node) continue\n\n\t\t\tnode.cache.minX = size.minX\n\t\t\tnode.cache.maxX = size.maxX\n\t\t\tnode.cache.minY = size.minY\n\t\t\tnode.cache.maxY = size.maxY\n\t\t}\n\t}\n\n\t// FIXME: Dark mode propagation needs to be unified.\n\t// We currently have DarkModeProvider.tsx, appearance-script.js, documentSettings.hasDarkAppearance.\n\tprivate updateDarkMode(isDarkMode: boolean) {\n\t\tif (this.isDarkMode === isDarkMode) return\n\t\tthis.isDarkMode = isDarkMode\n\n\t\t/**\n\t\t * @deprecated Use the data-framer-theme attribute instead. Can be\n\t\t * removed after the code block module has been updated.\n\t\t */\n\t\tdocument.body.classList.toggle(\"framer-theme-dark\", isDarkMode)\n\t\tdocument.body.dataset.framerTheme = isDarkMode ? \"dark\" : \"light\"\n\t}\n\n\tprivate rerenderComponentPresets() {\n\t\tconst listNode = PresetsListNode.get(this.tree)\n\t\tif (!listNode) return\n\n\t\tconst componentPresets = listNode.getComponentPresets()\n\t\tfor (const presetNode of componentPresets) {\n\t\t\tconst cache = presetNode.cache\n\t\t\tif (cache.isComponentLoaded || !cache.links) continue\n\n\t\t\tthis.invalidateNodes(cache.links)\n\t\t}\n\n\t\tthis.rerenderGroundNodesIfNeeded()\n\t}\n\n\trerenderGroundNodesIfNeeded() {\n\t\t// Prevent rendering during chunk reception to avoid tree inconsistencies\n\t\tif (this.isReceivingChunks) {\n\t\t\tlog.debug(\"rerenderGroundNodesIfNeeded: skipping during chunking\")\n\t\t\treturn\n\t\t}\n\n\t\t// Only update the array of ground nodes if it is different in\n\t\t// content. Otherwise we create needless by-reference differences\n\t\t// only, messing up shallow compares.\n\t\tconst newGroundNodes = this.getGroundNodes(isVisibleNode)\n\t\t// eslint-disable-next-line framer-studio/no-mutable-node-type-operations\n\t\tif (!isShallowArrayEqual(this.groundNodes, newGroundNodes)) {\n\t\t\tthis.groundNodes = newGroundNodes\n\t\t}\n\n\t\tlog.trace(\"rerenderGroundNodesIfNeeded\")\n\n\t\tthis.triggerRenderer()\n\t}\n\n\t/** Tracks the actual values with which the last react render updated the canvas. */\n\tprivate readonly lastRendering = {\n\t\tupdate: 0,\n\t\tscopeId: \"\",\n\t\tzoom: 1,\n\t\toffsetX: 0,\n\t\toffsetY: 0,\n\t\ttree: this.tree,\n\t\tgroundNodesInViewport: new Set<string>(),\n\t}\n\n\tprivate scheduledPostRenderMicroQueue = false\n\n\t/** Called by index.tsx in triggerRenderer() just before calling setState(). */\n\tbeforeRendering() {\n\t\tthis.updateTokenColorRevisionIfNeeded(this.tree)\n\t\tthis.tracker.updateState({ zoom: this.canvasZoom, assetHash: this.assetMapHash })\n\t\tthis.tracker.signalChanges(this.groundNodes, this.tree.get(this.scopeId))\n\t}\n\n\t/** this.triggerRender() will cause react to render, but we have little control over when\n\t * exactly react will actually run. That is why useCanvasRendererState will call\n\t * this.startRender() before re-rendering via the CanvasRenderer. */\n\tstartRendering() {\n\t\tconst updateStartTime = performance.now()\n\t\tthis.updateCache()\n\t\tthis.updateViewportRect()\n\t\tthis.updateGroundNodesInViewport()\n\n\t\tif (this.loadedSomeUserData) {\n\t\t\tthis.deferredRendering.setGroundNodes(this.groundNodes, this.groundNodeIdsInViewport, this.scopeId)\n\t\t}\n\n\t\t// Between sending new updates to the sandbox, rendering, and actually measuring, there can\n\t\t// be more updates or other events. That is why we must update and capture all properties\n\t\t// with which we rendered. Or measurements might be done with bad zoom values or offsets.\n\t\tthis.lastRendering.zoom = this.canvasZoom\n\t\tthis.lastRendering.scopeId = this.scopeId\n\t\tthis.lastRendering.offsetX = this.offsetX\n\t\tthis.lastRendering.offsetY = this.offsetY\n\t\tthis.lastRendering.tree = this.tree\n\t\tthis.lastRendering.groundNodesInViewport = this.groundNodeIdsInViewport\n\t\tthis.lastRendering.update = this.lastEngineUpdate\n\n\t\tconst renderingStartTime = performance.now()\n\t\tthis.updateTime += renderingStartTime - updateStartTime\n\n\t\tlog.trace(\n\t\t\t\"startRendering: zoom\",\n\t\t\tthis.canvasZoom,\n\t\t\t\"scroll\",\n\t\t\tthis.offsetX,\n\t\t\tthis.offsetY,\n\t\t\t\"rendering phase\",\n\t\t\tthis.deferredRendering.renderingPhase,\n\t\t\t\"liveZoom\",\n\t\t\tBoolean(this.liveZoom),\n\t\t)\n\n\t\t// React in debug mode will run this method twice, we shouldn't count that twice.\n\t\tif (this.scheduledPostRenderMicroQueue) return\n\n\t\tthis.scheduledPostRenderMicroQueue = true\n\t\tqueueMicrotask(() => {\n\t\t\tthis.scheduledPostRenderMicroQueue = false\n\t\t\tthis.renderTime += performance.now() - renderingStartTime\n\t\t\tthis.measureLayoutAndEmitUpdate()\n\t\t})\n\t}\n\n\tmeasureLayout(update: number) {\n\t\t// If we are in live zooming don't measure at all.\n\t\tif (this.liveZoom) return []\n\n\t\t// If we are previewing effects, do not run measurements. We don't want\n\t\t// to measure any elements who's DOM size could be thrown off by\n\t\t// transforms.\n\t\tif (this.previousNodesInEffectPreview.length > 0) return []\n\n\t\tperformanceMark(\"LayoutMeasure\")\n\n\t\tconst layoutMeasurements = this.layoutMeasureQueue.process(this.lastRendering)\n\n\t\tperformanceMeasure(`LayoutMeasure ${update}`, \"LayoutMeasure\")\n\t\tperformanceClearMarks(\"LayoutMeasure\")\n\n\t\treturn layoutMeasurements\n\t}\n\n\tgetGroundNodes(filter?: (node: CanvasNode) => boolean): CanvasNode[] {\n\t\t// Prevent accessing tree during chunking to avoid \"Can't find active page\" errors\n\t\tif (this.isReceivingChunks) {\n\t\t\tlog.debug(\"getGroundNodes: skipping during chunking\")\n\t\t\treturn []\n\t\t}\n\n\t\tconst tree = this.tree\n\n\t\tif (this.scopeId) {\n\t\t\tconst activeScope = tree.get(this.scopeId)\n\n\t\t\tassert(activeScope instanceof ScopeNode, \"Can't find active page in tree\")\n\t\t\treturn activeScope.getGroundNodes(filter)\n\t\t}\n\n\t\t// If we're not rendering a scope, we should have a set of specific nodes to render\n\t\tconst groundNodes: CanvasNode[] = []\n\t\tif (this.groundNodeMap) {\n\t\t\tfor (const id in this.groundNodeMap) {\n\t\t\t\tconst node = tree.get(id)\n\t\t\t\tif (!node) continue\n\t\t\t\tconst rect = this.groundNodeMap[id]\n\t\t\t\tif (!rect) continue\n\t\t\t\tconst groundNode = nodeForExporting(\n\t\t\t\t\tthis.componentLoader,\n\t\t\t\t\ttree,\n\t\t\t\t\tnode,\n\t\t\t\t\trect,\n\t\t\t\t\tthis.isDarkMode,\n\t\t\t\t\tthis.previousActiveOverlayNodes,\n\t\t\t\t)\n\n\t\t\t\tgroundNodes.push(groundNode)\n\t\t\t}\n\t\t}\n\n\t\treturn groundNodes\n\t}\n\n\tcommand({ command, args }: SandboxCommand): void {\n\t\tif (command === \"clearCache\") {\n\t\t\tthis.forceRender += 1\n\t\t\tthis.tree.resetDraftNodesAndCache()\n\t\t\tthis.setTree(this.tree)\n\t\t} else if (command === \"setEnvironment\" && isObject(args)) {\n\t\t\tObject.assign(environment, args)\n\t\t} else if (command === \"setLogLevel\" && isString(args)) {\n\t\t\tsetLogLevel(args, false)\n\t\t} else if (command === \"setLogTimestamps\" && typeof args === \"boolean\") {\n\t\t\tsetLogTimestamps(args)\n\t\t} else if (command === \"renderingFeatures\" && isObject(args)) {\n\t\t\tupdateDebugRenderingFeatures(args, this.tracker)\n\t\t} else if (command === \"updateGroundNodeOverflowSizes\" && isObject(args)) {\n\t\t\tthis.updateGroundNodeOverflowSizes(args)\n\t\t} else {\n\t\t\tlog.warn(\"unknown command:\", command, args)\n\t\t}\n\t}\n\n\tprivate getAndResetTimings(): { updateTime: number; renderTime: number } {\n\t\tconst updateTime = this.updateTime\n\t\tconst renderTime = this.renderTime\n\t\tthis.updateTime = 0\n\t\tthis.renderTime = 0\n\t\treturn { updateTime, renderTime }\n\t}\n\n\tinitialize(treeVersion: number, renderTarget: RenderTarget): Promise<void> {\n\t\tif (treeVersion !== CanvasTreeVersion) {\n\t\t\tthrow new Error(\"Incompatible tree version\")\n\t\t}\n\t\tthis.renderTarget = renderTarget\n\t\treturn Promise.resolve()\n\t}\n\n\tupdateSandbox(data: SandboxUpdate | SandboxCommand): boolean {\n\t\tperformanceMark(\"sandbox\")\n\n\t\tconst prevScopeId = this.scopeId\n\n\t\tif (!this.startedHeartbeat) {\n\t\t\tlog.debug(\"Starting heartbeat\")\n\t\t\tthis.startedHeartbeat = true\n\t\t\tsetTimeout(this.emitHeartbeat)\n\t\t}\n\n\t\tconst start = performance.now()\n\n\t\tlet result = false\n\t\tlet update = -1\n\n\t\tif (isSandboxUpdate(data)) {\n\t\t\tupdate = data.update\n\t\t\tthis.lastEngineUpdate = data.update\n\t\t\tthis._update(data)\n\t\t\tresult = true\n\t\t} else if (isSandboxCommand(data)) {\n\t\t\tthis.command(data)\n\t\t}\n\n\t\tconst renderingPhase = this.deferredRendering.renderingPhase\n\t\tthis.updateTime += performance.now() - start\n\n\t\tif (prevScopeId !== this.scopeId && !this.isInitialLoad) {\n\t\t\tthis.scopeSwitchUpdateEndTime = performance.now()\n\t\t}\n\n\t\tconst { updateTime, renderTime } = this.getAndResetTimings()\n\t\tconst isLoadingModules = this.isLoadingModules\n\t\tconst initialModuleLoadStats = this.initialModuleLoadStatsForRenderedUpdate(isLoadingModules)\n\n\t\tthis.remoteRendererListener.oneway.renderedUpdate({\n\t\t\tupdate,\n\t\t\tupdateTime,\n\t\t\trenderTime,\n\t\t\trenderingPhase,\n\t\t\tmoduleRuntimePhase: this.modulesRuntime.phase,\n\t\t\tisLoadingModules,\n\t\t\t...(initialModuleLoadStats ? { initialModuleLoadStats } : {}),\n\t\t\tlayoutMeasurements: [],\n\t\t\trepeaterUpdates: this.sandboxRepeaterData.export(),\n\t\t\tvisibilityUpdates: this.sandboxVisibility.export(),\n\t\t\tscopeId: this.scopeId ?? \"\",\n\t\t\tupdateEndTime: 0,\n\t\t\trenderEndTime: 0,\n\t\t\tscopeSwitchStartTime: 0,\n\t\t})\n\n\t\tFramer.installFlexboxGapWorkaroundIfNeeded()\n\n\t\tperformanceMeasure(\"Sandbox \" + update, \"sandbox\")\n\t\tperformanceClearMarks(\"sandbox\")\n\n\t\t// We have to regularly empty all measurements or they keep on accumulating in\n\t\t// performance.getEntries().\n\t\tperformanceClearMeasures()\n\n\t\tthis.#runAfterNextUpdateQueue.forEach(cb => cb())\n\t\tthis.#runAfterNextUpdateQueue = []\n\n\t\treturn result\n\t}\n\n\t#runAfterNextUpdateQueue: VoidFunction[] = []\n\trunAfterNextUpdate(cb: VoidFunction) {\n\t\tthis.#runAfterNextUpdateQueue.push(cb)\n\t}\n\n\treportError = (error: SandboxError) => {\n\t\tthis.remoteRendererListener.oneway.error(error)\n\t}\n\n\tprivate loadStylePresetFontsAndThenMeasure() {\n\t\tconst listNode = PresetsListNode.get(this.tree)\n\t\tif (!listNode) return\n\n\t\tconst unloadedFonts: string[] = []\n\t\tfor (const preset of listNode.children) {\n\t\t\tif (isComponentPresetNode(preset)) continue\n\n\t\t\tconst fonts = preset.getFontsForCodeGeneration()\n\t\t\tfor (const font of fonts) {\n\t\t\t\tif (fontStore.isSelectorLoaded(font)) continue\n\t\t\t\tunloadedFonts.push(font)\n\t\t\t}\n\t\t}\n\n\t\tif (unloadedFonts.length > 0) {\n\t\t\tfontStore\n\t\t\t\t.loadFonts(unloadedFonts)\n\t\t\t\t.then(() => this.layoutMeasureQueue.stylePresetChanged(this.tree))\n\t\t\t\t.catch(unhandledError)\n\t\t} else {\n\t\t\tthis.layoutMeasureQueue.stylePresetChanged(this.tree)\n\t\t}\n\t}\n\n\tasync waitUntilFontsLoaded() {\n\t\tconst groundNodes = this.getGroundNodes()\n\t\tconst nodesWithFonts: (CanvasNode & WithLoadableFonts)[] = []\n\n\t\tfor (const groundNode of groundNodes) {\n\t\t\tfor (const node of groundNode.walk()) {\n\t\t\t\tif (withLoadableFonts(node) && node.hasFontsToLoad()) {\n\t\t\t\t\tnodesWithFonts.push(node)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst changedIds = new Set<NodeID>()\n\n\t\ttry {\n\t\t\tawait Promise.allSettled(\n\t\t\t\tnodesWithFonts.map(node => {\n\t\t\t\t\tconst fonts = node.getFontsForLoading()\n\t\t\t\t\treturn fontStore\n\t\t\t\t\t\t.loadFonts(fonts)\n\t\t\t\t\t\t.then(({ newlyLoadedFontCount }) => {\n\t\t\t\t\t\t\tif (newlyLoadedFontCount > 0) {\n\t\t\t\t\t\t\t\tchangedIds.add(node.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch(unhandledError)\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch {\n\t\t\t// Ignore errors\n\t\t}\n\n\t\tfor (const nodeId of this.nodeIdsToRerender) {\n\t\t\tchangedIds.add(nodeId)\n\t\t}\n\n\t\tthis.invalidateNodes(changedIds)\n\t\tthis.nodeIdsToRerender.clear()\n\n\t\tawait new Promise<void>(resolve => {\n\t\t\tthis.triggerRenderer(resolve)\n\t\t})\n\t}\n\n\tprivate isLoadingResourcesPromise = new ResolvablePromise<void>()\n\tasync waitUntilResourcesLoaded(): Promise<void> {\n\t\tawait this.isLoadingResourcesPromise\n\t}\n\n\tprivate isTrackingUpdates = false\n\tprivate assertTrackingUpdates(tracking: boolean) {\n\t\tassert(\n\t\t\ttracking === this.isTrackingUpdates,\n\t\t\t\"Update tracking (willStartUpdates/waitForCompleteRenderAfterUpdates) must be balanced and not nested\",\n\t\t)\n\t}\n\n\tasync willStartUpdates() {\n\t\tthis.assertTrackingUpdates(false)\n\t\tthis.isTrackingUpdates = true\n\t}\n\n\tasync waitForCompleteRenderAfterUpdates() {\n\t\tthis.assertTrackingUpdates(true)\n\n\t\tawait this.waitUntilResourcesLoaded()\n\t\tawait this.waitUntilPlaceholdersSettled()\n\t\tawait this.waitUntilFontsLoaded()\n\t\tawait this.renderingStateTrackerNotLoading()\n\t\tawait this.renderingQueuesDrained()\n\n\t\t// FIXME: This is mostly a stub right now. This should also track any resource that was requested\n\t\t// between willStartUpdates and waitForCompleteRenderAfterUpdates. Everyone will need to make an effort\n\t\t// to make rendering subresources as trackable as images\n\t\t// See https://github.com/framer/company/issues/20983\n\n\t\t// Wait for the content to actually paint, wait for 10 frames (166ms\n\t\t// when running 60fps), but maximum 10 seconds.\n\t\tawait Promise.race([\n\t\t\twaitForAnimationFrames(10),\n\t\t\tresolveAndWarnAfterTimeout(10_000, \"CanvasSandboxApp: didn\u2019t render after 10s\"),\n\t\t]).finally(() => {\n\t\t\tthis.isTrackingUpdates = false\n\t\t})\n\t}\n\n\tasync waitUntilAllFetchesAreDone() {\n\t\twhile (\n\t\t\tthis.tracker.isLoading() ||\n\t\t\tthis.tracker.isWaitingForFetchValueToResolve() ||\n\t\t\tthis.tracker.isWaitingForCollections() ||\n\t\t\tthis.tracker.isWaitingForLayoutTemplates() ||\n\t\t\tthis.tracker.isWaitingForModules()\n\t\t) {\n\t\t\tawait waitForAnimationFrames()\n\t\t}\n\t}\n\n\tasync renderingStateTrackerNotLoading() {\n\t\t// Wait for the the RenderingStateTracker to be settled (fetches done by\n\t\t// components etc.)\n\t\t// Timeout after 10s, because we don't want to wait forever.\n\t\tawait Promise.race([\n\t\t\tthis.waitUntilAllFetchesAreDone(),\n\t\t\tresolveAndWarnAfterTimeout(10_000, \"CanvasSandboxApp: didn\u2019t fetch all data after 10s\"),\n\t\t])\n\t}\n\n\tasync renderingQueuesDrained() {\n\t\tawait waitForAnimationFrames()\n\t\t// If the rendering queues are not empty, like images are scheduled to be switched by higher\n\t\t// resolution images, we are willing to wait a good while, but not forever.\n\t\tfor (let i = 0; i < 100; i++) {\n\t\t\tif (!renderingTaskQueues.hasImmediateTasksToRun()) return\n\t\t\tawait waitForAnimationFrames()\n\t\t}\n\t}\n\n\t// Ensure Framer fonts are loaded for parity with the editor frame.\n\treadonly framerFontStore = new FramerFontStore()\n\n\t/**\n\t * Render RichTextNode's outside of the canvas to determine their view box.\n\t */\n\tasync getFitTextViewBoxes(ids: NodeID[], update: number): Promise<ViewBoxMeasurement[]> {\n\t\t// Wait for the sandbox to be caught up to the editor at the time of the request.\n\t\twhile (this.lastEngineUpdate < update) {\n\t\t\tawait new Promise<void>(resolve => this.runAfterNextUpdate(resolve))\n\t\t}\n\n\t\t// Ensure all fonts are loaded.\n\t\tconst unloadedFonts: string[] = []\n\t\tfor (const node of this.tree.getNodesWithTrait(ids, isRichTextNode)) {\n\t\t\tunloadedFonts.push(...node.getFontsForLoading())\n\t\t}\n\t\tawait fontStore.loadFonts(unloadedFonts)\n\n\t\t// Measure and return the result.\n\t\treturn viewBoxMeasurementsForRichTextNodes(this.tracker, this.tree, ids)\n\t}\n\n\tasync checkTextWordBreak(ids: NodeID[], update: number): Promise<NodeID[]> {\n\t\t// Wait for the sandbox to be caught up to the editor at the time of the request.\n\t\twhile (this.lastEngineUpdate < update) {\n\t\t\tawait new Promise<void>(resolve => this.runAfterNextUpdate(resolve))\n\t\t}\n\n\t\tconst unloadedFonts: string[] = []\n\t\tfor (const node of this.tree.getNodesWithTrait(ids, isRichTextNode)) {\n\t\t\tunloadedFonts.push(...node.getFontsForLoading())\n\t\t}\n\t\tawait fontStore.loadFonts(unloadedFonts)\n\n\t\treturn checkTextWordBreakForRichTextNodes(this.tree, ids)\n\t}\n\n\tasync getComponentRenderingError(nodeId: NodeID): Promise<string | undefined> {\n\t\tconst error = this.tracker.getRenderingErrorForNode(nodeId)\n\t\treturn error?.message\n\t}\n\n\t/**\n\t * Measures nodes that have already rendered and returns the results outside\n\t * of the update / measure loop. Used to get on-demand measurements of code\n\t * component nodes for \"Fit Content\".\n\t */\n\tasync measureNodes(nodeIds: NodeID[]): Promise<LayoutMeasurement[]> {\n\t\t// If we are previewing effects, do not run measurements. We don't want\n\t\t// to measure any elements who's DOM size could be thrown off by\n\t\t// transforms.\n\t\tif (this.previousNodesInEffectPreview.length > 0) return []\n\t\tconst nodes = this.tree.getNodes(nodeIds)\n\t\tconst measurements = measureQueueForRenderedNodes(nodes).process({\n\t\t\tscopeId: this.scopeId,\n\t\t\tzoom: this.canvasZoom,\n\t\t\toffsetX: this.offsetX,\n\t\t\toffsetY: this.offsetY,\n\t\t\ttree: this.tree,\n\t\t\tgroundNodesInViewport: this.groundNodeIdsInViewport,\n\t\t})\n\n\t\tlog.trace(\"measureNodes:\", measurements.length)\n\t\treturn measurements\n\t}\n\n\tasync getViewportRect(nodeId: NodeID): Promise<{ x: number; y: number; width: number; height: number } | null> {\n\t\tconst element = document.getElementById(`id_${nodeId}`)\n\t\tif (!element) return null\n\t\tconst rect = element.getBoundingClientRect()\n\n\t\t// Ground nodes have 0x0 dimensions - use wrapper element instead\n\t\tif (rect.width === 0 && rect.height === 0) {\n\t\t\tconst wrapper = document.getElementById(nodeId)\n\t\t\tif (wrapper && wrapper !== element) {\n\t\t\t\tconst wrapperRect = wrapper.getBoundingClientRect()\n\t\t\t\treturn { x: wrapperRect.x, y: wrapperRect.y, width: wrapperRect.width, height: wrapperRect.height }\n\t\t\t}\n\t\t}\n\n\t\treturn { x: rect.x, y: rect.y, width: rect.width, height: rect.height }\n\t}\n\n\tasync waitUntilPlaceholdersSettled(): Promise<void> {\n\t\treturn waitUntilPlaceholdersSettled()\n\t}\n\n\t/**\n\t * Placeholder method, redefined at runtime by useCanvasRendererState in ./index.tsx.\n\t * @param callback - Called after React has rendered.\n\t */\n\ttriggerRenderer: (callback?: () => void) => void = () => undefined\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,gBAAkB;;;ACiBX,SAAS,6BACf,UACA,cACC;AAED,eAAa,yBAAyB;AACtC,eAAa,e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