{
  "version": 3,
  "sources": ["../../src/code-generation/utils/moduleAssetUrlsUtils.ts", "../../src/modulesRuntime/InitialModuleLoadTracker.ts", "../../src/modulesRuntime/mockRangeRequestLambda.ts", "../../src/modulesRuntime/utf16asUtf8.ts", "../../src/modulesRuntime/ModulesRuntime.ts"],
  "sourcesContent": ["import type { LocalModuleId } from \"@framerjs/shared\"\nimport { getLogger } from \"@framerjs/shared\"\nimport { imageUrlForAsset } from \"library/render/utils/imageUrlForAsset.ts\"\nimport { transparentImage } from \"utils/imageDataURIs.ts\"\n\nconst log = getLogger(\"moduleAssetsUrlUtils\")\n\n/**\n * @deprecated This is only needed for older modules that are downloaded from\n * the backend and recompiled because a dependency has changed. Newer modules\n * don't contain relative asset URLs anymore.\n */\nexport function rewriteAssetURLsIfNeeded(code: string, localId: LocalModuleId): string {\n\treturn code.replace(\n\t\t/\\bnew URL\\(\"assets\\/(?:(\\d+)\\/)?([^/\"]*)\",\\s*import\\.meta\\.url\\)\\.href\\b/gu,\n\t\t(match, assetSizeString, assetKey) => {\n\t\t\tif (!assetKey) {\n\t\t\t\tlog.reportError(Error(`Could not find asset key in \"${match}\" for module ${localId}`))\n\t\t\t\t// Fall back to an empty 1x1 GIF.\n\t\t\t\treturn JSON.stringify(transparentImage)\n\t\t\t}\n\t\t\tconst assetSize = assetSizeString ? Number.parseInt(assetSizeString) : undefined\n\t\t\treturn JSON.stringify(imageUrlForAsset(assetKey, assetSize))\n\t\t},\n\t)\n}\n", "import type { TypeSlashName } from \"../modules/types.ts\"\nimport type { InitialModuleLoadStats } from \"../utils/performanceTracker.ts\"\n\ninterface InitialModuleNetworkRequest {\n\turl: string\n\thasResourceTiming: boolean\n\tresourceTimingBytes: number | undefined\n\tcontentLengthBytes: number | undefined\n}\n\ninterface InitialModuleNetworkRequestHandle {\n\tsetContentLengthFromResponse(response: Response): void\n}\n\nfunction isPerformanceResourceTiming(entry: PerformanceEntry | undefined): entry is PerformanceResourceTiming {\n\treturn entry?.entryType === \"resource\"\n}\n\nfunction validByteCount(bytes: number | undefined): number | undefined {\n\tif (bytes === undefined || bytes < 0) return undefined\n\tif (!Number.isFinite(bytes)) return undefined\n\treturn bytes\n}\n\nfunction getResourceTimingNetworkBytes(entry: PerformanceResourceTiming | undefined): number | undefined {\n\tif (!entry) return undefined\n\treturn validByteCount(entry.encodedBodySize || entry.transferSize)\n}\n\nfunction getContentLengthBytes(response: Response): number | undefined {\n\tconst value = response.headers.get(\"content-length\")\n\tif (!value) return undefined\n\tconst bytes = Number(value)\n\treturn validByteCount(bytes)\n}\n\n/**\n * Tracks module work observed inside the canvas sandbox runtime before initial module\n * loading becomes idle. Module fetches are registered explicitly by the loader via\n * `startNetworkRequest` (so we don't rely on URL heuristics); everything else the\n * PerformanceObserver sees during the window is attributed to non-module deps.\n *\n * Single-shot: `take()` returns stats once and marks the tracker as done.\n */\nexport class InitialModuleLoadTracker {\n\tprivate isActive = false\n\tprivate hasReported = false\n\tprivate readonly localEvaluatedModules = new Set<TypeSlashName>()\n\tprivate readonly externalEvaluatedModules = new Set<string>()\n\tprivate readonly networkRequests: InitialModuleNetworkRequest[] = []\n\tprivate readonly networkRequestsByURL = new Map<string, InitialModuleNetworkRequest[]>()\n\tprivate nonModuleNetworkRequestCount = 0\n\tprivate nonModuleNetworkBytes = 0\n\tprivate networkObserver: PerformanceObserver | undefined\n\n\tstart(): void {\n\t\tif (this.isActive || this.hasReported) return\n\t\tthis.isActive = true\n\t\tthis.networkObserver = this.createNetworkObserver()\n\t}\n\n\ttrackLocalEvaluatedModules(modulesToEvaluate: Iterable<TypeSlashName>): void {\n\t\tif (!this.isActive) return\n\t\tfor (const typeSlashName of modulesToEvaluate) {\n\t\t\tthis.localEvaluatedModules.add(typeSlashName)\n\t\t}\n\t}\n\n\ttrackExternalEvaluatedModule(importSpecifier: string): void {\n\t\tif (!this.isActive) return\n\t\tthis.externalEvaluatedModules.add(importSpecifier)\n\t}\n\n\tstartNetworkRequest(url: string): InitialModuleNetworkRequestHandle | undefined {\n\t\tif (!this.isActive) return\n\n\t\tconst request: InitialModuleNetworkRequest = {\n\t\t\turl,\n\t\t\thasResourceTiming: false,\n\t\t\tresourceTimingBytes: undefined,\n\t\t\tcontentLengthBytes: undefined,\n\t\t}\n\t\tthis.networkRequests.push(request)\n\t\tconst requestsForURL = this.networkRequestsByURL.get(url)\n\t\tif (requestsForURL) {\n\t\t\trequestsForURL.push(request)\n\t\t} else {\n\t\t\tthis.networkRequestsByURL.set(url, [request])\n\t\t}\n\t\treturn {\n\t\t\tsetContentLengthFromResponse(response) {\n\t\t\t\trequest.contentLengthBytes = getContentLengthBytes(response)\n\t\t\t},\n\t\t}\n\t}\n\n\ttake(): InitialModuleLoadStats | undefined {\n\t\tif (!this.isActive) return\n\t\tif (this.hasReported) return\n\n\t\tthis.collectResourceTimingEntries(this.networkObserver?.takeRecords() ?? [])\n\t\tthis.hasReported = true\n\t\tthis.isActive = false\n\t\tconst stats: InitialModuleLoadStats = {\n\t\t\tlocalEvaluatedModulesCount: this.localEvaluatedModules.size,\n\t\t\texternalEvaluatedModulesCount: this.externalEvaluatedModules.size,\n\t\t\tmoduleNetworkRequestCount: this.networkRequests.length,\n\t\t\tmoduleNetworkBytes: Math.round(this.computeModuleNetworkBytes()),\n\t\t\tnonModuleNetworkRequestCount: this.nonModuleNetworkRequestCount,\n\t\t\tnonModuleNetworkBytes: Math.round(this.nonModuleNetworkBytes),\n\t\t}\n\t\tthis.clear()\n\t\treturn stats\n\t}\n\n\tprivate createNetworkObserver(): PerformanceObserver | undefined {\n\t\tif (typeof PerformanceObserver === \"undefined\") return undefined\n\n\t\tconst observer = new PerformanceObserver(list => {\n\t\t\tthis.collectResourceTimingEntries(list.getEntries())\n\t\t})\n\t\ttry {\n\t\t\tobserver.observe({ type: \"resource\" })\n\t\t\treturn observer\n\t\t} catch {\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\tprivate collectResourceTimingEntries(entries: PerformanceEntryList): void {\n\t\tif (!this.isActive) return\n\n\t\tfor (const entry of entries) {\n\t\t\tif (!isPerformanceResourceTiming(entry)) continue\n\n\t\t\tconst requestsForURL = this.networkRequestsByURL.get(entry.name)\n\t\t\tif (requestsForURL) {\n\t\t\t\tconst request = requestsForURL.find(candidate => !candidate.hasResourceTiming)\n\t\t\t\tif (request) {\n\t\t\t\t\trequest.hasResourceTiming = true\n\t\t\t\t\trequest.resourceTimingBytes = getResourceTimingNetworkBytes(entry)\n\t\t\t\t}\n\t\t\t\t// Extra entry for a known module URL \u2014 already accounted for, skip.\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// URL the loader never registered \u2014 counts as a non-module dep.\n\t\t\tthis.nonModuleNetworkRequestCount += 1\n\t\t\tthis.nonModuleNetworkBytes += getResourceTimingNetworkBytes(entry) ?? 0\n\t\t}\n\t}\n\n\tprivate computeModuleNetworkBytes(): number {\n\t\tlet bytes = 0\n\t\tfor (const request of this.networkRequests) {\n\t\t\tbytes += request.resourceTimingBytes ?? request.contentLengthBytes ?? 0\n\t\t}\n\t\treturn bytes\n\t}\n\n\tprivate clear(): void {\n\t\tthis.networkObserver?.disconnect()\n\t\tthis.networkObserver = undefined\n\t\tthis.localEvaluatedModules.clear()\n\t\tthis.externalEvaluatedModules.clear()\n\t\tthis.networkRequests.length = 0\n\t\tthis.networkRequestsByURL.clear()\n\t\tthis.nonModuleNetworkRequestCount = 0\n\t\tthis.nonModuleNetworkBytes = 0\n\t}\n}\n", "import { assert } from \"@framerjs/shared\"\nimport { isNumber, isString } from \"utils/typeChecks.ts\"\n\n/**\n * This function mocks the serve-cms-files lambda function for the\n * `ModulesRuntime` to resolve byte ranges from blob urls.\n *\n * We need this to fetch binary files from blobs URLs if they haven't been\n * uploaded to the backend yet.\n *\n * https://github.com/framer/FramerInfrastructureFunctions/tree/main/functions/serve-cms-files\n */\nexport function mockRangeRequestLambda(bytes: Uint8Array, rangeQuery: string) {\n\tlet totalBytes = 0\n\tconst parts: Uint8Array[] = []\n\n\tconst ranges = rangeQuery.split(\",\")\n\n\tfor (const range of ranges) {\n\t\tconst part = getRange(bytes, range)\n\n\t\tparts.push(part)\n\t\ttotalBytes += part.length\n\t}\n\n\tlet position = 0\n\tconst result = new Uint8Array(totalBytes)\n\n\tfor (const part of parts) {\n\t\tresult.set(part, position)\n\t\tposition += part.length\n\t}\n\n\treturn new Response(result)\n}\n\nfunction getRange(bytes: Uint8Array, range: string) {\n\tconst [startString, endString] = range.split(\"-\")\n\tassert(isString(endString), \"Invalid range\")\n\n\tconst start = parseInt(startString, 10)\n\tconst end = parseInt(endString, 10)\n\n\tassert(isNumber(start), \"Invalid range\")\n\tassert(isNumber(end), \"Invalid range\")\n\n\treturn bytes.subarray(start, end + 1)\n}\n", "/**\n * Converts a Unicode string to a string in which each 16-bit unit\n * is split into two 8-bit chars so that the string can be encoded with btoa.\n */\nexport function utf16asUtf8(utf16String: string): string {\n\tlet result = \"\"\n\tlet i = 0\n\tconst len = utf16String.length\n\twhile (i < len) {\n\t\t// Create 12-byte chunks of strings which is much more\n\t\t// efficient than appending to a single long string.\n\t\t// Note that every step of the loop reads a UTF-16 code\n\t\t// (2 bytes) and appends it as individual UTF-8 codes.\n\t\tlet chunk = \"\"\n\t\tfor (let j = 0; j < 4 && i + j < len; j++) {\n\t\t\tconst code = utf16String.charCodeAt(i + j)\n\t\t\tchunk += String.fromCharCode(code & 0xff, code >> 8)\n\t\t}\n\t\ti += 4\n\t\t// Appending a chunk instead of a single character leverages\n\t\t// the rope data structure that most JavaScript engines use.\n\t\tresult += chunk\n\t}\n\treturn result\n}\n", "import type { Patch } from \"@framerjs/app-shared/src/lib/immer.ts\"\nimport { applyPatches } from \"@framerjs/app-shared/src/lib/immer.ts\"\nimport type { EntityIdentifier } from \"@framerjs/framer-runtime\"\nimport type { SandboxEntityDefinition } from \"@framerjs/framer-runtime/sandbox\"\nimport { SandboxComponentLoader } from \"@framerjs/framer-runtime/sandbox\"\nimport { locks } from \"@framerjs/framer-runtime/utils/locks\"\nimport type { ModulesUpdates } from \"@framerjs/framer-services\"\nimport type {\n\tExternalModuleBareIdentifier,\n\tExternalModuleIdentifier,\n\tExternalModuleIdentifierString,\n\tLocalModuleId,\n\tLocalModuleIdentifierString,\n\tModuleIdentifier,\n} from \"@framerjs/shared\"\nimport {\n\tassert,\n\tdelay,\n\tDEPENDENCIES_MODULE_TYPE_SLASH_NAME,\n\tgetLogger,\n\tisLocalModuleIdentifier,\n\tlocalModuleIdentifier,\n\tlocalModuleImportMapSpecifier,\n\tModuleType,\n\tparseModuleIdentifier,\n\treportableError,\n\tResolvablePromise,\n\twithoutExportSpecifier,\n} from \"@framerjs/shared\"\nimport { QueryEngine } from \"library/modules/cms/QueryEngine.ts\"\nimport { filenamesFromModuleName } from \"modules/filenamesFromModuleName.ts\"\nimport { getSubmoduleImport, isSubmoduleImport } from \"modules/submodules.ts\"\nimport { getTypeSlashName, normalizePath } from \"modules/utils.ts\"\nimport { getKeys } from \"utils/getKeys.ts\"\nimport type { InitialModuleLoadStats } from \"utils/performanceTracker.ts\"\nimport { isString, isUndefined } from \"utils/typeChecks.ts\"\nimport { performanceClearMarks, performanceMark, performanceMeasure } from \"utils/userTiming.ts\"\nimport { rewriteAssetURLsIfNeeded } from \"../code-generation/utils/moduleAssetUrlsUtils.ts\"\nimport type {\n\tDependenciesModuleEntry,\n\tFastRefreshModuleEntry,\n\tLocalModuleEntry,\n\tModuleEntry,\n} from \"../modules/ModulesStorage.ts\"\nimport type { ImportMap, ModuleSpecifier, TypeSlashName } from \"../modules/types.ts\"\nimport type * as ReactRefreshRuntime from \"../preview-module/reactRefreshRuntime.ts\"\nimport type { Result } from \"../utils/result.ts\"\nimport { InitialModuleLoadTracker } from \"./InitialModuleLoadTracker.ts\"\nimport { collectModuleEntities, getModuleEvaluationError } from \"./collectModuleEntities.ts\"\nimport type {\n\tDefaultFetch,\n\tDefaultResolve,\n\tFetchHook,\n\tFetchInit,\n\tFetchInput,\n\tFetchSource,\n\tResolveHook,\n} from \"./importShim.ts\"\nimport {\n\tgetCurrentShimFetchHook,\n\tgetCurrentShimResolveHook,\n\timportShim,\n\tinstallShimFetchHook,\n\tinstallShimResolveHook,\n} from \"./importShim.ts\"\nimport { mockRangeRequestLambda } from \"./mockRangeRequestLambda.ts\"\nimport type {\n\tBinaryAssetBlobObjectURLs,\n\tEvaluatedModule,\n\tEvaluatedModuleKind,\n\tFastRefreshEvaluatedModule,\n\tLocalEvaluatedModule,\n\tModuleEvaluationResult,\n\tSubmoduleBlobObjectURLs,\n} from \"./types.ts\"\nimport { utf16asUtf8 } from \"./utf16asUtf8.ts\"\n\n/**\n * The modules runtime has 3 modes and can be either running or done.\n * Waiting: only buffering module updates.\n * LazyRunning: in lazy mode and currently evaluating modules.\n * LazyDone: in lazy mode and all modules that should be evaluated are done.\n * EagerRunning: in eager mode and currently evaluating modules.\n * EagerDone: in eager mode and all modules have evaluated.\n */\nexport type ModuleRuntimePhase = \"Waiting\" | \"LazyRunning\" | \"LazyDone\" | \"EagerRunning\" | \"EagerDone\"\n\nconst log = getLogger(\"modules-runtime\")\nconst resolveLog = getLogger(\"modules-resolver\")\n\n// Returns seconds quantized to milliseconds as string, for debugging.\nfunction seconds(millis: number): string {\n\treturn (millis / 1000).toFixed(3)\n}\n\nconst LOCKED_RESOURCE_NAME = \"update-modules-runtime\"\n\n// This list contains paths that are not relevant to the module update process.\n// Updates to these paths won't trigger a re-evaluation of the module. Inside\n// the runtime the files path is only used to determine the module filename for\n// the import map, and that is never supposed to change, so we can ignore\n// updates to it.\nconst ignoredModuleUpdatePatchPaths = new Set([\"files\"])\n\ntype ModulesUpdateEvent = Omit<ModulesUpdates.ModulesUpdateEvent, \"patches\" | \"prioritizedModules\"> & {\n\t// We are using a more concrete type for patches, because the ipc version of it is incomplete\n\t// due to the limitations of the ipc type system.\n\tpatches: Patch[]\n}\n\ntype ModuleCallback = (\n\tmoduleRecord: ModuleEvaluationResult | undefined,\n\tkind: EvaluatedModuleKind,\n\tsourceRevision: number | undefined,\n\tfastRefreshResult: FastRefreshResult | undefined,\n) => void\ntype ModuleCallbackDestructor = () => void\n\n/** Maintains a set of all code components that render a module. */\nclass ModuleSubscriptionsEntry {\n\tcallbacks = new Set<ModuleCallback>()\n\tconstructor(public evaluationResult: ModuleEvaluationResult | undefined) {}\n}\n\nclass ModuleNotFoundError extends Error {\n\tconstructor(typeSlashName: TypeSlashName) {\n\t\tsuper(`Module Not Found: '${typeSlashName}'`)\n\t}\n}\n\n/** Keeps track of code components that are rendering a module in render.tsx. */\nclass ModuleSubscriptions {\n\tprivate subscriptions = new Map<LocalModuleId, ModuleSubscriptionsEntry>()\n\n\t/** Subscribe a callback to be called if the exports for a module updates. Returns an\n\t * unsubscribe function. */\n\tadd(\n\t\tlocalId: LocalModuleId,\n\t\tcallback: ModuleCallback,\n\t\tevaluationResult: ModuleEvaluationResult | undefined,\n\t): ModuleCallbackDestructor {\n\t\tlet entry = this.subscriptions.get(localId)\n\t\tif (!entry) {\n\t\t\tentry = new ModuleSubscriptionsEntry(evaluationResult)\n\t\t\tthis.subscriptions.set(localId, entry)\n\t\t}\n\t\tentry.callbacks.add(callback)\n\t\treturn () => {\n\t\t\tthis.remove(localId, callback)\n\t\t}\n\t}\n\n\thas(localId: LocalModuleId): boolean {\n\t\treturn this.subscriptions.has(localId)\n\t}\n\n\tprivate remove(localId: LocalModuleId, callback: ModuleCallback): void {\n\t\tconst entry = this.subscriptions.get(localId)\n\t\tif (!entry) return\n\t\tentry.callbacks.delete(callback)\n\t\tif (entry.callbacks.size > 0) return\n\t\tthis.subscriptions.delete(localId)\n\t}\n\n\tprivate moduleEvaluationResult(\n\t\tmodule: EvaluatedModule | undefined,\n\t\ttypeSlashName: TypeSlashName,\n\t\tsubscriptions: ModuleSubscriptionsEntry | undefined,\n\t): ModuleEvaluationResult | undefined {\n\t\tif (module) {\n\t\t\t// If the module exists, and it has evaluated, we should still not publish this unless\n\t\t\t// it is also available in the component loader.\n\t\t\tif (!module.inComponentLoader) return undefined\n\t\t\treturn module.evaluationResult\n\t\t}\n\n\t\t// If the module was not found, we return the current module not found error if it exists.\n\t\t// This prevents signalling subscribers with new errors that are structurally the same.\n\t\tif (subscriptions?.evaluationResult instanceof ModuleNotFoundError) return subscriptions.evaluationResult\n\t\treturn new ModuleNotFoundError(`Module Not Found: '${typeSlashName}'`)\n\t}\n\n\tgetEvaluationResult(evaluatedModules: Map<TypeSlashName, EvaluatedModule>, typeSlashName: TypeSlashName) {\n\t\tconst module = evaluatedModules.get(typeSlashName)\n\t\tconst subscriptions = module ? this.subscriptions.get(module.localId) : undefined\n\t\treturn this.moduleEvaluationResult(module, typeSlashName, subscriptions)\n\t}\n\n\tprocessEvaluationResults(\n\t\tevaluatedModules: Map<TypeSlashName, EvaluatedModule>,\n\t\tfastRefreshResults: Map<LocalModuleId, FastRefreshResult>,\n\t) {\n\t\tfor (const [typeSlashName, module] of evaluatedModules) {\n\t\t\tconst subscription = this.subscriptions.get(module.localId)\n\t\t\tif (!subscription) continue\n\t\t\tconst evaluationResult = this.moduleEvaluationResult(module, typeSlashName, subscription)\n\t\t\tif (subscription.evaluationResult === evaluationResult) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsubscription.evaluationResult = evaluationResult\n\t\t\tconst fastRefreshResult = fastRefreshResults.get(module.localId)\n\t\t\tlog.trace(\"running callbacks for:\", typeSlashName, subscription.callbacks.size)\n\t\t\tfor (const callback of subscription.callbacks) {\n\t\t\t\tcallback(evaluationResult, module.kind, module.sourceRevision, fastRefreshResult)\n\t\t\t}\n\t\t}\n\t}\n\n\tisLoadingSubscriptions(): boolean {\n\t\tfor (const entry of this.subscriptions.values()) {\n\t\t\tif (!entry.evaluationResult) return true\n\t\t}\n\n\t\treturn false\n\t}\n}\n\n/** Will try to return a type slash name from a local id, but if not possible, will return \"error/unknown\". */\nfunction typeSlashNameFromLocalIdOrError(localId: LocalModuleId): TypeSlashName {\n\tconst identifier = parseModuleIdentifier(localId)\n\tif (isLocalModuleIdentifier(identifier) && identifier.type === ModuleType.Canvas) return identifier.localId\n\treturn \"error/unknown\"\n}\n\ntype EvaluationMode = \"waiting\" | \"lazy\" | \"eager\"\n\nexport interface ModuleRuntimeStateChangedListener {\n\tlocalModulesLoaded(\n\t\tentitiesToUpdate: SandboxEntityDefinition<unknown>[],\n\t\tentitiesToDelete: string[],\n\t\tmodulesRevision: number,\n\t\tlazyModulesRevision: number,\n\t): void\n\texternalModulesLoadingStateChange?(loading: boolean): void\n\texternalModuleLoaded(identifier: ExternalModuleIdentifierString, entities: SandboxEntityDefinition<unknown>[]): void\n\n\t/**\n\t * represents isLoadingAnything, which includes both local and external modules\n\t * called after changes to loading state in synchronize lock, after task is done\n\t */\n\tloadingStateChanged?(loading: boolean): void\n\n\t/**\n\t * Relay a typed loading performance mark from the sandbox to the editor realm so it shows up\n\t * in the loader timeline and telemetry. Optional so test doubles don't have to implement it.\n\t */\n\tmarkLoadingPerf?(mark: SandboxLoadingMark): void\n\n\t/**\n\t * Relay a dynamic (string-named) loading performance mark from the sandbox to the editor\n\t * realm. Used for unbounded sequences (e.g. one per module-evaluation batch); only shown in\n\t * the in-UI debug loader, never reported in telemetry. Optional so test doubles don't have\n\t * to implement it.\n\t */\n\tmarkLoadingPerfDynamic?(name: string, label: string): void\n}\n\n/** Subset of {@link Mark} that the sandbox can emit. Kept separate from the full {@link Mark}\n * union so the sandbox can't accidentally relay marks that belong to other phases. */\nexport type SandboxLoadingMark =\n\t| \"sandboxModulesListReceived\"\n\t| \"sandboxFirstBatchEvaluated\"\n\t| \"sandboxEvaluateModulesEnd\"\n\t| \"sandboxExternalModulesIdle\"\n\t| \"sandboxTrackerIdle\"\n\t| \"sandboxScopeLoadingDebounceEnter\"\n\nexport class ModulesRuntime {\n\treadonly componentLoader = new SandboxComponentLoader()\n\n\tpublic get phase(): ModuleRuntimePhase {\n\t\tif (this.mode === \"waiting\") return \"Waiting\"\n\t\tif (this.mode === \"lazy\") return this.tasksRunningOrWaiting > 0 ? \"LazyRunning\" : \"LazyDone\"\n\t\treturn this.tasksRunningOrWaiting > 0 ? \"EagerRunning\" : \"EagerDone\"\n\t}\n\n\tpublic get status(): \"Done\" | \"Running\" {\n\t\tconst currentPhase = this.phase\n\n\t\treturn currentPhase === \"LazyDone\" || currentPhase === \"EagerDone\" ? \"Done\" : \"Running\"\n\t}\n\n\tprivate tasksRunningOrWaiting = 0\n\tprivate inSynchronizeBlock = false\n\tprivate moduleRevision = -1\n\tprivate lazyRevision = 0\n\n\t/** When mode is \"lazy\", components that are not needed for rendering, are not evaluated as they\n\t * receive updates. Only when some renderer calls subscribeToModuleComponent. And then updates\n\t * are pushed through such subscriptions. */\n\tconstructor(\n\t\tprivate mode: EvaluationMode,\n\t\tprivate moduleStateListener: ModuleRuntimeStateChangedListener,\n\t) {\n\t\tinstallShimResolveHook(this.resolveHook)\n\t\tinstallShimFetchHook(this.fetchHook)\n\t}\n\n\tprivate get isReady() {\n\t\tif (this.moduleRevision < 0) return false\n\t\tif (this.userImportMapInitializedPromise.state === \"pending\") return false\n\n\t\treturn true\n\t}\n\n\tisLoadingAnything() {\n\t\t// If we have never received any list of modules, report we are loading.\n\t\tif (!this.isReady) return true\n\t\treturn this.tasksRunningOrWaiting > 0 || this.externalModuleImportsInFlight > 0\n\t}\n\n\tpublic takeInitialModuleLoadStats(): InitialModuleLoadStats | undefined {\n\t\treturn this.initialModuleLoadTracker.take()\n\t}\n\n\tprivate notifyLoadingStateChangedIfIdle(): void {\n\t\tif (this.isLoadingAnything()) return\n\t\tthis.moduleStateListener.loadingStateChanged?.(false)\n\t}\n\n\t/** The modules as we receive them from the modules storage. */\n\tprivate compiledModules = new Map<TypeSlashName, ModuleEntry>()\n\n\tprivate fastRefreshPreviousEvaluationResults = new Map<TypeSlashName, ModuleEvaluationResult>()\n\n\t/** The modules we have evaluated, or are about to evaluate. */\n\tprivate evaluatedModules = new Map<TypeSlashName, EvaluatedModule>()\n\n\tprivate readonly initialModuleLoadTracker = new InitialModuleLoadTracker()\n\n\t/** Mapping local modules via their blob url to help resolve imports. */\n\tprivate compiledModulesByBlobObjectURL = new Map<string, LocalModuleEntry | FastRefreshModuleEntry>()\n\n\t/** Mapping local modules via their module url to help resolve imports. */\n\tprivate compiledModulesByModuleURL = new Map<string, LocalEvaluatedModule | FastRefreshEvaluatedModule>()\n\n\tprivate submoduleBlobObjectURLsByBlobObjectURL = new Map<ModuleSpecifier, SubmoduleBlobObjectURLs>()\n\tprivate binaryAssetBlobObjectURLsByBlobObjectURL = new Map<ModuleSpecifier, BinaryAssetBlobObjectURLs>()\n\n\t// We can't revoke blob object URLs immediately, because they might still be\n\t// in used by the CanvasRenderer when we are evaluating the new modules and\n\t// the component loader isn't updated yet.\n\tprivate blobObjectURLsToRevoke = new Set<ModuleSpecifier>()\n\n\t// We never delete items from this map, so this will only grow in memory.\n\t// It's probably fine, because it's only strings, but good to be aware of.\n\tprivate typeSlashNameByLocalId = new Map<LocalModuleId, TypeSlashName>()\n\n\tprivate userImportMapInitializedPromise = new ResolvablePromise<void>().pending()\n\n\tprivate externalModuleImportsInFlight = 0\n\n\t/** Keeps track of code components that are rendering a module. */\n\tprivate moduleSubscriptions = new ModuleSubscriptions()\n\n\tprivate getEvaluationResultForLocalId(localId: LocalModuleId): ModuleEvaluationResult | undefined {\n\t\t// It is important we always have a typeSlashName, so we can return an error state if the\n\t\t// module does not exist.\n\t\tconst typeSlashName = this.typeSlashNameByLocalId.get(localId) ?? typeSlashNameFromLocalIdOrError(localId)\n\t\treturn this.moduleSubscriptions.getEvaluationResult(this.evaluatedModules, typeSlashName)\n\t}\n\n\t/** Returns the exports of a module, a ModuleNotFoundError, or undefined if still evaluating. */\n\tgetLocalModuleExports(moduleIdentifier: LocalModuleIdentifierString): ModuleEvaluationResult | undefined {\n\t\t// If we have never received any list of modules, report the module is loading.\n\t\tif (!this.isReady) return undefined\n\t\tconst { localId } = parseModuleIdentifier(moduleIdentifier)\n\t\treturn this.getEvaluationResultForLocalId(localId)\n\t}\n\n\t/**\n\t * Get evaluated module by local identifier\n\t *\n\t * This module returns `undefined` if\n\t *   1. Module has never been evaluated before\n\t *   2. Module is disposed\n\t *   3. Module is still being evaluated\n\t *      - This typically happens when new module data is retrieved\n\t *        from the server, which clears the evaluation result and\n\t *        starts a new evaluation asynchronously.\n\t */\n\tgetEvaluatedModule(moduleIdentifier: LocalModuleIdentifierString): EvaluatedModule | undefined {\n\t\tconst { localId } = parseModuleIdentifier(moduleIdentifier)\n\t\tconst module = this.evaluatedModules.get(localId)\n\n\t\tif (module?.evaluationResult) {\n\t\t\treturn module\n\t\t}\n\n\t\treturn undefined\n\t}\n\n\t/** Subscribe a callback to be called if the exports for a module changes. Returns an\n\t * unsubscribe function. */\n\tsubscribeToLocalModuleExports(\n\t\tmoduleIdentifier: LocalModuleIdentifierString,\n\t\tcallback: ModuleCallback,\n\t): ModuleCallbackDestructor {\n\t\tconst { localId } = parseModuleIdentifier(moduleIdentifier)\n\t\tconst evaluationResult = this.getEvaluationResultForLocalId(localId)\n\n\t\tif (!evaluationResult) {\n\t\t\tthis.evaluateDelayedModulesDebounced()\n\t\t}\n\t\treturn this.moduleSubscriptions.add(localId, callback, evaluationResult)\n\t}\n\n\tsetEvaluationMode(mode: EvaluationMode): void {\n\t\tif (this.mode === mode) return\n\n\t\tlog.debug(\"changing evaluation mode:\", this.mode, \"->\", mode)\n\t\tthis.mode = mode\n\t\tthis.evaluateDelayedModules()\n\t\tassert(this.tasksRunningOrWaiting, \"changing mode must have scheduled a task\")\n\t}\n\n\tprivate evaluateModulesForRenderersTimer = 0\n\tprivate evaluateDelayedModulesDebounced() {\n\t\tif (this.evaluateModulesForRenderersTimer) return\n\t\tthis.evaluateModulesForRenderersTimer = window.setTimeout(() => {\n\t\t\tthis.evaluateModulesForRenderersTimer = 0\n\t\t\tthis.evaluateDelayedModules()\n\t\t}, 0)\n\t}\n\n\tprivate evaluateDelayedModules() {\n\t\tvoid this.synchronize(async () => {\n\t\t\tif (this.mode === \"waiting\") {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst modulesToEvaluate = new Set<TypeSlashName>()\n\n\t\t\t// Go over all modules that don't have an evaluation result yet. In eager mode we\n\t\t\t// evaluate them all. In lazy mode, we only evaluate them if they have a subscription\n\t\t\t// (are being rendered on the canvas).\n\t\t\tfor (const [typeSlashName, evaluated] of this.evaluatedModules) {\n\t\t\t\tif (evaluated.evaluationResult) continue\n\t\t\t\tif (this.mode === \"lazy\" && !this.moduleSubscriptions.has(evaluated.localId)) continue\n\t\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t\t}\n\n\t\t\tif (modulesToEvaluate.size === 0) {\n\t\t\t\t// If we reached here it means there were no modules to evaluate, but we want to notify\n\t\t\t\t// the listener that we are done evaluating so they have a chance to update their state.\n\t\t\t\tthis.moduleStateListener.localModulesLoaded([], [], this.moduleRevision, this.lazyRevision)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.lazyRevision += 1\n\t\t\tlet fastRefreshResults: Map<LocalModuleId, FastRefreshResult> = new Map()\n\t\t\tif (this.mode === \"eager\") {\n\t\t\t\t// If we are in eager mode, but there are delayed modules, we evaluate them in batches.\n\t\t\t\tfastRefreshResults = await this.evaluateModulesInBatches(modulesToEvaluate, this.mode)\n\t\t\t} else {\n\t\t\t\tfastRefreshResults = await this.evaluateModules(modulesToEvaluate, this.mode)\n\t\t\t}\n\t\t\tconst entitiesToUpdate = await this.processEvaluationForComponentLoader(modulesToEvaluate)\n\t\t\tthis.moduleSubscriptions.processEvaluationResults(this.evaluatedModules, fastRefreshResults)\n\t\t\tthis.moduleStateListener.localModulesLoaded(entitiesToUpdate, [], this.moduleRevision, this.lazyRevision)\n\t\t})\n\t}\n\n\t/**\n\t * Keeps track of the modules that are currently being loaded.\n\t * `loadPromise` is resolved when the module is evaluated and its \"entities\"\n\t * are added to `sandboxComponentLoader`.\n\t */\n\tprivate externalModuleImportPromises = new Map<\n\t\tstring,\n\t\t{ identifier: ExternalModuleBareIdentifier; loadPromise: ResolvablePromise<void> }\n\t>()\n\n\tpublic async insertTemporaryImportMap(importMap: ImportMap): Promise<void> {\n\t\tawait this.userImportMapInitializedPromise\n\t\tconst importMapId = `framer-temp-importmap-${Math.random()}` as const\n\t\tthis.updateImportMap(importMap, importMapId)\n\t}\n\n\tasync loadLocalModules(moduleIdentifiers: Set<LocalModuleIdentifierString>): Promise<void> {\n\t\tawait this.userImportMapInitializedPromise\n\t\tawait this.synchronize(async () => {\n\t\t\tif (this.mode !== \"lazy\") return\n\n\t\t\tconst modulesToEvaluate = new Set<string>()\n\t\t\tfor (const moduleIdentifier of moduleIdentifiers) {\n\t\t\t\tconst { localId } = parseModuleIdentifier(moduleIdentifier)\n\t\t\t\tconst typeSlashName = this.typeSlashNameByLocalId.get(localId)\n\t\t\t\tif (!typeSlashName) continue\n\t\t\t\tconst evaluated = this.evaluatedModules.get(typeSlashName)\n\t\t\t\tif (evaluated && evaluated.evaluationResult) continue\n\t\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t\t}\n\t\t\tawait this.evaluateAndProcessModules(modulesToEvaluate)\n\t\t})\n\t}\n\n\tasync loadAllLocalModules(): Promise<void> {\n\t\tawait this.userImportMapInitializedPromise\n\t\tawait this.synchronize(async () => {\n\t\t\tif (this.mode !== \"lazy\") return\n\n\t\t\tconst modulesToEvaluate = new Set<string>()\n\t\t\tfor (const [typeSlashName, evaluated] of this.evaluatedModules) {\n\t\t\t\tif (evaluated.evaluationResult) continue\n\t\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t\t}\n\t\t\tawait this.evaluateAndProcessModules(modulesToEvaluate)\n\t\t})\n\t}\n\n\t/**\n\t * This method checks if any module subscriptions are not evaluated yet.\n\t *\n\t * @returns true if there is local module currently being rendered that hasn't loaded yet.\n\t */\n\tpublic isLoadingSubscriptions(): boolean {\n\t\treturn this.moduleSubscriptions.isLoadingSubscriptions()\n\t}\n\n\t/**\n\t *\n\t * @param modulesToEvaluate a set of typeSlashNames\n\t * @returns\n\t */\n\tprivate async evaluateAndProcessModules(modulesToEvaluate: Set<string>) {\n\t\tif (modulesToEvaluate.size === 0) {\n\t\t\t// If we reached here it means there were some modules deleted\n\t\t\tlog.debug(\"no modules to evaluate\", this.lazyRevision, this.mode, this.phase)\n\t\t\tthis.moduleStateListener.localModulesLoaded([], [], this.moduleRevision, this.lazyRevision)\n\t\t\treturn\n\t\t}\n\n\t\tthis.lazyRevision += 1\n\t\tconst fastRefreshResults = await this.evaluateModules(modulesToEvaluate, this.mode)\n\t\tconst entitiesToUpdate = await this.processEvaluationForComponentLoader(modulesToEvaluate)\n\t\tthis.moduleSubscriptions.processEvaluationResults(this.evaluatedModules, fastRefreshResults)\n\t\tthis.moduleStateListener.localModulesLoaded(entitiesToUpdate, [], this.moduleRevision, this.lazyRevision)\n\t}\n\n\t/** Returns true if the module is known to the runtime. */\n\tpublic moduleExists(identifierString: LocalModuleIdentifierString | ExternalModuleIdentifierString): boolean {\n\t\t// If we have never received any list of modules, we report all modules existing. But since\n\t\t// they won't have any data, they will look like they are loading.\n\t\tif (!this.isReady) return true\n\n\t\tconst identifier = parseModuleIdentifier(identifierString)\n\t\tif (isLocalModuleIdentifier(identifier)) {\n\t\t\tconst typeSlashName =\n\t\t\t\tthis.typeSlashNameByLocalId.get(identifier.localId) ?? typeSlashNameFromLocalIdOrError(identifier.localId)\n\t\t\treturn this.evaluatedModules.has(typeSlashName)\n\t\t}\n\n\t\treturn this.externalModuleImportPromises.has(identifier.importSpecifier)\n\t}\n\n\tpublic async ensureExternalModuleLoaded(\n\t\tidentifier: ExternalModuleIdentifier,\n\t\t{ force }: { force?: boolean } = {},\n\t): Promise<void> {\n\t\tlog.debug(\"ensureExternalModuleLoaded:\", identifier.value, \"force:\", force)\n\t\t// Use the bare module identifier since the remaining logic will be per\n\t\t// module, not per entity.\n\t\tidentifier = withoutExportSpecifier(identifier)\n\n\t\t// Wait for the project import map to be initialized because it may be\n\t\t// required for the external modules' evaluation.\n\t\tawait this.userImportMapInitializedPromise\n\n\t\tconst { importSpecifier } = identifier\n\t\tlet loadPromise = this.externalModuleImportPromises.get(importSpecifier)?.loadPromise\n\t\tif (loadPromise && !force) return loadPromise\n\n\t\tthis.initialModuleLoadTracker.trackExternalEvaluatedModule(importSpecifier)\n\n\t\tloadPromise = new ResolvablePromise()\n\t\tthis.externalModuleImportPromises.set(importSpecifier, { identifier, loadPromise })\n\t\tthis.externalModuleImportsInFlight += 1\n\n\t\tlet evaluationResult: Result<Record<string, unknown>, Error> | undefined\n\t\ttry {\n\t\t\t// When the first external module starts loading notify the listener\n\t\t\tif (this.externalModuleImportsInFlight === 1) {\n\t\t\t\tthis.moduleStateListener.externalModulesLoadingStateChange?.(true)\n\t\t\t}\n\t\t\tconst moduleURL = new URL(importSpecifier)\n\t\t\tmoduleURL.searchParams.set(\"t\", String(Date.now()))\n\t\t\tconst moduleEvaluation = await importShim(moduleURL.href)\n\t\t\tconst maybeError = getModuleEvaluationError(moduleEvaluation)\n\t\t\tif (maybeError) {\n\t\t\t\tevaluationResult = { ok: false, error: maybeError }\n\t\t\t} else {\n\t\t\t\tevaluationResult = { ok: true, value: moduleEvaluation }\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tevaluationResult = { ok: false, error: reportableError(error) }\n\t\t}\n\n\t\tconst entities: SandboxEntityDefinition[] = []\n\t\ttry {\n\t\t\tawait this.collectModuleEntities(\n\t\t\t\tidentifier,\n\t\t\t\tevaluationResult.ok ? evaluationResult.value : evaluationResult.error,\n\t\t\t\tentities,\n\t\t\t\tundefined,\n\t\t\t\t0, // We don't care about update in external modules\n\t\t\t)\n\t\t\tthis.componentLoader.updateModuleEntities(entities)\n\t\t} catch (error) {\n\t\t\tevaluationResult = { ok: false, error: reportableError(error) }\n\t\t} finally {\n\t\t\t// `collectModuleEntities` normally shouldn't throw, but we're being\n\t\t\t// extra vigilant here to prevent `this.externalModuleImportsInFlight`\n\t\t\t// from being unbalanced if `collectModuleEntities` throws an error.\n\t\t\tthis.externalModuleImportsInFlight -= 1\n\t\t}\n\n\t\tif (evaluationResult.ok) {\n\t\t\tloadPromise.resolve()\n\t\t} else {\n\t\t\tloadPromise.reject(evaluationResult.error)\n\t\t}\n\n\t\t// When the last external module is loaded notify the listener\n\t\tif (this.externalModuleImportsInFlight === 0) {\n\t\t\tthis.moduleStateListener.externalModulesLoadingStateChange?.(false)\n\t\t\tif (!this.hasEmittedExternalModulesIdleMark) {\n\t\t\t\tthis.hasEmittedExternalModulesIdleMark = true\n\t\t\t\tthis.moduleStateListener.markLoadingPerf?.(\"sandboxExternalModulesIdle\")\n\t\t\t}\n\t\t}\n\n\t\t// Notify Vekter about the update of the sandboxComponentLoader state (only happening on Canvas)\n\t\tlog.trace(\"notify externalModuleLoaded:\", identifier.value)\n\t\tthis.moduleStateListener.externalModuleLoaded(identifier.value, entities)\n\n\t\treturn loadPromise\n\t}\n\n\tpublic async handleLocalModulesUpdate(updateEvent: ModulesUpdateEvent): Promise<void> {\n\t\tlog.debug(\"update:\", updateEvent.revision, updateEvent.dependentModules.length)\n\t\treturn this.synchronize(() => this.handleLocalModulesUpdateLocked(updateEvent))\n\t}\n\n\tprivate hasEmittedListReceivedMark = false\n\tprivate hasEmittedExternalModulesIdleMark = false\n\n\tprivate async handleLocalModulesUpdateLocked(updateEvent: ModulesUpdateEvent) {\n\t\tlog.debug(\"update:\", updateEvent.revision, updateEvent.dependentModules.length, \"mode:\", this.mode)\n\t\tconst isFirstUpdate = this.moduleRevision < 0\n\t\tthis.moduleRevision = updateEvent.revision\n\t\tassert(this.moduleRevision >= 0, \"moduleRevision must be >= 0\")\n\t\tthis.lazyRevision = 0\n\n\t\tif (isFirstUpdate && !this.hasEmittedListReceivedMark) {\n\t\t\tthis.initialModuleLoadTracker.start()\n\t\t\tthis.hasEmittedListReceivedMark = true\n\t\t\tthis.moduleStateListener.markLoadingPerf?.(\"sandboxModulesListReceived\")\n\t\t}\n\n\t\tconst patches = updateEvent.patches\n\n\t\t// If `patches` contain an importMap patch, handle it separately and remove from the array.\n\t\tconst importMapPatchIndex = patches.findIndex(patch => patch.path[0] === DEPENDENCIES_MODULE_TYPE_SLASH_NAME)\n\t\tif (importMapPatchIndex !== -1) {\n\t\t\tconst [importMapPatch] = patches.splice(importMapPatchIndex, 1)\n\t\t\tassert(importMapPatch, \"Import map patch must be defined\")\n\t\t\tconst dependenciesModule: DependenciesModuleEntry = importMapPatch.value\n\t\t\tthis.updateImportMap(JSON.parse(dependenciesModule.importMapContent), \"framer-user-importmap\")\n\n\t\t\tfor (const { identifier } of this.externalModuleImportPromises.values()) {\n\t\t\t\tthis.ensureExternalModuleLoaded(identifier, { force: true }).catch(e => {\n\t\t\t\t\tlog.error(`Failed to re-evaluate external module ${identifier.importSpecifier}`, e)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (updateEvent.initialized) {\n\t\t\t// After receiving the first \"initialized\" update we know that\n\t\t\t// if there is a project import map, it's already loaded and inserted.\n\t\t\tthis.userImportMapInitializedPromise.resolve()\n\t\t}\n\n\t\tif (patches.length === 0 && updateEvent.dependentModules.length === 0) return\n\n\t\tconst updatedModules = new Set<TypeSlashName>()\n\t\tconst deletedModules = new Set<TypeSlashName>()\n\t\t// Includes both updated modules and dependent modules\n\t\tconst modulesToPrepare = new Set<TypeSlashName>(updateEvent.dependentModules)\n\t\tthis.compiledModules = applyPatches(this.compiledModules, patches)\n\t\tpatches.forEach(patch => {\n\t\t\tconst typeSlashName = patch.path[0]\n\t\t\tassert(typeof typeSlashName === \"string\")\n\n\t\t\tif (patch.op === \"remove\" && patch.path.length === 1) {\n\t\t\t\tdeletedModules.add(typeSlashName)\n\t\t\t} else {\n\t\t\t\tif (patch.op === \"replace\" && patch.path.length === 2) {\n\t\t\t\t\tconst path = patch.path[1]\n\t\t\t\t\t// Specifically ignore updates to the files path, because\n\t\t\t\t\t// the module filename should never change.\n\t\t\t\t\tif (isString(path) && ignoredModuleUpdatePatchPaths.has(path)) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tupdatedModules.add(typeSlashName)\n\t\t\t\tmodulesToPrepare.add(typeSlashName)\n\t\t\t}\n\t\t})\n\n\t\t// The modules to evaluate must always include all modules that are\n\t\t// needed from modulesToPrepare, because in `prepareForEvaluation`, we\n\t\t// remove the evaluation results of every module listed in\n\t\t// modulesToPrepare.\n\t\tconst modulesToEvaluate = new Set<TypeSlashName>()\n\t\tconst mode = this.mode\n\t\tmodulesToPrepare.forEach(typeSlashName => {\n\t\t\tconst module = this.compiledModules.get(typeSlashName)\n\t\t\tif (!module) {\n\t\t\t\tlog.reportError(\"compiledModules is missing module that is needed for evaluation\", {\n\t\t\t\t\ttypeSlashName,\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.typeSlashNameByLocalId.set(module.localId, typeSlashName)\n\n\t\t\t// In waiting mode, we don't run any modules.\n\t\t\tif (mode === \"waiting\") return\n\n\t\t\t// In eager mode, we run all modules.\n\t\t\tif (mode === \"eager\") {\n\t\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Otherwise we are in lazy mode, we run rendered modules.\n\t\t\tif (module.kind === \"fast-refresh\") {\n\t\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t\t\tconst prevEvaluatedModule = this.evaluatedModules.get(typeSlashName)\n\t\t\t\tif (\n\t\t\t\t\tprevEvaluatedModule &&\n\t\t\t\t\tprevEvaluatedModule.kind === \"fast-refresh\" &&\n\t\t\t\t\tprevEvaluatedModule.evaluationResult\n\t\t\t\t) {\n\t\t\t\t\tthis.fastRefreshPreviousEvaluationResults.set(typeSlashName, prevEvaluatedModule.evaluationResult)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.moduleSubscriptions.has(module.localId)) {\n\t\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Otherwise we skip evaluating canvas components, screen modules, vectors, or metadata modules.\n\t\t\tif (module.type === ModuleType.Screen) return\n\t\t\tif (module.type === ModuleType.Canvas) return\n\t\t\tif (module.type === ModuleType.Vector) return\n\t\t\tif (module.type === ModuleType.WebPageMetadata) return\n\t\t\tmodulesToEvaluate.add(typeSlashName)\n\t\t})\n\n\t\tconst entitiesToDelete: EntityIdentifier[] = []\n\t\tfor (const typeSlashName of deletedModules) {\n\t\t\tconst entityIdsToDelete = this.disposeEvaluatedModule(typeSlashName)\n\t\t\tthis.componentLoader.deleteModuleEntities(entityIdsToDelete)\n\t\t\tentitiesToDelete.push(...entityIdsToDelete)\n\t\t}\n\n\t\t// If there is nothing to re-evaluate, exit early.\n\t\tif (modulesToPrepare.size === 0) {\n\t\t\t// If we reached here it means there were some modules deleted\n\t\t\t// we still need to update the component loader state in this case.\n\t\t\tlog.debug(\"no modules to evaluate\", this.lazyRevision, this.mode, this.phase)\n\t\t\tthis.moduleStateListener.localModulesLoaded([], entitiesToDelete, this.moduleRevision, this.lazyRevision)\n\t\t\treturn\n\t\t}\n\n\t\tconst { entitiesToUpdate, entityIdsToDelete, fastRefreshResults } = await this.prepareAndEvaluateModules(\n\t\t\tmodulesToPrepare,\n\t\t\tmodulesToEvaluate,\n\t\t\tupdatedModules,\n\t\t\tupdateEvent.initialized,\n\t\t)\n\t\tthis.moduleSubscriptions.processEvaluationResults(this.evaluatedModules, fastRefreshResults)\n\n\t\tentitiesToDelete.push(...entityIdsToDelete)\n\t\tthis.moduleStateListener.localModulesLoaded(\n\t\t\tentitiesToUpdate,\n\t\t\tentitiesToDelete,\n\t\t\tthis.moduleRevision,\n\t\t\tthis.lazyRevision,\n\t\t)\n\t\tthis.revokeBlobObjectURLs()\n\t}\n\n\tprivate async prepareAndEvaluateModules(\n\t\tmodulesToPrepare: Set<TypeSlashName>,\n\t\tmodulesToEvaluate: Set<TypeSlashName>,\n\t\tupdatedModules: Set<TypeSlashName>,\n\t\tinitialized: boolean,\n\t): Promise<{\n\t\tentitiesToUpdate: SandboxEntityDefinition[]\n\t\tentityIdsToDelete: string[]\n\t\tfastRefreshResults: Map<LocalModuleId, FastRefreshResult>\n\t}> {\n\t\tconst { entityIdsToDelete } = this.prepareForEvaluation(modulesToPrepare, updatedModules)\n\n\t\tconst initialFastRefreshResults = await this.evaluateModules(modulesToEvaluate, this.mode)\n\n\t\t// evaluateFastRefreshResults recursively calls prepareAndEvaluateModules to re-evaluate the\n\t\t// modules that are dependent on the module that failed to fast-refresh. Therefor it updates\n\t\t// this.evaluatedModules which are processed in processEvaluationResultsForComponentLoader.\n\t\tconst fastRefreshResults = await this.evaluateFastRefreshResults(initialFastRefreshResults, initialized)\n\n\t\tconst entitiesToUpdate = await this.processEvaluationForComponentLoader(\n\t\t\tmodulesToEvaluate,\n\t\t\tentityIdsToDelete,\n\t\t\tinitialized,\n\t\t)\n\n\t\treturn { entitiesToUpdate, entityIdsToDelete, fastRefreshResults }\n\t}\n\n\tprivate splitFastRefreshResults(fastRefreshResults: Map<LocalModuleId, FastRefreshResult>): {\n\t\tsuccesfullyRefreshedModules: Map<LocalModuleId, FastRefreshResult>\n\t\tfailedFastRefreshModules: Set<TypeSlashName>\n\t} {\n\t\tconst succesfullyRefreshedModules = new Map<LocalModuleId, FastRefreshResult>()\n\t\tconst failedFastRefreshModules = new Set<TypeSlashName>()\n\t\tfor (const [localModuleId, result] of fastRefreshResults) {\n\t\t\tif (isUndefined(result?.error)) {\n\t\t\t\tsuccesfullyRefreshedModules.set(localModuleId, result)\n\t\t\t} else {\n\t\t\t\tconst typeSlashName = this.typeSlashNameByLocalId.get(localModuleId)\n\t\t\t\tif (!typeSlashName) continue\n\t\t\t\tfailedFastRefreshModules.add(typeSlashName)\n\t\t\t}\n\t\t}\n\t\treturn { succesfullyRefreshedModules, failedFastRefreshModules }\n\t}\n\n\t/**\n\t * Processes fast refresh results and re-evaluates modules that are dependend on the modules that\n\t * failed to refresh. We need to re-evaluate the modules because otherwise they won't pick up\n\t * the relative imports of the updated modules.\n\t * @param fastRefreshResults - A map of local module IDs to their fast refresh results.\n\t * @returns A promise that resolves to a map of local module IDs to the combined fast refresh\n\t * results of the initial run and the re-evaluated fast-refresh modules.\n\t */\n\tprivate async evaluateFastRefreshResults(\n\t\tfastRefreshResults: Map<LocalModuleId, FastRefreshResult>,\n\t\tinitialized: boolean,\n\t): Promise<Map<LocalModuleId, FastRefreshResult>> {\n\t\tif (fastRefreshResults.size === 0) return fastRefreshResults\n\t\tconst { succesfullyRefreshedModules: newFastRefreshedModules, failedFastRefreshModules } =\n\t\t\tthis.splitFastRefreshResults(fastRefreshResults)\n\t\tif (failedFastRefreshModules.size === 0) return fastRefreshResults\n\t\tconst modulesToReevaluate = this.collectDependenciesToReevaluate(failedFastRefreshModules)\n\t\tif (modulesToReevaluate.size > 0) {\n\t\t\tconst { fastRefreshResults: newFastRefreshResults } = await this.prepareAndEvaluateModules(\n\t\t\t\tmodulesToReevaluate,\n\t\t\t\tmodulesToReevaluate,\n\t\t\t\tnew Set(),\n\t\t\t\tinitialized,\n\t\t\t)\n\t\t\tfor (const [localModuleId, result] of newFastRefreshResults) {\n\t\t\t\tnewFastRefreshedModules.set(localModuleId, result)\n\t\t\t}\n\t\t}\n\t\treturn newFastRefreshedModules\n\t}\n\n\tprivate getReverseDependencies(targetModule: TypeSlashName): Set<TypeSlashName> {\n\t\tconst reverseDependencies = new Set<TypeSlashName>()\n\t\tfor (const [moduleName, moduleEntry] of this.compiledModules) {\n\t\t\tfor (const dependency of moduleEntry.relativeImports) {\n\t\t\t\tif (dependency.includes(targetModule)) {\n\t\t\t\t\treverseDependencies.add(moduleName)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn reverseDependencies\n\t}\n\n\tprivate collectDependenciesToReevaluate(failedFastRefreshModules: Set<TypeSlashName>): Set<TypeSlashName> {\n\t\tconst recursiveDependents = new Set<TypeSlashName>()\n\t\tconst visited = new Set<string>()\n\t\tconst stack: string[] = [...failedFastRefreshModules]\n\n\t\twhile (stack.length > 0) {\n\t\t\tconst currentModule = stack.pop()\n\t\t\tif (!currentModule || visited.has(currentModule)) continue\n\t\t\tvisited.add(currentModule)\n\t\t\t// This loops through every compiled module for every module it checks, so it might be\n\t\t\t// inefficient. A better approach might be to build a map of reverse dependencies once,\n\t\t\t// but I'm not sure that's worth the overhead. Something similar is happening in the\n\t\t\t// ModuelsStore (See DependencyGraph.ts) just before the modules are sent into the\n\t\t\t// ModulesRuntime, so it should be possible to send those results into the\n\t\t\t// ModulesRuntime too, but at the moment it did not seem worth it to pursue that.\n\t\t\tconst dependents = this.getReverseDependencies(currentModule)\n\t\t\tfor (const dependent of dependents) {\n\t\t\t\tif (!visited.has(dependent)) {\n\t\t\t\t\trecursiveDependents.add(dependent)\n\t\t\t\t\tstack.push(dependent)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn recursiveDependents\n\t}\n\n\tprivate async processEvaluationForComponentLoader(\n\t\tmodulesToEvaluate: Set<TypeSlashName>,\n\t\tentityIdsToDelete?: string[],\n\t\tinitialized?: boolean,\n\t): Promise<SandboxEntityDefinition<unknown>[]> {\n\t\tconst moduleEntities: SandboxEntityDefinition[] = []\n\t\tfor (const typeSlashName of modulesToEvaluate) {\n\t\t\tconst evaluatedModule = this.evaluatedModules.get(typeSlashName)\n\t\t\tassert(evaluatedModule, \"expected\", typeSlashName, \"in evaluatedModules\")\n\t\t\tconst evaluationResult = evaluatedModule?.evaluationResult\n\t\t\tassert(evaluationResult, \"expected\", typeSlashName, \"to be evaluated\")\n\t\t\tconst compiledModule = this.compiledModules.get(typeSlashName)\n\t\t\tassert(compiledModule, \"expected\", typeSlashName, \"in compiledModules\")\n\t\t\tconst identifier = localModuleIdentifier(compiledModule.localId)\n\t\t\tawait this.collectModuleEntities(\n\t\t\t\tidentifier,\n\t\t\t\tevaluationResult,\n\t\t\t\tmoduleEntities,\n\t\t\t\tcompiledModule.name,\n\t\t\t\tcompiledModule.update,\n\t\t\t)\n\t\t}\n\n\t\t// Atomically update the component loader.\n\t\tif (entityIdsToDelete) {\n\t\t\tthis.componentLoader.deleteModuleEntities(entityIdsToDelete)\n\t\t}\n\t\tthis.componentLoader.updateModuleEntities(moduleEntities)\n\t\tif (initialized !== undefined) {\n\t\t\tthis.componentLoader.setLocalModulesInitialized(initialized)\n\t\t}\n\n\t\tfor (const typeSlashName of modulesToEvaluate) {\n\t\t\tconst evaluatedModule = this.evaluatedModules.get(typeSlashName)\n\t\t\tassert(evaluatedModule, \"expected\", typeSlashName, \"in evaluatedModules\")\n\t\t\tevaluatedModule.inComponentLoader = true\n\t\t}\n\n\t\treturn moduleEntities\n\t}\n\n\t/**\n\t * Invalidates the previous version of the modules in `this.evaluatedModules` map.\n\t * Updates the modules in `this.evaluatedModules` leaving `evaluationResult` empty.\n\t *\n\t * @param modulesToEvaluate - all the modules that need to be (re-)evaluated,\n\t *        including ones transitive modules that only need their dependencies (re-)evaluated.\n\t * @param updatedModules - only the modules the source code of which has been updated.\n\t */\n\tprivate prepareForEvaluation(\n\t\tmodulesToEvaluate: Set<TypeSlashName>,\n\t\tupdatedModules?: Set<TypeSlashName>,\n\t): { entityIdsToDelete: string[] } {\n\t\tconst startMark = \"client-handle-modules-update\"\n\t\tperformanceMark(startMark)\n\t\tconst start = performance.now()\n\n\t\tconst entityIdsToDelete: string[] = []\n\t\tfor (const typeSlashName of modulesToEvaluate) {\n\t\t\tconst prevEvaluatedModule = this.evaluatedModules.get(typeSlashName)\n\t\t\tconst compiledModule = this.compiledModules.get(typeSlashName)\n\t\t\tassert(compiledModule, typeSlashName, \"is expected to be in this.compiledModules already.\")\n\n\t\t\t// Server modules are not available locally, but also don't have any changes made to\n\t\t\t// them. We evaluate these from their moduleURL.\n\t\t\tif (compiledModule.kind === \"server\") {\n\t\t\t\tentityIdsToDelete.push(...this.disposeEvaluatedModule(typeSlashName))\n\t\t\t\tthis.evaluatedModules.set(typeSlashName, {\n\t\t\t\t\tkind: compiledModule.kind,\n\t\t\t\t\tlocalId: compiledModule.localId,\n\t\t\t\t\tmoduleURL: compiledModule.moduleURL,\n\t\t\t\t\tsourceRevision: compiledModule.sourceRevision,\n\t\t\t\t\tevaluationResult: undefined,\n\t\t\t\t\tinComponentLoader: false,\n\t\t\t\t\tfiles: compiledModule.files,\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Other modules are available locally, they might not even exist on the backend yet,\n\t\t\t// being queued in modules storage. We write them into blobs and evaluate them by\n\t\t\t// rewriting their would-be moduleURL to the blob url.\n\n\t\t\tlet codeForEvaluation = compiledModule.moduleContent\n\n\t\t\t// Replace asset import URLs that use `import.meta.url` because the latter\n\t\t\t// won't point to the right location when the module is served from a blob URL.\n\t\t\tcodeForEvaluation = rewriteAssetURLsIfNeeded(codeForEvaluation, compiledModule.localId)\n\n\t\t\tconst binaryAssetBlobObjectURLs: BinaryAssetBlobObjectURLs = new Map()\n\t\t\tconst binaryAssets = compiledModule.binaryAssetContents\n\t\t\tif (binaryAssets) {\n\t\t\t\tcodeForEvaluation = codeForEvaluation.replaceAll(\n\t\t\t\t\t/\\bnew URL\\(\"\\.\\/(?<filename>.+?)\",\\s*import\\.meta\\.url\\)\\.href\\b/gu,\n\t\t\t\t\t(match, filename) => {\n\t\t\t\t\t\tconst binaryAsset = binaryAssets[filename]\n\t\t\t\t\t\tif (!binaryAsset) return match\n\n\t\t\t\t\t\tconst blobURL =\n\t\t\t\t\t\t\tbinaryAssetBlobObjectURLs.get(filename) ??\n\t\t\t\t\t\t\tURL.createObjectURL(\n\t\t\t\t\t\t\t\tnew Blob([binaryAsset], {\n\t\t\t\t\t\t\t\t\ttype: \"application/octet-stream\",\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\tbinaryAssetBlobObjectURLs.set(filename, blobURL)\n\n\t\t\t\t\t\treturn JSON.stringify(blobURL)\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlet sourceMapURL: string | undefined = undefined\n\t\t\tif (updatedModules?.has(typeSlashName)) {\n\t\t\t\t// Include inline source maps only for code files.\n\t\t\t\tif (compiledModule.type === ModuleType.Code && compiledModule.sourceMapContent) {\n\t\t\t\t\t// MODULES-TODO: The sourceMap encoding takes as long as about 1/3 of the time spent\n\t\t\t\t\t//               compiling the module (3ms for a 10ms-compiling module), and most of the time\n\t\t\t\t\t//               the source map is not needed in the runtime. We should investigate other\n\t\t\t\t\t//               solutions to that, e.g. creating a Blob and using its objectURL\n\t\t\t\t\t//               instead of inlining the base64 representation.\n\t\t\t\t\tsourceMapURL =\n\t\t\t\t\t\t\"data:application/json;charset=utf-16;base64,\" +\n\t\t\t\t\t\t// Conversion to utf8 string is needed because btoa doesn't support utf16 (javascript source code) strings\n\t\t\t\t\t\tbtoa(utf16asUtf8(compiledModule.sourceMapContent))\n\t\t\t\t}\n\t\t\t} else if (prevEvaluatedModule?.kind === \"local\") {\n\t\t\t\tsourceMapURL = prevEvaluatedModule.sourceMapURL\n\t\t\t}\n\n\t\t\tconst blobParts = [codeForEvaluation]\n\t\t\tif (sourceMapURL !== undefined) {\n\t\t\t\tblobParts.push(\"\\n//# sourceMappingURL=\", sourceMapURL)\n\t\t\t}\n\t\t\tconst blobObjectURL = URL.createObjectURL(\n\t\t\t\tnew Blob(blobParts, {\n\t\t\t\t\ttype: \"text/javascript\",\n\t\t\t\t}),\n\t\t\t)\n\n\t\t\tconst submoduleBlobObjectURLs: SubmoduleBlobObjectURLs = new Map()\n\t\t\tconst submoduleContents = compiledModule.submoduleContents\n\t\t\tif (submoduleContents) {\n\t\t\t\tconst filenames = getKeys(submoduleContents)\n\t\t\t\tfor (const filename of filenames) {\n\t\t\t\t\tconst submoduleContent = submoduleContents[filename]\n\t\t\t\t\tassert(isString(submoduleContent), \"submoduleContent must be defined\")\n\n\t\t\t\t\tconst submoduleBlobObjectURL = URL.createObjectURL(\n\t\t\t\t\t\tnew Blob([submoduleContent], {\n\t\t\t\t\t\t\ttype: \"text/javascript\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\n\t\t\t\t\tconst submoduleImport = getSubmoduleImport(filename)\n\t\t\t\t\tsubmoduleBlobObjectURLs.set(submoduleImport, submoduleBlobObjectURL)\n\n\t\t\t\t\tthis.submoduleBlobObjectURLsByBlobObjectURL.set(submoduleBlobObjectURL, submoduleBlobObjectURLs)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Invalidate the previous version of the updated module in `this.evaluatedModules` map.\n\t\t\tentityIdsToDelete.push(...this.disposeEvaluatedModule(typeSlashName))\n\n\t\t\t// Update the corresponding module entry in this.evaluatedModules leaving `evaluationResult` empty for now.\n\t\t\tconst sharedProperties = {\n\t\t\t\tlocalId: compiledModule.localId,\n\t\t\t\tsourceRevision: compiledModule.sourceRevision,\n\t\t\t\tblobObjectURL,\n\t\t\t\tsourceMapURL,\n\t\t\t\tevaluationResult: undefined,\n\t\t\t\tinComponentLoader: false,\n\t\t\t}\n\n\t\t\tconst evaluatedModule: EvaluatedModule =\n\t\t\t\tcompiledModule.kind === \"local\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...sharedProperties,\n\t\t\t\t\t\t\tkind: compiledModule.kind,\n\t\t\t\t\t\t\tmoduleURL: compiledModule.moduleURL,\n\t\t\t\t\t\t\tfiles: compiledModule.files,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...sharedProperties,\n\t\t\t\t\t\t\tkind: compiledModule.kind,\n\t\t\t\t\t\t}\n\n\t\t\t// Keep track of the module in the three maps.\n\t\t\tthis.evaluatedModules.set(typeSlashName, evaluatedModule)\n\t\t\tthis.compiledModulesByBlobObjectURL.set(blobObjectURL, compiledModule)\n\t\t\tif (compiledModule.kind === \"local\") {\n\t\t\t\tthis.compiledModulesByModuleURL.set(compiledModule.moduleURL, evaluatedModule)\n\t\t\t}\n\t\t\tthis.submoduleBlobObjectURLsByBlobObjectURL.set(blobObjectURL, submoduleBlobObjectURLs)\n\t\t\tthis.binaryAssetBlobObjectURLsByBlobObjectURL.set(blobObjectURL, binaryAssetBlobObjectURLs)\n\t\t}\n\n\t\tlog.debug(\n\t\t\t\"prepareForEvaluation took:\",\n\t\t\tseconds(performance.now() - start),\n\t\t\t\"prepared:\",\n\t\t\tmodulesToEvaluate.size,\n\t\t\t\"/\",\n\t\t\tthis.evaluatedModules.size,\n\t\t)\n\t\tperformanceMeasure(\"\uD83E\uDD41 Prepare modules for evaluation\", startMark)\n\t\tperformanceClearMarks(startMark)\n\n\t\t// Update the local import map before evaluating modules.\n\t\tconst importMap: Required<ImportMap> = { imports: {}, scopes: {} }\n\t\tfor (const [name, evaluatedModule] of this.evaluatedModules) {\n\t\t\tconst { kind, localId } = evaluatedModule\n\t\t\tif (kind === \"fast-refresh\") {\n\t\t\t\tconst { module } = filenamesFromModuleName(name)\n\t\t\t\timportMap.imports[localModuleImportMapSpecifier(localId, module)] = evaluatedModule.blobObjectURL\n\t\t\t} else {\n\t\t\t\tconst { files } = evaluatedModule\n\t\t\t\tassert(isString(files.module), \"Must have a module file name to build a local module import map specifier.\")\n\n\t\t\t\t// Use the blob object URL for local modules. Using the module\n\t\t\t\t// URL too soon risks the module not existing on the server\n\t\t\t\t// immediately after the import map is updated\n\t\t\t\t// https://github.com/framer/FramerStudio/pull/19546.\n\t\t\t\tconst url = evaluatedModule.kind === \"local\" ? evaluatedModule.blobObjectURL : evaluatedModule.moduleURL\n\t\t\t\timportMap.imports[localModuleImportMapSpecifier(localId, files.module)] = url\n\t\t\t}\n\t\t}\n\n\t\tfor (const localSpecifier in importMap.imports) {\n\t\t\tif (localSpecifier.startsWith(`#framer/local/${ModuleType.Collection}/`)) {\n\t\t\t\t// Serve draft collection instead of collection\n\t\t\t\tconst draftSpecifier = localSpecifier.replace(ModuleType.Collection, ModuleType.DraftCollection)\n\t\t\t\tconst draftURL = importMap.imports[draftSpecifier]\n\t\t\t\tconst collectionURL = importMap.imports[localSpecifier]\n\t\t\t\tif (draftURL && collectionURL) {\n\t\t\t\t\timportMap.imports[localSpecifier] = draftURL\n\n\t\t\t\t\t// For smart components, we import collection by full module URL\n\t\t\t\t\t// in `replaceRelativeImportsWithAbsolute` of `ModulesStorage`,\n\t\t\t\t\t// so we need to provide an override for it too\n\t\t\t\t\timportMap.imports[collectionURL] = draftURL\n\n\t\t\t\t\t// But not when the draft collection imports the collection\n\t\t\t\t\timportMap.scopes[draftURL] = {\n\t\t\t\t\t\t[localSpecifier]: collectionURL,\n\t\t\t\t\t\t[collectionURL]: collectionURL,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.updateImportMap(importMap, \"framer-local-modules\")\n\n\t\treturn { entityIdsToDelete }\n\t}\n\n\tprivate disposeEvaluatedModule(typeSlashName: TypeSlashName): string[] {\n\t\tconst entry = this.evaluatedModules.get(typeSlashName)\n\t\tif (!entry) return []\n\n\t\tthis.evaluatedModules.delete(typeSlashName)\n\t\tif (entry.kind === \"local\") {\n\t\t\tconst blobObjectURL = entry.blobObjectURL\n\t\t\tthis.blobObjectURLsToRevoke.add(blobObjectURL)\n\t\t\tthis.compiledModulesByModuleURL.delete(entry.moduleURL)\n\n\t\t\tconst submoduleBlobObjectURLs = this.submoduleBlobObjectURLsByBlobObjectURL.get(blobObjectURL)\n\t\t\tif (submoduleBlobObjectURLs) {\n\t\t\t\tthis.blobObjectURLsToRevoke.add(blobObjectURL)\n\n\t\t\t\tfor (const [, submoduleBlobObjectURL] of submoduleBlobObjectURLs) {\n\t\t\t\t\tthis.blobObjectURLsToRevoke.add(submoduleBlobObjectURL)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst binaryAssetBlobObjectURLs = this.binaryAssetBlobObjectURLsByBlobObjectURL.get(blobObjectURL)\n\t\t\tif (binaryAssetBlobObjectURLs) {\n\t\t\t\tthis.blobObjectURLsToRevoke.add(blobObjectURL)\n\n\t\t\t\tfor (const [, binaryAssetBlobObjectURL] of binaryAssetBlobObjectURLs) {\n\t\t\t\t\tthis.blobObjectURLsToRevoke.add(binaryAssetBlobObjectURL)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!entry.evaluationResult) return []\n\t\tif (entry.evaluationResult instanceof Error) {\n\t\t\treturn [localModuleIdentifier(entry.localId).value]\n\t\t}\n\t\treturn Object.keys(entry.evaluationResult).map(exported => localModuleIdentifier(entry.localId, exported).value)\n\t}\n\n\tprivate revokeBlobObjectURLs() {\n\t\tfor (const blobObjectURL of this.blobObjectURLsToRevoke) {\n\t\t\tthis.blobObjectURLsToRevoke.delete(blobObjectURL)\n\t\t\tthis.compiledModulesByBlobObjectURL.delete(blobObjectURL)\n\t\t\tthis.submoduleBlobObjectURLsByBlobObjectURL.delete(blobObjectURL)\n\t\t\tthis.binaryAssetBlobObjectURLsByBlobObjectURL.delete(blobObjectURL)\n\t\t\tURL.revokeObjectURL(blobObjectURL)\n\t\t}\n\t}\n\n\t// Serve the draft collection module instead of the collection module.\n\tprivate resolveDraftCollection(id: string, parentURL: string): string {\n\t\tlet typeSlashName: string | undefined = undefined\n\n\t\t// Resolve a moduleURL to a locally loaded blob object. (This happens as other editors\n\t\t// update modules that depend on modules we compiled locally.)\n\t\tconst targetModule = this.compiledModulesByModuleURL.get(id)\n\t\tif (targetModule) {\n\t\t\ttypeSlashName = this.typeSlashNameByLocalId.get(targetModule.localId)\n\t\t}\n\n\t\t// Resolve relative module imports for blob urls.\n\t\t// Either ../type/name or ./name\n\t\tconst parentModule = this.compiledModulesByBlobObjectURL.get(parentURL)\n\t\tif (parentModule && parentModule.relativeImports.indexOf(id) >= 0) {\n\t\t\ttypeSlashName = normalizePath(id, getTypeSlashName(parentModule))\n\t\t}\n\n\t\t// Resolve a module by the blob object URL.\n\t\tconst blobModule = this.compiledModulesByBlobObjectURL.get(id)\n\t\tif (blobModule) {\n\t\t\ttypeSlashName = getTypeSlashName(blobModule)\n\t\t}\n\n\t\tif (typeSlashName?.startsWith(ModuleType.Collection)) {\n\t\t\tconst draftTypeSlashName = typeSlashName.replace(ModuleType.Collection, ModuleType.DraftCollection)\n\t\t\tconst draftCollectionModule = this.evaluatedModules.get(draftTypeSlashName)\n\t\t\tif (draftCollectionModule) {\n\t\t\t\tconst resolved =\n\t\t\t\t\tdraftCollectionModule.kind === \"server\"\n\t\t\t\t\t\t? draftCollectionModule.moduleURL\n\t\t\t\t\t\t: draftCollectionModule.blobObjectURL\n\t\t\t\tresolveLog.trace(\"resolve draft collection\", id, parentURL, \"->\", resolved)\n\t\t\t\treturn resolved\n\t\t\t}\n\t\t}\n\n\t\treturn id\n\t}\n\n\tprivate parentModuleIsDraftCollection(parentURL: string): boolean {\n\t\tconst blobObjectURL = this.compiledModulesByModuleURL.get(parentURL)?.blobObjectURL\n\t\tconst parentModuleByBlobObjectURL = this.compiledModulesByBlobObjectURL.get(blobObjectURL || parentURL)\n\t\treturn parentModuleByBlobObjectURL?.type === ModuleType.DraftCollection\n\t}\n\n\t/** As modules evaluate, es-module-shims will resolve imports. This method hooks into that\n     resolve method and resolves all relative imports and module urls for us. */\n\tresolveHook: ResolveHook = (originalId: string, parentURL: string, defaultResolve: DefaultResolve): string => {\n\t\t// Allow importing collections from draft collections\n\t\tconst id = this.parentModuleIsDraftCollection(parentURL)\n\t\t\t? originalId\n\t\t\t: this.resolveDraftCollection(originalId, parentURL)\n\n\t\t// Resolve a moduleURL to a locally loaded blob object. (This happens as other editors\n\t\t// update modules that depend on modules we compiled locally.)\n\t\tconst targetModule = this.compiledModulesByModuleURL.get(id)\n\t\tif (targetModule) {\n\t\t\tresolveLog.trace(\"resolve moduleURL -> blob:\", id, parentURL, \"->\", targetModule.blobObjectURL)\n\t\t\treturn targetModule.blobObjectURL\n\t\t}\n\n\t\t// Resolve submodules.\n\t\tconst submoduleBlobObjectURLs = this.submoduleBlobObjectURLsByBlobObjectURL.get(parentURL)\n\t\tif (submoduleBlobObjectURLs && isSubmoduleImport(id)) {\n\t\t\tconst resolvedSubmodule = submoduleBlobObjectURLs.get(id)\n\t\t\tif (resolvedSubmodule) {\n\t\t\t\tresolveLog.trace(\"resolve local import:\", id, parentURL, \"->\", resolvedSubmodule)\n\t\t\t\treturn resolvedSubmodule\n\t\t\t}\n\t\t}\n\n\t\t// Resolve relative module imports for blob urls.\n\t\tconst parentModule = this.compiledModulesByBlobObjectURL.get(parentURL)\n\t\tif (parentModule && parentModule.relativeImports.indexOf(id) >= 0) {\n\t\t\t// Either ../type/name or ./name\n\t\t\tconst typeSlashName = normalizePath(id, getTypeSlashName(parentModule))\n\t\t\tassert(typeSlashName, \"normalizePath\")\n\n\t\t\tconst importedModule = this.evaluatedModules.get(typeSlashName)\n\t\t\tif (!importedModule) throw Error(\"unable to resolve: \" + typeSlashName)\n\t\t\tconst resolved =\n\t\t\t\timportedModule.kind === \"local\" || importedModule.kind === \"fast-refresh\"\n\t\t\t\t\t? importedModule.blobObjectURL\n\t\t\t\t\t: importedModule.moduleURL\n\t\t\tresolveLog.trace(\"resolve local import:\", id, parentURL, \"->\", resolved)\n\t\t\treturn resolved\n\t\t}\n\n\t\t// Resolve any resource for a blob on top of its moduleURL.\n\t\tif (parentModule && parentModule.kind === \"local\") {\n\t\t\tconst url = parentModule?.moduleURL ?? parentURL\n\t\t\tresolveLog.trace(\"resolve blob:\", id, url)\n\t\t\treturn defaultResolve(id, url)\n\t\t}\n\n\t\t// Normal resolve.\n\t\tresolveLog.trace(\"resolve import-map:\", id, parentURL)\n\t\treturn defaultResolve(id, parentURL)\n\t}\n\n\tfetchHook: FetchHook = async (\n\t\tinput: FetchInput,\n\t\tinit: FetchInit,\n\t\tdefaultFetch: DefaultFetch,\n\t\tsource: FetchSource,\n\t) => {\n\t\tlet request: Request | undefined\n\t\ttry {\n\t\t\trequest = new Request(input, init)\n\n\t\t\tconst url = new URL(request.url)\n\t\t\tconst isBlobUrl = url.protocol === \"blob:\"\n\t\t\tconst rangeQuery = url.searchParams.get(\"range\")\n\n\t\t\t// Mock CMS range request lambda.\n\t\t\tif (isBlobUrl && rangeQuery) {\n\t\t\t\turl.searchParams.delete(\"range\")\n\n\t\t\t\tconst fileRequest = new Request(url, request)\n\t\t\t\tconst fileResponse = await defaultFetch(fileRequest)\n\n\t\t\t\tconst buffer = await fileResponse.arrayBuffer()\n\t\t\t\tconst bytes = new Uint8Array(buffer)\n\n\t\t\t\treturn mockRangeRequestLambda(bytes, rangeQuery)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// If we get an error, we try the default fetch implementation.\n\t\t\tlog.reportError(error)\n\t\t}\n\n\t\tconst url = request?.url\n\t\tconst networkRequestHandle =\n\t\t\tsource === \"module-loader\" && url ? this.initialModuleLoadTracker.startNetworkRequest(url) : undefined\n\t\tconst response = await defaultFetch(input, init)\n\t\tnetworkRequestHandle?.setContentLengthFromResponse(response)\n\t\treturn response\n\t}\n\n\t// TODO: after we can update the component loader in a more fine grained and light weight way,\n\t// we can do these batches outside of synchronize, and not block other modules runtime requests.\n\tprivate hasEmittedFirstBatchMark = false\n\tprivate hasEmittedEvaluateModulesEndMark = false\n\tprivate evaluateBatchMarkCounter = 0\n\n\tprivate async evaluateModulesInBatches(\n\t\tmodulesToEvaluate: Set<TypeSlashName>,\n\t\tmode: EvaluationMode,\n\t): Promise<Map<LocalModuleId, FastRefreshResult>> {\n\t\tconst batchSize = 50\n\n\t\tconst batch = new Set<TypeSlashName>()\n\t\tconst fastRefreshResults = new Map<LocalModuleId, FastRefreshResult>()\n\t\tfor (const typeSlashName of modulesToEvaluate) {\n\t\t\tbatch.add(typeSlashName)\n\t\t\t// Evaluate a single batch, then wait a bit, then clear the batch and fill it again.\n\t\t\tif (batch.size >= batchSize) {\n\t\t\t\tconst evaluated = await this.evaluateModules(batch, mode)\n\t\t\t\tevaluated.forEach((error, localId) => fastRefreshResults.set(localId, error))\n\t\t\t\tthis.emitInitialLoadBatchMarks()\n\t\t\t\tawait delay(100)\n\t\t\t\tbatch.clear()\n\t\t\t}\n\t\t}\n\t\tif (batch.size > 0) {\n\t\t\tconst evaluated = await this.evaluateModules(batch, mode)\n\t\t\tevaluated.forEach((error, localId) => fastRefreshResults.set(localId, error))\n\t\t\tthis.emitInitialLoadBatchMarks()\n\t\t}\n\t\tif (!this.hasEmittedEvaluateModulesEndMark) {\n\t\t\tthis.hasEmittedEvaluateModulesEndMark = true\n\t\t\tthis.moduleStateListener.markLoadingPerf?.(\"sandboxEvaluateModulesEnd\")\n\t\t}\n\t\treturn fastRefreshResults\n\t}\n\n\t/** Emits the typed first-batch mark and a dynamic per-batch mark for the initial load only.\n\t * Suppressed after the initial load's `sandboxEvaluateModulesEnd` fires, so fast-refresh\n\t * batches don't pollute the loader timeline. */\n\tprivate emitInitialLoadBatchMarks(): void {\n\t\tif (this.hasEmittedEvaluateModulesEndMark) return\n\n\t\tconst batchNumber = ++this.evaluateBatchMarkCounter\n\t\tif (!this.hasEmittedFirstBatchMark) {\n\t\t\tthis.hasEmittedFirstBatchMark = true\n\t\t\tthis.moduleStateListener.markLoadingPerf?.(\"sandboxFirstBatchEvaluated\")\n\t\t}\n\t\tthis.moduleStateListener.markLoadingPerfDynamic?.(\n\t\t\t`sandboxEvaluateBatch${batchNumber}`,\n\t\t\t`Sandbox Evaluate Batch ${batchNumber}`,\n\t\t)\n\t}\n\n\tprivate evaluateModulesMarkCounter = 0\n\n\tprivate importMapVersion = 0\n\n\tprivate async evaluateModules(\n\t\tmodulesToEvaluate: Set<TypeSlashName>,\n\t\tmode: EvaluationMode,\n\t): Promise<Map<LocalModuleId, FastRefreshResult>> {\n\t\tassert(getCurrentShimResolveHook() === this.resolveHook, \"this.resolveHook is no longer current\")\n\t\tassert(getCurrentShimFetchHook() === this.fetchHook, \"this.fetchHook is no longer current\")\n\t\tassert(this.inSynchronizeBlock, \"evaluateModules can only be called from a synchronize block\")\n\n\t\tconst evaluationStartMark = `client-handle-modules-update-evaluation-${this.evaluateModulesMarkCounter++}`\n\t\tperformanceMark(evaluationStartMark)\n\t\tconst start = performance.now()\n\t\tconst fastRefreshResults = new Map<LocalModuleId, FastRefreshResult>()\n\t\tthis.initialModuleLoadTracker.trackLocalEvaluatedModules(modulesToEvaluate)\n\t\t// Wait for until script are loaded and evaluated in parallel.\n\t\tawait Promise.all(\n\t\t\tArray.from(modulesToEvaluate).map(async typeSlashName => {\n\t\t\t\tconst moduleEntry = this.evaluatedModules.get(typeSlashName)\n\t\t\t\tassert(moduleEntry, typeSlashName, \"should be in this.evaluatedModules before evaluation\")\n\t\t\t\tconst moduleURL =\n\t\t\t\t\tmoduleEntry.kind === \"local\" || moduleEntry.kind === \"fast-refresh\"\n\t\t\t\t\t\t? moduleEntry.blobObjectURL\n\t\t\t\t\t\t: moduleEntry.moduleURL\n\n\t\t\t\tconst evaluationResult = await importShim(moduleURL).catch((err: unknown) => err)\n\t\t\t\tlog.trace(\"eval:\", typeSlashName, moduleURL, evaluationResult)\n\t\t\t\tmoduleEntry.evaluationResult = evaluationResult\n\t\t\t\tif (moduleEntry.kind === \"fast-refresh\") {\n\t\t\t\t\tconst previousEvaluationResult = this.fastRefreshPreviousEvaluationResults.get(typeSlashName)\n\t\t\t\t\tif (previousEvaluationResult) {\n\t\t\t\t\t\tconst result = performFastRefresh(previousEvaluationResult, evaluationResult)\n\t\t\t\t\t\tfastRefreshResults.set(moduleEntry.localId, result)\n\t\t\t\t\t\tlog.trace(\"performFastRefresh\", typeSlashName, previousEvaluationResult, evaluationResult, result)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t)\n\n\t\tlog.debug(\n\t\t\t\"evaluateModules took:\",\n\t\t\tseconds(performance.now() - start),\n\t\t\t\"evaluated:\",\n\t\t\tmodulesToEvaluate.size,\n\t\t\t\"/\",\n\t\t\tthis.evaluatedModules.size,\n\t\t\t\"mode:\",\n\t\t\tmode,\n\t\t\t\"revision:\",\n\t\t\tthis.moduleRevision,\n\t\t\tthis.lazyRevision > 0 ? this.lazyRevision : \"\",\n\t\t)\n\t\tperformanceMeasure(\"\uD83C\uDFC4 Evaluate modules\", evaluationStartMark)\n\t\tperformanceClearMarks(evaluationStartMark)\n\t\tlog.trace(\"evaluatedModules\", modulesToEvaluate, fastRefreshResults)\n\t\treturn fastRefreshResults\n\t}\n\n\tprivate updateImportMap(\n\t\timportMap: ImportMap,\n\t\tname: \"framer-user-importmap\" | `framer-temp-importmap-${number}` | \"framer-local-modules\",\n\t) {\n\t\tconst source = JSON.stringify(importMap, null, 4)\n\t\tresolveLog.trace(\"installing new import map:\", name, source)\n\t\tconst importMapEl = Object.assign(document.createElement(\"script\"), {\n\t\t\t// We use \"importmap-shim\" instead of \"importmap\" because there is no browser yet that supports\n\t\t\t// dynamically injected import maps, see: https://github.com/guybedford/import-maps-extensions#lazy-loading-of-import-maps\n\t\t\ttype: \"importmap-shim\",\n\t\t\tid: name,\n\t\t\tinnerHTML: source,\n\t\t})\n\t\tconst prevImportMapEl = document.getElementById(name)\n\t\tif (prevImportMapEl) {\n\t\t\tprevImportMapEl?.parentNode?.replaceChild(importMapEl, prevImportMapEl)\n\t\t} else {\n\t\t\tdocument.body.appendChild(importMapEl)\n\t\t}\n\n\t\t// Whenever we update the import map, we should assume that evaluating\n\t\t// server modules should be re-evaluated if they have been evaluated\n\t\t// before.\n\t\tthis.importMapVersion++\n\t\tresolveLog.debug(\"\uD83D\uDC89\", name, \"updated.\")\n\t}\n\n\tprivate synchronizeMarkCounter = 0\n\n\tprivate async synchronize<R>(callback: () => R | Promise<R>): Promise<R> {\n\t\tthis.tasksRunningOrWaiting += 1\n\t\tconst start = performance.now()\n\t\tconst markName = `acquire-modules-runtime-lock-${this.synchronizeMarkCounter++}`\n\t\tperformanceMark(markName)\n\t\treturn locks.request(LOCKED_RESOURCE_NAME, async () => {\n\t\t\tconst timeTook = performance.now() - start\n\t\t\tperformanceMeasure(`\uD83D\uDD13 Acquire ${LOCKED_RESOURCE_NAME} lock`, markName)\n\t\t\tperformanceClearMarks(markName)\n\t\t\tlog.debug(\"\uD83D\uDD13 Acquired the\", LOCKED_RESOURCE_NAME, \"lock in\", seconds(timeTook), \"seconds\")\n\t\t\tif (timeTook > 1000) {\n\t\t\t\tlog.warn(\"\u2757 Long wait: it took\", timeTook.toFixed(0), \"ms to acquire the\", LOCKED_RESOURCE_NAME, \"lock.\")\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tthis.inSynchronizeBlock = true\n\t\t\t\treturn await callback()\n\t\t\t} finally {\n\t\t\t\tthis.tasksRunningOrWaiting -= 1\n\t\t\t\tthis.inSynchronizeBlock = false\n\t\t\t\tthis.notifyLoadingStateChangedIfIdle()\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate queryEngine = new QueryEngine()\n\n\tasync collectModuleEntities(\n\t\tidentifier: ModuleIdentifier,\n\t\tevaluationResult: ModuleEvaluationResult,\n\t\tentities: SandboxEntityDefinition[],\n\t\tmoduleName: string | undefined,\n\t\tupdate: number,\n\t) {\n\t\treturn collectModuleEntities(this.queryEngine, identifier, evaluationResult, entities, moduleName, update)\n\t}\n}\n\ninterface FastRefreshResult {\n\terror: string | undefined\n}\n\nfunction performFastRefresh(\n\tpreviousEvaluationResult: ModuleEvaluationResult | undefined,\n\tevaluationResult: ModuleEvaluationResult | undefined,\n): FastRefreshResult {\n\tconst unsafeWindow = window as unknown as {\n\t\treactRefreshRuntime: typeof ReactRefreshRuntime | undefined\n\t}\n\t// This is being set on the window by the fast-refresh script\n\tconst { reactRefreshRuntime } = unsafeWindow\n\tassert(reactRefreshRuntime, \"React fast refresh runtime should be available\")\n\tlet error: string | undefined\n\ttry {\n\t\tconst invalidateMessage = reactRefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(\n\t\t\tpreviousEvaluationResult,\n\t\t\tevaluationResult,\n\t\t)\n\t\terror = invalidateMessage\n\t} catch (e) {\n\t\terror = e instanceof Error ? e.message : String(e)\n\t}\n\tlog.info(\"React fast refresh\", {\n\t\tprevious: previousEvaluationResult,\n\t\tevaluationResult,\n\t\terror,\n\t})\n\treturn { error }\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,MAAM,UAAU,sBA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