@abide/abide 0.48.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/AGENTS.md +85 -59
  2. package/CHANGELOG.md +216 -0
  3. package/README.md +21 -10
  4. package/package.json +15 -4
  5. package/src/abideLsp.ts +5 -6
  6. package/src/abideResolverPlugin.ts +197 -169
  7. package/src/build.ts +79 -56
  8. package/src/buildCli.ts +3 -5
  9. package/src/buildDisconnected.ts +2 -5
  10. package/src/bundleApp.ts +2 -3
  11. package/src/checkAbide.ts +12 -2
  12. package/src/compile.ts +2 -4
  13. package/src/devEntry.ts +113 -28
  14. package/src/discoveryEntry.ts +3 -2
  15. package/src/lib/bundle/disconnected.abide +69 -73
  16. package/src/lib/bundle/infoPlist.ts +13 -7
  17. package/src/lib/bundle/installDownloads.ts +13 -3
  18. package/src/lib/bundle/installMacMenu.ts +13 -3
  19. package/src/lib/bundle/spawnEmbeddedServer.ts +13 -4
  20. package/src/lib/bundle/waitForServer.ts +6 -1
  21. package/src/lib/cli/parseArgvForRpc.ts +36 -9
  22. package/src/lib/cli/tokenizeArgvFlags.ts +4 -2
  23. package/src/lib/mcp/createMcpResourceServer.ts +13 -2
  24. package/src/lib/mcp/mcpTools.ts +15 -6
  25. package/src/lib/mcp/toolResultFromResponse.ts +40 -12
  26. package/src/lib/server/error.ts +6 -6
  27. package/src/lib/server/json.ts +17 -3
  28. package/src/lib/server/rpc/defineRpc.ts +58 -24
  29. package/src/lib/server/rpc/parseArgs.ts +113 -14
  30. package/src/lib/server/rpc/resolveRpcJsonSchema.ts +28 -0
  31. package/src/lib/server/rpc/runWithRpcTimeout.ts +12 -1
  32. package/src/lib/server/rpc/types/RpcHelper.ts +75 -105
  33. package/src/lib/server/rpc/types/RpcRegistryEntry.ts +24 -9
  34. package/src/lib/server/rpc/validationError.ts +1 -1
  35. package/src/lib/server/runtime/DEV_RELOAD_CLIENT_SCRIPT.ts +0 -15
  36. package/src/lib/server/runtime/buildCacheSnapshot.ts +10 -9
  37. package/src/lib/server/runtime/buildInspectorSurface.ts +6 -4
  38. package/src/lib/server/runtime/buildOpenApiSpec.ts +55 -11
  39. package/src/lib/server/runtime/buildPreloadManifest.ts +12 -10
  40. package/src/lib/server/runtime/createAppAssetServer.ts +18 -15
  41. package/src/lib/server/runtime/createAppRouteResolver.ts +145 -0
  42. package/src/lib/server/runtime/createPlumbingRouter.ts +212 -0
  43. package/src/lib/server/runtime/createRouteDispatcher.ts +4 -10
  44. package/src/lib/server/runtime/createServer.ts +120 -324
  45. package/src/lib/server/runtime/createUiPageRenderer.ts +137 -26
  46. package/src/lib/server/runtime/devClientFingerprint.ts +19 -34
  47. package/src/lib/server/runtime/finalizeResponse.ts +11 -1
  48. package/src/lib/server/runtime/installAmbientScopeStore.ts +30 -9
  49. package/src/lib/server/runtime/logExposedSurfaces.ts +8 -7
  50. package/src/lib/server/runtime/pathStore.ts +15 -0
  51. package/src/lib/server/runtime/registryManifests.ts +1 -1
  52. package/src/lib/server/runtime/renderCellBarrierStore.ts +15 -0
  53. package/src/lib/server/runtime/runWithRequestScope.ts +3 -0
  54. package/src/lib/server/runtime/serializeCacheSnapshot.ts +6 -4
  55. package/src/lib/server/runtime/snapshotEntryFromCache.ts +24 -16
  56. package/src/lib/server/runtime/streamCacheResolutions.ts +14 -7
  57. package/src/lib/server/runtime/streamFromIterator.ts +30 -2
  58. package/src/lib/server/runtime/textResponse.ts +23 -0
  59. package/src/lib/server/runtime/types/DevReloadStamp.ts +6 -10
  60. package/src/lib/server/runtime/types/InspectorCacheEntry.ts +1 -1
  61. package/src/lib/server/runtime/types/RequestStore.ts +27 -0
  62. package/src/lib/server/runtime/warnUnguardedMcp.ts +15 -5
  63. package/src/lib/server/sockets/createSocketDispatcher.ts +9 -11
  64. package/src/lib/server/sockets/defineSocket.ts +5 -4
  65. package/src/lib/server/sse.ts +5 -1
  66. package/src/lib/shared/ASYNC_CELL.ts +5 -0
  67. package/src/lib/shared/DEV_REBUILD_PATH.ts +6 -0
  68. package/src/lib/shared/HTTP_METHODS.ts +6 -0
  69. package/src/lib/shared/HttpError.ts +1 -5
  70. package/src/lib/shared/MCP_PATH.ts +6 -0
  71. package/src/lib/shared/PROXIED_SERVER_SUBDIRS.ts +15 -0
  72. package/src/lib/shared/REF_JSON_TAGS.ts +13 -1
  73. package/src/lib/shared/RPC_SHIM_GLOBALS.ts +9 -0
  74. package/src/lib/shared/activeCacheStore.ts +1 -0
  75. package/src/lib/shared/activePage.ts +1 -0
  76. package/src/lib/shared/buildArtifact.ts +20 -0
  77. package/src/lib/shared/buildRpcRequest.ts +6 -2
  78. package/src/lib/shared/buildSocketOverChannel.ts +4 -3
  79. package/src/lib/shared/bundleGraphFromMetafile.ts +68 -0
  80. package/src/lib/shared/cache.ts +156 -131
  81. package/src/lib/shared/canonicalJson.ts +24 -1
  82. package/src/lib/shared/changeAffectsClient.ts +12 -7
  83. package/src/lib/shared/createCacheStore.ts +31 -8
  84. package/src/lib/shared/createChannelLog.ts +24 -0
  85. package/src/lib/shared/createLifecycleChannel.ts +7 -1
  86. package/src/lib/shared/createReachable.ts +47 -78
  87. package/src/lib/shared/createRemoteFunction.ts +52 -30
  88. package/src/lib/shared/createRpcServerProgram.ts +820 -0
  89. package/src/lib/shared/decodeRefJson.ts +4 -4
  90. package/src/lib/shared/decodeResponse.ts +2 -2
  91. package/src/lib/shared/decodeWireBody.ts +35 -0
  92. package/src/lib/shared/detectRpcMethod.ts +8 -1
  93. package/src/lib/shared/done.ts +8 -2
  94. package/src/lib/shared/encodeRefJson.ts +4 -4
  95. package/src/lib/shared/encodeWireBody.ts +18 -0
  96. package/src/lib/shared/exitOnBuildFailure.ts +4 -3
  97. package/src/lib/{server/rpc → shared}/fieldErrorsFromIssues.ts +5 -1
  98. package/src/lib/shared/generateDeclarations.ts +72 -0
  99. package/src/lib/shared/hasSeedableRequest.ts +25 -0
  100. package/src/lib/shared/hydrationWindow.ts +53 -0
  101. package/src/lib/shared/isAsyncCell.ts +11 -0
  102. package/src/lib/shared/isAsyncIterable.ts +8 -0
  103. package/src/lib/shared/isSubscribable.ts +3 -3
  104. package/src/lib/shared/isThenable.ts +9 -0
  105. package/src/lib/shared/jsonSchemaForType.ts +258 -0
  106. package/src/lib/shared/lenientDecode.ts +15 -0
  107. package/src/lib/shared/loadProjectTsConfig.ts +28 -0
  108. package/src/lib/shared/markFrameworkSourcesIgnored.ts +1 -1
  109. package/src/lib/shared/matchRoute.ts +4 -14
  110. package/src/lib/shared/parseEnv.ts +17 -6
  111. package/src/lib/shared/peek.ts +14 -0
  112. package/src/lib/shared/pending.ts +9 -6
  113. package/src/lib/shared/pendingAsyncCellsSlot.ts +13 -0
  114. package/src/lib/shared/prepareRpcModule.ts +91 -93
  115. package/src/lib/shared/prepareSocketModule.ts +3 -2
  116. package/src/lib/shared/probeRegistries.ts +5 -18
  117. package/src/lib/shared/reachable.ts +7 -10
  118. package/src/lib/shared/refresh.ts +12 -2
  119. package/src/lib/shared/refreshing.ts +8 -2
  120. package/src/lib/shared/resolvedCellsSlot.ts +13 -0
  121. package/src/lib/shared/reviveWireField.ts +49 -0
  122. package/src/lib/shared/reviveWireOutput.ts +36 -0
  123. package/src/lib/shared/rpcServerForRoot.ts +25 -0
  124. package/src/lib/shared/scanPages.ts +25 -0
  125. package/src/lib/shared/serializeEnv.ts +18 -6
  126. package/src/lib/shared/snapshotShippable.ts +8 -7
  127. package/src/lib/shared/snippet.ts +11 -6
  128. package/src/lib/shared/streamedCellsSlot.ts +14 -0
  129. package/src/lib/shared/subscribableFromResponse.ts +4 -4
  130. package/src/lib/shared/subscribableProbes.ts +1 -1
  131. package/src/lib/shared/tailProbeSlot.ts +1 -1
  132. package/src/lib/shared/types/AsyncComputed.ts +20 -0
  133. package/src/lib/shared/types/AsyncState.ts +13 -0
  134. package/src/lib/shared/types/CacheEntry.ts +7 -7
  135. package/src/lib/shared/types/CacheOptions.ts +23 -37
  136. package/src/lib/shared/types/CachePolicy.ts +25 -0
  137. package/src/lib/shared/types/CacheSnapshotEntry.ts +6 -5
  138. package/src/lib/shared/types/ErrorJsonSchemas.ts +8 -0
  139. package/src/lib/shared/types/HttpMethod.ts +3 -1
  140. package/src/lib/shared/types/InputCoercion.ts +17 -0
  141. package/src/lib/shared/types/{Subscribable.ts → NamedAsyncIterable.ts} +1 -1
  142. package/src/lib/shared/types/OutputWirePlan.ts +17 -0
  143. package/src/lib/shared/types/PagesScan.ts +7 -0
  144. package/src/lib/shared/types/PendingAsyncCells.ts +10 -0
  145. package/src/lib/shared/types/RawRemoteFunction.ts +6 -0
  146. package/src/lib/shared/types/RemoteCallable.ts +8 -7
  147. package/src/lib/shared/types/RemoteFunction.ts +16 -15
  148. package/src/lib/shared/types/ResolvedCells.ts +11 -0
  149. package/src/lib/shared/types/ReturnBody.ts +15 -0
  150. package/src/lib/shared/types/RpcBuildStamps.ts +23 -0
  151. package/src/lib/shared/types/RpcErrorGuard.ts +3 -8
  152. package/src/lib/shared/types/Socket.ts +4 -4
  153. package/src/lib/shared/types/SsrPayload.ts +5 -1
  154. package/src/lib/shared/types/StreamPolicy.ts +11 -0
  155. package/src/lib/shared/types/StreamedCells.ts +19 -0
  156. package/src/lib/shared/types/StreamedResolution.ts +24 -6
  157. package/src/lib/shared/types/TailHooks.ts +1 -1
  158. package/src/lib/shared/types/WireKind.ts +11 -0
  159. package/src/lib/shared/url.ts +5 -0
  160. package/src/lib/shared/validationHttpError.ts +33 -0
  161. package/src/lib/shared/warmSeedKey.ts +16 -0
  162. package/src/lib/shared/wireJsonReplacer.ts +30 -0
  163. package/src/lib/shared/writeRpcDts.ts +11 -1
  164. package/src/lib/shared/writeTestSocketsDts.ts +1 -1
  165. package/src/lib/test/createTestApp.ts +19 -1
  166. package/src/lib/ui/README.md +1 -1
  167. package/src/lib/ui/activePendingCells.ts +14 -0
  168. package/src/lib/ui/compile/BLOCK_KEYWORDS.ts +21 -0
  169. package/src/lib/ui/compile/SSR_ESCAPE.ts +4 -1
  170. package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +35 -7
  171. package/src/lib/ui/compile/abideUiPlugin.ts +19 -2
  172. package/src/lib/ui/compile/analyzeComponent.ts +89 -6
  173. package/src/lib/ui/compile/assignmentTargetNames.ts +54 -0
  174. package/src/lib/ui/compile/asyncInterpolationFields.ts +152 -0
  175. package/src/lib/ui/compile/asyncValuePositionError.ts +21 -0
  176. package/src/lib/ui/compile/asyncValuePositionInterpolations.ts +64 -0
  177. package/src/lib/ui/compile/attrLiftPosition.ts +18 -0
  178. package/src/lib/ui/compile/bindListenEvent.ts +5 -6
  179. package/src/lib/ui/compile/cachedSourceFile.ts +40 -0
  180. package/src/lib/ui/compile/catchBinding.ts +7 -5
  181. package/src/lib/ui/compile/classifyInterpolationType.ts +46 -0
  182. package/src/lib/ui/compile/collectAbideDiagnostics.ts +96 -0
  183. package/src/lib/ui/compile/compileComponent.ts +19 -3
  184. package/src/lib/ui/compile/compileModule.ts +27 -58
  185. package/src/lib/ui/compile/compileSSR.ts +52 -13
  186. package/src/lib/ui/compile/compileShadow.ts +265 -42
  187. package/src/lib/ui/compile/composeProps.ts +15 -4
  188. package/src/lib/ui/compile/createShadowLanguageService.ts +116 -68
  189. package/src/lib/ui/compile/createShadowProgram.ts +35 -6
  190. package/src/lib/ui/compile/declaredNames.ts +36 -0
  191. package/src/lib/ui/compile/desugarSignals.ts +419 -37
  192. package/src/lib/ui/compile/expressionIsPrefixEvaluable.ts +19 -0
  193. package/src/lib/ui/compile/generateBuild.ts +74 -17
  194. package/src/lib/ui/compile/generateSSR.ts +286 -75
  195. package/src/lib/ui/compile/hoistableAwaits.ts +193 -0
  196. package/src/lib/ui/compile/hoistableChildRenders.ts +112 -0
  197. package/src/lib/ui/compile/interpolatedTemplateLiteral.ts +3 -1
  198. package/src/lib/ui/compile/interpolationClassifierForRoot.ts +37 -0
  199. package/src/lib/ui/compile/isSpuriousAsyncReadDiagnostic.ts +174 -0
  200. package/src/lib/ui/compile/isWhitespaceText.ts +10 -2
  201. package/src/lib/ui/compile/liftAsyncSubExpressions.ts +166 -0
  202. package/src/lib/ui/compile/lowerAsyncInterpolations.ts +92 -0
  203. package/src/lib/ui/compile/lowerContext.ts +10 -0
  204. package/src/lib/ui/compile/lowerDocAccess.ts +51 -10
  205. package/src/lib/ui/compile/lowerScript.ts +40 -4
  206. package/src/lib/ui/compile/nodeAtShadowOffset.ts +28 -0
  207. package/src/lib/ui/compile/parseTemplate.ts +18 -1090
  208. package/src/lib/ui/compile/parseTemplateRecovering.ts +1385 -0
  209. package/src/lib/ui/compile/referencedIdentifiers.ts +35 -0
  210. package/src/lib/ui/compile/renameSignalRefs.ts +26 -40
  211. package/src/lib/ui/compile/resolveReactiveExport.ts +4 -7
  212. package/src/lib/ui/compile/scopeCss.ts +27 -4
  213. package/src/lib/ui/compile/seedTypeClassifierForRoot.ts +65 -0
  214. package/src/lib/ui/compile/shadowInterpolationClassifier.ts +47 -0
  215. package/src/lib/ui/compile/sourceFileOptionsSignature.ts +20 -0
  216. package/src/lib/ui/compile/structuralHeadTokens.ts +107 -0
  217. package/src/lib/ui/compile/templateSemanticTokens.ts +21 -0
  218. package/src/lib/ui/compile/templateStartOffset.ts +15 -0
  219. package/src/lib/ui/compile/tryPlan.ts +4 -3
  220. package/src/lib/ui/compile/types/AnalyzedComponent.ts +4 -0
  221. package/src/lib/ui/compile/types/AsyncInterpolationField.ts +19 -0
  222. package/src/lib/ui/compile/types/InterpolationClassifier.ts +12 -0
  223. package/src/lib/ui/compile/types/InterpolationKind.ts +7 -0
  224. package/src/lib/ui/compile/types/ParseDiagnostic.ts +8 -0
  225. package/src/lib/ui/compile/types/SeedTypeClassifier.ts +15 -0
  226. package/src/lib/ui/compile/types/TemplateNode.ts +36 -4
  227. package/src/lib/ui/compile/types/ValuePositionInterpolation.ts +13 -0
  228. package/src/lib/ui/compile/writtenTemplateNames.ts +84 -0
  229. package/src/lib/ui/computed.ts +28 -1
  230. package/src/lib/ui/createScope.ts +35 -68
  231. package/src/lib/ui/dom/anchoredBranch.ts +142 -0
  232. package/src/lib/ui/dom/appendText.ts +8 -3
  233. package/src/lib/ui/dom/awaitBlock.ts +62 -75
  234. package/src/lib/ui/dom/bindProp.ts +22 -0
  235. package/src/lib/ui/dom/bindableProp.ts +47 -0
  236. package/src/lib/ui/dom/cellPending.ts +24 -0
  237. package/src/lib/ui/dom/discardBoundary.ts +24 -6
  238. package/src/lib/ui/dom/disposeRange.ts +2 -1
  239. package/src/lib/ui/dom/each.ts +41 -12
  240. package/src/lib/ui/dom/eachAsync.ts +39 -3
  241. package/src/lib/ui/dom/fillBefore.ts +6 -7
  242. package/src/lib/ui/dom/fillBoundary.ts +2 -3
  243. package/src/lib/ui/dom/fillRange.ts +4 -4
  244. package/src/lib/ui/dom/hydrate.ts +6 -12
  245. package/src/lib/ui/dom/isComment.ts +1 -1
  246. package/src/lib/ui/dom/matchingRangeClose.ts +29 -0
  247. package/src/lib/ui/dom/mergeProps.ts +1 -1
  248. package/src/lib/ui/dom/mount.ts +1 -2
  249. package/src/lib/ui/dom/mountChild.ts +9 -40
  250. package/src/lib/ui/dom/mountRange.ts +2 -3
  251. package/src/lib/ui/dom/mountSlot.ts +1 -1
  252. package/src/lib/ui/dom/mountStreamedChild.ts +84 -0
  253. package/src/lib/ui/dom/mountSwappableRange.ts +46 -4
  254. package/src/lib/ui/dom/mutateDocContainer.ts +65 -0
  255. package/src/lib/ui/dom/on.ts +2 -2
  256. package/src/lib/ui/dom/readCell.ts +40 -0
  257. package/src/lib/ui/dom/restProps.ts +2 -2
  258. package/src/lib/ui/dom/spreadProps.ts +3 -4
  259. package/src/lib/ui/dom/switchBlock.ts +30 -7
  260. package/src/lib/ui/dom/tryBlock.ts +233 -70
  261. package/src/lib/ui/dom/types/SwitchCase.ts +5 -1
  262. package/src/lib/ui/dom/when.ts +12 -2
  263. package/src/lib/ui/dom/withScope.ts +9 -2
  264. package/src/lib/ui/finalizeStreamedChildren.ts +89 -0
  265. package/src/lib/ui/flight.ts +56 -0
  266. package/src/lib/ui/html.ts +12 -1
  267. package/src/lib/ui/isolateCellBarrier.ts +17 -0
  268. package/src/lib/ui/linked.ts +48 -2
  269. package/src/lib/ui/props.ts +17 -0
  270. package/src/lib/ui/remoteProxy.ts +84 -159
  271. package/src/lib/ui/renderChain.ts +53 -13
  272. package/src/lib/ui/renderToStream.ts +22 -18
  273. package/src/lib/ui/resumeSeedScript.ts +1 -1
  274. package/src/lib/ui/router.ts +86 -53
  275. package/src/lib/ui/runtime/AsyncCellError.ts +20 -0
  276. package/src/lib/ui/runtime/CELL_SEED.ts +14 -0
  277. package/src/lib/ui/runtime/CHILD_PRESENT.ts +2 -2
  278. package/src/lib/ui/runtime/CURRENT_BOUNDARY.ts +11 -0
  279. package/src/lib/ui/runtime/CURRENT_PATH.ts +29 -0
  280. package/src/lib/ui/runtime/RENDER.ts +10 -7
  281. package/src/lib/ui/runtime/RESUME.ts +4 -4
  282. package/src/lib/ui/runtime/STREAMED_CELLS.ts +57 -0
  283. package/src/lib/ui/runtime/ambientPathBacking.ts +32 -0
  284. package/src/lib/ui/runtime/applyPatchToTree.ts +17 -4
  285. package/src/lib/ui/runtime/blockId.ts +31 -0
  286. package/src/lib/ui/runtime/boundaryFor.ts +11 -0
  287. package/src/lib/ui/runtime/cellBarrierBacking.ts +30 -0
  288. package/src/lib/ui/runtime/createAsyncCell.ts +300 -0
  289. package/src/lib/ui/runtime/createDoc.ts +31 -54
  290. package/src/lib/ui/runtime/createEffectNode.ts +9 -0
  291. package/src/lib/ui/runtime/enterRenderPass.ts +5 -4
  292. package/src/lib/ui/runtime/flushEffects.ts +33 -1
  293. package/src/lib/ui/runtime/isAsyncFunction.ts +14 -0
  294. package/src/lib/ui/runtime/nextBlockId.ts +8 -7
  295. package/src/lib/ui/runtime/renderPath.ts +16 -0
  296. package/src/lib/ui/runtime/scope.ts +11 -0
  297. package/src/lib/ui/runtime/toTeardown.ts +10 -3
  298. package/src/lib/ui/runtime/types/Boundary.ts +9 -0
  299. package/src/lib/ui/runtime/types/RenderContext.ts +9 -7
  300. package/src/lib/ui/runtime/types/SsrRender.ts +9 -2
  301. package/src/lib/ui/runtime/types/UiComponent.ts +1 -5
  302. package/src/lib/ui/runtime/types/UiProps.ts +6 -5
  303. package/src/lib/ui/runtime/withOptionalPath.ts +8 -0
  304. package/src/lib/ui/runtime/withPath.ts +16 -0
  305. package/src/lib/ui/runtime/withPathFrom.ts +20 -0
  306. package/src/lib/ui/runtime/withoutHydration.ts +22 -0
  307. package/src/lib/ui/seedStreamedResolution.ts +31 -6
  308. package/src/lib/ui/settleAsyncCells.ts +24 -0
  309. package/src/lib/ui/socketProxy.ts +1 -1
  310. package/src/lib/ui/startClient.ts +16 -31
  311. package/src/lib/ui/state.ts +9 -3
  312. package/src/lib/ui/trackedComputed.ts +68 -0
  313. package/src/lib/ui/types/Scope.ts +8 -24
  314. package/src/lib/ui/watch.ts +3 -3
  315. package/src/serverEntry.ts +14 -0
  316. package/template/src/server/rpc/getHello.ts +15 -13
  317. package/template/test/app.test.ts +1 -1
  318. package/src/lib/server/runtime/devHotModuleResponse.ts +0 -41
  319. package/src/lib/shared/DEV_HOT_PREFIX.ts +0 -7
  320. package/src/lib/shared/UNREACHABLE_STATUSES.ts +0 -13
  321. package/src/lib/shared/hasReplayableRequest.ts +0 -17
  322. package/src/lib/shared/hydratingSlot.ts +0 -12
  323. package/src/lib/shared/outboxProbeSlot.ts +0 -20
  324. package/src/lib/shared/types/Outbox.ts +0 -9
  325. package/src/lib/shared/types/OutboxEntry.ts +0 -27
  326. package/src/lib/shared/types/SmartReadOptions.ts +0 -36
  327. package/src/lib/shared/wakeHydrationPeeks.ts +0 -20
  328. package/src/lib/ui/COMPONENT_WRAPPER_PREFIX.ts +0 -5
  329. package/src/lib/ui/compile/REACTIVE_CALLEES.ts +0 -11
  330. package/src/lib/ui/compile/assertRuntimeHelpersBound.ts +0 -80
  331. package/src/lib/ui/compile/markupTokens.ts +0 -313
  332. package/src/lib/ui/compile/structuralBlockTokens.ts +0 -100
  333. package/src/lib/ui/dom/applyResolved.ts +0 -87
  334. package/src/lib/ui/dom/scopeLabel.ts +0 -21
  335. package/src/lib/ui/dom/text.ts +0 -20
  336. package/src/lib/ui/history.ts +0 -101
  337. package/src/lib/ui/installHotBridge.ts +0 -93
  338. package/src/lib/ui/installInspectorBridge.ts +0 -140
  339. package/src/lib/ui/outbox.ts +0 -35
  340. package/src/lib/ui/persist.ts +0 -115
  341. package/src/lib/ui/rpcOutbox/createOutboxQueue.ts +0 -281
  342. package/src/lib/ui/rpcOutbox/outboxRegistry.ts +0 -69
  343. package/src/lib/ui/runtime/PATCH_BUS.ts +0 -28
  344. package/src/lib/ui/runtime/captureModelDoc.ts +0 -28
  345. package/src/lib/ui/runtime/hotInstances.ts +0 -10
  346. package/src/lib/ui/runtime/hotReloadEnabled.ts +0 -8
  347. package/src/lib/ui/runtime/hotReplace.ts +0 -38
  348. package/src/lib/ui/runtime/liveScopes.ts +0 -15
  349. package/src/lib/ui/runtime/localStoragePersistence.ts +0 -47
  350. package/src/lib/ui/runtime/registerHotInstance.ts +0 -23
  351. package/src/lib/ui/runtime/seedModelDoc.ts +0 -26
  352. package/src/lib/ui/runtime/types/HotInstance.ts +0 -22
  353. package/src/lib/ui/runtime/types/PatchEvent.ts +0 -16
  354. package/src/lib/ui/seedResolved.ts +0 -28
  355. package/src/lib/ui/sync.ts +0 -48
  356. package/src/lib/ui/types/History.ts +0 -14
  357. package/src/lib/ui/types/PersistHandle.ts +0 -11
  358. package/src/lib/ui/types/PersistenceStore.ts +0 -12
  359. package/src/lib/ui/types/ResolvedFrame.ts +0 -15
  360. package/src/lib/ui/types/SyncTransport.ts +0 -13
@@ -4,14 +4,18 @@ import { messageFromError } from '../../shared/messageFromError.ts'
4
4
  import { mapSyntacticClassification, mapTsClassification } from './ABIDE_SEMANTIC_TOKENS_LEGEND.ts'
5
5
  import { assetModulesFile } from './assetModulesFile.ts'
6
6
  import { compileShadow } from './compileShadow.ts'
7
+ import { isSpuriousAsyncReadDiagnostic } from './isSpuriousAsyncReadDiagnostic.ts'
7
8
  import { loadShadowTsConfig } from './loadShadowTsConfig.ts'
8
9
  import { pagePropsType } from './pagePropsType.ts'
9
10
  import { remapShadowDiagnostic } from './remapShadowDiagnostic.ts'
10
11
  import { resolveAbideImports } from './resolveAbideImports.ts'
12
+ import { shadowInterpolationClassifier } from './shadowInterpolationClassifier.ts'
11
13
  import { shadowNaming } from './shadowNaming.ts'
12
14
  import { sourceToShadowOffset } from './sourceToShadowOffset.ts'
15
+ import { templateStartOffset } from './templateStartOffset.ts'
13
16
  import type { AbideDiagnostic } from './types/AbideDiagnostic.ts'
14
17
  import type { CompiledShadow } from './types/CompiledShadow.ts'
18
+ import type { InterpolationClassifier } from './types/InterpolationClassifier.ts'
15
19
  import type { SemanticToken } from './types/SemanticToken.ts'
16
20
 
17
21
  const { suffixed, isShadow, sourceOf } = shadowNaming
@@ -45,12 +49,6 @@ export function createShadowLanguageService(cwd: string): ShadowLanguageService
45
49
  const { options, fileNames } = loadShadowTsConfig(cwd)
46
50
  const overlays = new Map<string, string>()
47
51
  const versions = new Map<string, number>()
48
- const shadows = new Map<string, CompiledShadow>()
49
- const parseErrors = new Map<string, string>()
50
- /* Memo of `shadowText` output keyed by source path, tagged with the shadow
51
- version it was compiled at; a stale tag forces recompilation. `update`/`close`
52
- bump that version, so the next read recompiles. */
53
- const compiledAt = new Map<string, { version: number; code: string }>()
54
52
  /* Memo of `pagePropsType` (route re-parse) per source path; the path → props
55
53
  type mapping is immutable, so no version tag is needed. */
56
54
  const propsTypes = new Map<string, string | undefined>()
@@ -69,33 +67,6 @@ export function createShadowLanguageService(cwd: string): ShadowLanguageService
69
67
  const exists = (abidePath: string): boolean =>
70
68
  overlays.has(abidePath) || ts.sys.fileExists(abidePath)
71
69
 
72
- /* Compiles (and caches) a component's shadow from its overlay or disk text; a
73
- template parse error yields a minimal valid module + a recorded message.
74
- Memoised against the shadow's version (bumped by `update`/`close`), so
75
- repeated reads at the same version skip the ~700-line compile and the
76
- `shadows`/`parseErrors` caches stay current. */
77
- const shadowText = (abidePath: string): string => {
78
- const version = versions.get(suffixed(abidePath)) ?? 0
79
- const memo = compiledAt.get(abidePath)
80
- if (memo !== undefined && memo.version === version) {
81
- return memo.code
82
- }
83
- const source = overlays.get(abidePath) ?? ts.sys.readFile(abidePath) ?? ''
84
- try {
85
- const compiled = compileShadow(source, propsTypeOf(abidePath))
86
- shadows.set(abidePath, compiled)
87
- parseErrors.delete(abidePath)
88
- compiledAt.set(abidePath, { version, code: compiled.code })
89
- return compiled.code
90
- } catch (error) {
91
- shadows.set(abidePath, { code: '', mappings: [] })
92
- parseErrors.set(abidePath, messageFromError(error))
93
- const code = 'export default function (): void {}\n'
94
- compiledAt.set(abidePath, { version, code })
95
- return code
96
- }
97
- }
98
-
99
70
  /* All component shadows: those on disk plus any opened (possibly unsaved) ones. */
100
71
  const shadowNames = (): string[] => {
101
72
  const disk = [...new Bun.Glob('**/*.abide').scanSync({ cwd, onlyFiles: true })]
@@ -104,44 +75,99 @@ export function createShadowLanguageService(cwd: string): ShadowLanguageService
104
75
  return [...new Set([...disk, ...overlays.keys()])].map(suffixed)
105
76
  }
106
77
 
107
- const moduleResolutionHost: ts.ModuleResolutionHost = {
108
- fileExists: (fileName) =>
109
- fileName === assets.path ||
110
- (isShadow(fileName) ? exists(sourceOf(fileName)) : ts.sys.fileExists(fileName)),
111
- readFile: (fileName) =>
112
- fileName === assets.path
113
- ? assets.content
114
- : isShadow(fileName)
115
- ? shadowText(sourceOf(fileName))
116
- : ts.sys.readFile(fileName),
117
- }
118
-
119
- const host: ts.LanguageServiceHost = {
120
- getScriptFileNames: () => [assets.path, ...fileNames, ...shadowNames()],
121
- getScriptVersion: (fileName) => String(versions.get(fileName) ?? 0),
122
- getScriptSnapshot: (fileName) => {
123
- if (fileName === assets.path) {
124
- return ts.ScriptSnapshot.fromString(assets.content)
78
+ /* One incremental language service over the shadow world, its shadows built by `compile`. Two
79
+ are made: a VERBATIM one (the classifier source — interpolations un-wrapped, so `getFoo()`
80
+ still types as `Promise`), and the WRAPPED main one (async interpolations peek-wrapped, ADR-
81
+ 0032, so hover/completions/diagnostics see the RESOLVED value). They share `overlays`/`versions`
82
+ so both reflect unsaved edits, but hold SEPARATE shadow caches + document registries (the same
83
+ shadow file name carries different text in each). */
84
+ const buildService = (compile: (source: string, abidePath: string) => CompiledShadow) => {
85
+ const shadows = new Map<string, CompiledShadow>()
86
+ const parseErrors = new Map<string, string>()
87
+ /* Memo of `shadowText` output keyed by source path, tagged with the shadow version it was
88
+ compiled at; a stale tag forces recompilation. `update`/`close` bump that version. */
89
+ const compiledAt = new Map<string, { version: number; code: string }>()
90
+ const shadowText = (abidePath: string): string => {
91
+ const version = versions.get(suffixed(abidePath)) ?? 0
92
+ const memo = compiledAt.get(abidePath)
93
+ if (memo !== undefined && memo.version === version) {
94
+ return memo.code
125
95
  }
126
- if (isShadow(fileName)) {
127
- return exists(sourceOf(fileName))
128
- ? ts.ScriptSnapshot.fromString(shadowText(sourceOf(fileName)))
129
- : undefined
96
+ const source = overlays.get(abidePath) ?? ts.sys.readFile(abidePath) ?? ''
97
+ try {
98
+ const compiled = compile(source, abidePath)
99
+ shadows.set(abidePath, compiled)
100
+ parseErrors.delete(abidePath)
101
+ compiledAt.set(abidePath, { version, code: compiled.code })
102
+ return compiled.code
103
+ } catch (error) {
104
+ shadows.set(abidePath, { code: '', mappings: [] })
105
+ parseErrors.set(abidePath, messageFromError(error))
106
+ const code = 'export default function (): void {}\n'
107
+ compiledAt.set(abidePath, { version, code })
108
+ return code
130
109
  }
131
- const text = ts.sys.readFile(fileName)
132
- return text === undefined ? undefined : ts.ScriptSnapshot.fromString(text)
133
- },
134
- getCurrentDirectory: () => cwd,
135
- getCompilationSettings: () => options,
136
- getDefaultLibFileName: (compilerOptions) => ts.getDefaultLibFilePath(compilerOptions),
137
- fileExists: moduleResolutionHost.fileExists,
138
- readFile: moduleResolutionHost.readFile,
139
- readDirectory: ts.sys.readDirectory,
140
- directoryExists: ts.sys.directoryExists,
141
- getDirectories: ts.sys.getDirectories,
142
- resolveModuleNames: resolveAbideImports(options, moduleResolutionHost),
110
+ }
111
+ const moduleResolutionHost: ts.ModuleResolutionHost = {
112
+ fileExists: (fileName) =>
113
+ fileName === assets.path ||
114
+ (isShadow(fileName) ? exists(sourceOf(fileName)) : ts.sys.fileExists(fileName)),
115
+ readFile: (fileName) =>
116
+ fileName === assets.path
117
+ ? assets.content
118
+ : isShadow(fileName)
119
+ ? shadowText(sourceOf(fileName))
120
+ : ts.sys.readFile(fileName),
121
+ }
122
+ const host: ts.LanguageServiceHost = {
123
+ getScriptFileNames: () => [assets.path, ...fileNames, ...shadowNames()],
124
+ getScriptVersion: (fileName) => String(versions.get(fileName) ?? 0),
125
+ getScriptSnapshot: (fileName) => {
126
+ if (fileName === assets.path) {
127
+ return ts.ScriptSnapshot.fromString(assets.content)
128
+ }
129
+ if (isShadow(fileName)) {
130
+ return exists(sourceOf(fileName))
131
+ ? ts.ScriptSnapshot.fromString(shadowText(sourceOf(fileName)))
132
+ : undefined
133
+ }
134
+ const text = ts.sys.readFile(fileName)
135
+ return text === undefined ? undefined : ts.ScriptSnapshot.fromString(text)
136
+ },
137
+ getCurrentDirectory: () => cwd,
138
+ getCompilationSettings: () => options,
139
+ getDefaultLibFileName: (compilerOptions) => ts.getDefaultLibFilePath(compilerOptions),
140
+ fileExists: moduleResolutionHost.fileExists,
141
+ readFile: moduleResolutionHost.readFile,
142
+ readDirectory: ts.sys.readDirectory,
143
+ directoryExists: ts.sys.directoryExists,
144
+ getDirectories: ts.sys.getDirectories,
145
+ resolveModuleNames: resolveAbideImports(options, moduleResolutionHost),
146
+ }
147
+ return {
148
+ service: ts.createLanguageService(host, ts.createDocumentRegistry()),
149
+ shadows,
150
+ parseErrors,
151
+ shadowText,
152
+ }
153
+ }
154
+
155
+ const verbatim = buildService((source, abidePath) =>
156
+ compileShadow(source, propsTypeOf(abidePath)),
157
+ )
158
+ /* The wrapped shadow's peek-wrap is type-directed: it asks the verbatim program which
159
+ sub-expressions are async. `getProgram()` reflects the shared overlays/versions, so the
160
+ classifier tracks unsaved edits; fail-open to `undefined` (verbatim shadow) if unavailable. */
161
+ const classifierFor = (abidePath: string): InterpolationClassifier | undefined => {
162
+ const program = verbatim.service.getProgram()
163
+ return program === undefined
164
+ ? undefined
165
+ : shadowInterpolationClassifier(program, verbatim.shadows, abidePath)
143
166
  }
144
- const service = ts.createLanguageService(host, ts.createDocumentRegistry())
167
+ const main = buildService((source, abidePath) =>
168
+ compileShadow(source, propsTypeOf(abidePath), classifierFor(abidePath)),
169
+ )
170
+ const { service, shadows, parseErrors, shadowText } = main
145
171
 
146
172
  const bump = (abidePath: string): void => {
147
173
  const fileName = suffixed(abidePath)
@@ -178,6 +204,12 @@ export function createShadowLanguageService(cwd: string): ShadowLanguageService
178
204
  ]
179
205
  }
180
206
  const mappings = shadows.get(abidePath)?.mappings ?? []
207
+ /* The shadow file + checker + template boundary, for the ADR-0032 bare-async-read
208
+ suppression (mirrors `collectAbideDiagnostics` so the editor and CLI agree). */
209
+ const shadowFile = service.getProgram()?.getSourceFile(fileName)
210
+ const checker = service.getProgram()?.getTypeChecker()
211
+ const source = overlays.get(abidePath) ?? ts.sys.readFile(abidePath) ?? ''
212
+ const templateStart = templateStartOffset(source)
181
213
  return raw.flatMap((diagnostic) => {
182
214
  if (diagnostic.start === undefined) {
183
215
  return []
@@ -190,6 +222,22 @@ export function createShadowLanguageService(cwd: string): ShadowLanguageService
190
222
  if (located === undefined) {
191
223
  return []
192
224
  }
225
+ /* Drop the spurious "property missing on Promise" / "condition always defined" a
226
+ bare async read provokes — the runtime peeks the resolved value (ADR-0032). */
227
+ if (
228
+ shadowFile !== undefined &&
229
+ checker !== undefined &&
230
+ located.start >= templateStart &&
231
+ isSpuriousAsyncReadDiagnostic(
232
+ shadowFile,
233
+ checker,
234
+ diagnostic.code,
235
+ diagnostic.start,
236
+ diagnostic.length ?? 0,
237
+ )
238
+ ) {
239
+ return []
240
+ }
193
241
  return [
194
242
  {
195
243
  file: abidePath,
@@ -2,12 +2,15 @@ import { resolve } from 'node:path'
2
2
  import ts from 'typescript'
3
3
  import { messageFromError } from '../../shared/messageFromError.ts'
4
4
  import { assetModulesFile } from './assetModulesFile.ts'
5
+ import { cachedSourceFile } from './cachedSourceFile.ts'
5
6
  import { compileShadow } from './compileShadow.ts'
6
7
  import { loadShadowTsConfig } from './loadShadowTsConfig.ts'
7
8
  import { pagePropsType } from './pagePropsType.ts'
8
9
  import { resolveAbideImports } from './resolveAbideImports.ts'
9
10
  import { shadowNaming } from './shadowNaming.ts'
11
+ import { sourceFileOptionsSignature } from './sourceFileOptionsSignature.ts'
10
12
  import type { CompiledShadow } from './types/CompiledShadow.ts'
13
+ import type { InterpolationClassifier } from './types/InterpolationClassifier.ts'
11
14
 
12
15
  const { suffixed, isShadow, sourceOf } = shadowNaming
13
16
 
@@ -29,7 +32,16 @@ the project's tsconfig (lib/paths/baseUrl) so the shadows type-check against the
29
32
  same world the app does; `noUnusedLocals`/`noUnusedParameters` are forced off
30
33
  because the shadow legitimately declares scope bindings a template may not read.
31
34
  */
32
- export function createShadowProgram(cwd: string, abidePaths?: string[]): ShadowProgram {
35
+ export function createShadowProgram(
36
+ cwd: string,
37
+ abidePaths?: string[],
38
+ /* Per-file interpolation classifier (ADR-0032). When provided, each shadow peek-wraps its async
39
+ sub-expressions so they type-check against the RESOLVED value; it must be backed by a SEPARATE
40
+ verbatim program (see `checkAbide`), since a classifier reading these same wrapped shadows
41
+ would be circular. Absent ⇒ verbatim shadows (the classifier-source pass, and any caller that
42
+ doesn't need the peek types). */
43
+ classifierFor?: (abidePath: string) => InterpolationClassifier | undefined,
44
+ ): ShadowProgram {
33
45
  const { options, fileNames } = loadShadowTsConfig(cwd)
34
46
  const shadows = new Map<string, CompiledShadow>()
35
47
  const parseErrors = new Map<string, string>()
@@ -47,7 +59,11 @@ export function createShadowProgram(cwd: string, abidePaths?: string[]): ShadowP
47
59
  const shadowText = (abidePath: string): string => {
48
60
  const source = ts.sys.readFile(abidePath) ?? ''
49
61
  try {
50
- const compiled = compileShadow(source, pagePropsType(abidePath))
62
+ const compiled = compileShadow(
63
+ source,
64
+ pagePropsType(abidePath),
65
+ classifierFor?.(abidePath),
66
+ )
51
67
  shadows.set(abidePath, compiled)
52
68
  parseErrors.delete(abidePath)
53
69
  return compiled.code
@@ -61,22 +77,35 @@ export function createShadowProgram(cwd: string, abidePaths?: string[]): ShadowP
61
77
  /* Ambient declarations for bundler-handled asset imports (`*.css`, …). */
62
78
  const assets = assetModulesFile(cwd)
63
79
 
80
+ /* The parse/bind-affecting options are identical for every source in a program, so compute
81
+ the cache signature once and reuse it for every file (see `cachedSourceFile`). */
82
+ const signature = sourceFileOptionsSignature(options)
83
+
64
84
  const host = ts.createCompilerHost(options, true)
65
85
  const originalGetSourceFile = host.getSourceFile.bind(host)
66
86
  host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreate) => {
67
87
  if (fileName === assets.path) {
68
- return ts.createSourceFile(fileName, assets.content, languageVersionOrOptions, true)
88
+ return cachedSourceFile(fileName, assets.content, languageVersionOrOptions, signature)
69
89
  }
70
90
  if (isShadow(fileName)) {
71
- return ts.createSourceFile(
91
+ /* `shadowText` populates the per-program `shadows`/`parseErrors` maps as a side effect,
92
+ so it must run on every call — only its expensive TS parse is memoised by `cachedSourceFile`. */
93
+ return cachedSourceFile(
72
94
  fileName,
73
95
  shadowText(sourceOf(fileName)),
74
96
  languageVersionOrOptions,
75
- true,
97
+ signature,
76
98
  ts.ScriptKind.TS,
77
99
  )
78
100
  }
79
- return originalGetSourceFile(fileName, languageVersionOrOptions, onError, shouldCreate)
101
+ /* Real `.ts`/`.d.ts` inputs (the ~3MB of default libs plus resolved dependencies) — read the
102
+ text and reuse the parsed file across programs when it is byte-identical. Fall back to the
103
+ default host on a read failure so its missing-file / `onError` handling is preserved. */
104
+ const text = ts.sys.readFile(fileName)
105
+ if (text === undefined) {
106
+ return originalGetSourceFile(fileName, languageVersionOrOptions, onError, shouldCreate)
107
+ }
108
+ return cachedSourceFile(fileName, text, languageVersionOrOptions, signature)
80
109
  }
81
110
  host.fileExists = (fileName) =>
82
111
  fileName === assets.path ||
@@ -0,0 +1,36 @@
1
+ import ts from 'typescript'
2
+
3
+ /* Top-level declared names of a code block — a nested `<script>`'s locals, or a snippet's params
4
+ parsed as a destructuring pattern. Best-effort; on a parse miss returns empty (fail-open on the
5
+ binder side is safe: a script's names only ADD conservatism to a prefix-evaluability check when
6
+ present). Shared by the await-flight and child-render-flight classifiers (ADR-0034 / ADR-0037). */
7
+ export function declaredNames(code: string): Set<string> {
8
+ const names = new Set<string>()
9
+ let source: ts.SourceFile
10
+ try {
11
+ source = ts.createSourceFile('script.ts', code, ts.ScriptTarget.Latest, true)
12
+ } catch {
13
+ return names
14
+ }
15
+ const collectBinding = (name: ts.BindingName): void => {
16
+ if (ts.isIdentifier(name)) {
17
+ names.add(name.text)
18
+ return
19
+ }
20
+ for (const element of name.elements) {
21
+ if (ts.isBindingElement(element)) {
22
+ collectBinding(element.name)
23
+ }
24
+ }
25
+ }
26
+ for (const statement of source.statements) {
27
+ if (ts.isVariableStatement(statement)) {
28
+ for (const declaration of statement.declarationList.declarations) {
29
+ collectBinding(declaration.name)
30
+ }
31
+ } else if (ts.isFunctionDeclaration(statement) && statement.name !== undefined) {
32
+ names.add(statement.name.text)
33
+ }
34
+ }
35
+ return names
36
+ }