@abide/abide 0.57.1 → 0.100.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 (1197) hide show
  1. package/CHANGELOG.md +3 -1773
  2. package/bin/abide.ts +788 -204
  3. package/package.json +30 -152
  4. package/scaffold/src/server/app.ts +6 -0
  5. package/scaffold/src/shared/.gitkeep +0 -0
  6. package/scaffold/src/ui/app.html +8 -0
  7. package/scaffold/src/ui/pages/page.abide +13 -0
  8. package/src/compiler/CHARACTER_REFERENCES.ts +2242 -0
  9. package/src/compiler/CheckerAnswer.ts +62 -0
  10. package/src/compiler/Cursor.ts +367 -0
  11. package/src/compiler/Finding.ts +2 -0
  12. package/src/compiler/Lowering.ts +648 -0
  13. package/src/compiler/PositionTable.ts +125 -0
  14. package/src/compiler/REACTIVE_MEMBERS.ts +36 -0
  15. package/src/compiler/SHARED_NAMES.ts +45 -0
  16. package/src/compiler/SPECIFIERS.ts +16 -0
  17. package/src/compiler/ShadowMap.ts +144 -0
  18. package/src/compiler/TemplateNode.ts +176 -0
  19. package/src/compiler/TypeSession.ts +1079 -0
  20. package/src/compiler/VOID_ELEMENTS.ts +22 -0
  21. package/src/compiler/aliasedSymbol.ts +15 -0
  22. package/src/compiler/ambientReadsIn.ts +152 -0
  23. package/src/compiler/argsDefaultsIn.ts +173 -0
  24. package/src/compiler/argsSchemaOf.ts +230 -0
  25. package/src/compiler/checkApp.ts +117 -0
  26. package/src/compiler/checkedShadow.ts +182 -0
  27. package/src/compiler/classifyRead.ts +577 -0
  28. package/src/compiler/classifyTemplate.ts +501 -0
  29. package/src/compiler/compileApp.ts +559 -0
  30. package/src/compiler/compiledEntry.ts +141 -0
  31. package/src/compiler/componentGraph.ts +139 -0
  32. package/src/compiler/declaredExports.ts +645 -0
  33. package/src/compiler/decodeCharacterReferences.ts +111 -0
  34. package/src/compiler/emitClient.ts +1343 -0
  35. package/src/compiler/emitComponent.ts +162 -0
  36. package/src/compiler/emitSource.ts +91 -0
  37. package/src/compiler/formatDiagnosis.ts +19 -0
  38. package/src/compiler/handlersUnder.ts +109 -0
  39. package/src/compiler/index.ts +15 -0
  40. package/src/compiler/invocationProps.ts +67 -0
  41. package/src/compiler/isNamedAlone.ts +9 -0
  42. package/src/compiler/lineOf.ts +38 -0
  43. package/src/compiler/parseAbide.ts +1341 -0
  44. package/src/compiler/projectShadow.ts +643 -0
  45. package/src/compiler/reactiveOptions.ts +82 -0
  46. package/src/compiler/reactiveTypes.ts +222 -0
  47. package/src/compiler/readSources.ts +100 -0
  48. package/src/compiler/readsIn.ts +1023 -0
  49. package/src/compiler/renderMarkup.ts +781 -0
  50. package/src/compiler/scaffold.ts +105 -0
  51. package/src/compiler/scopeStyles.ts +309 -0
  52. package/src/compiler/serveLanguage.ts +405 -0
  53. package/src/compiler/shareScope.ts +51 -0
  54. package/src/compiler/sharedModuleWrites.ts +88 -0
  55. package/src/compiler/splitImports.ts +387 -0
  56. package/src/compiler/templateWarnings.ts +128 -0
  57. package/src/compiler/tokenize.ts +317 -0
  58. package/src/compiler/trackingWarnings.ts +279 -0
  59. package/src/compiler/writeDefaultProject.ts +42 -0
  60. package/src/server/BRIDGE_VERSION.ts +3 -0
  61. package/src/server/CLIENT_BUILD.ts +56 -0
  62. package/src/server/DEFAULT_PORT.ts +6 -0
  63. package/src/server/DOCUMENT_HEADERS.ts +11 -0
  64. package/src/server/Inbox.ts +36 -0
  65. package/src/server/LogPanel.ts +239 -0
  66. package/src/server/MCP_PROTOCOL_VERSION.ts +3 -0
  67. package/src/server/SETTLE_MILLISECONDS.ts +7 -0
  68. package/src/server/VIRTUAL_DIRECTORY.ts +6 -0
  69. package/src/server/answerFailure.ts +91 -0
  70. package/src/server/answerRequest.ts +560 -0
  71. package/src/server/answerRpc.ts +537 -0
  72. package/src/server/answerSocket.ts +537 -0
  73. package/src/server/answerValue.ts +375 -0
  74. package/src/server/appDirectories.ts +9 -0
  75. package/src/server/appKit.ts +204 -0
  76. package/src/server/appPlugins.ts +26 -0
  77. package/src/server/argsFor.ts +40 -0
  78. package/src/server/assistant.ts +163 -0
  79. package/src/server/banner.ts +43 -0
  80. package/src/server/bridgeRelay.ts +249 -0
  81. package/src/server/buildDirectory.ts +10 -0
  82. package/src/server/callerOf.ts +60 -0
  83. package/src/server/claudeApi.ts +224 -0
  84. package/src/server/claudeCode.ts +187 -0
  85. package/src/server/clientBuildOptions.ts +49 -0
  86. package/src/server/coerceArgs.ts +110 -0
  87. package/src/server/commands.ts +442 -0
  88. package/src/server/componentImports.ts +56 -0
  89. package/src/server/componentModules.d.ts +9 -0
  90. package/src/server/compressAnswer.ts +66 -0
  91. package/src/server/config.ts +192 -0
  92. package/src/server/configFields.ts +92 -0
  93. package/src/server/createApp.ts +428 -0
  94. package/src/server/crossingOrigin.ts +49 -0
  95. package/src/server/csp.ts +77 -0
  96. package/src/server/devWorker.ts +613 -0
  97. package/src/server/faultPolicy.ts +59 -0
  98. package/src/server/fenceServer.ts +48 -0
  99. package/src/server/generatedSurfaces.ts +430 -0
  100. package/src/server/hooks.ts +190 -0
  101. package/src/server/index.ts +87 -0
  102. package/src/server/installServer.ts +47 -0
  103. package/src/server/launcherOptions.ts +62 -0
  104. package/src/server/launcherPage.ts +156 -0
  105. package/src/server/manifestOf.ts +114 -0
  106. package/src/server/muxUpgrade.ts +72 -0
  107. package/src/server/namesUnder.ts +15 -0
  108. package/src/server/nativeMenu.ts +296 -0
  109. package/src/server/negotiateEncoding.ts +39 -0
  110. package/src/server/plainAnswer.ts +19 -0
  111. package/src/server/prefers.ts +25 -0
  112. package/src/server/principal.ts +261 -0
  113. package/src/server/qualitiesOf.ts +22 -0
  114. package/src/server/randomToken.ts +9 -0
  115. package/src/server/reachable.ts +31 -0
  116. package/src/server/refuseAddressCollision.ts +30 -0
  117. package/src/server/remote.ts +242 -0
  118. package/src/server/render.ts +464 -0
  119. package/src/server/renderComponent.ts +33 -0
  120. package/src/server/reportHealth.ts +46 -0
  121. package/src/server/requestScope.ts +435 -0
  122. package/src/server/responseHelpers.ts +75 -0
  123. package/src/server/runCompiled.ts +44 -0
  124. package/src/server/runDesktop.ts +572 -0
  125. package/src/server/seedBuffer.ts +293 -0
  126. package/src/server/serveBuild.ts +198 -0
  127. package/src/server/serveDev.ts +499 -0
  128. package/src/server/shell.ts +506 -0
  129. package/src/server/surfaceOf.ts +47 -0
  130. package/src/server/testBuild.ts +237 -0
  131. package/src/server/trace.ts +151 -0
  132. package/src/server/versionOf.ts +109 -0
  133. package/src/server/withoutTrailingSlash.ts +4 -0
  134. package/src/shared/ADDRESSES.ts +69 -0
  135. package/src/shared/ANCHORS.ts +54 -0
  136. package/src/shared/Attributes.ts +339 -0
  137. package/src/shared/BOOLEAN_ATTRIBUTES.ts +41 -0
  138. package/src/shared/CHILDREN.ts +11 -0
  139. package/src/shared/CURRENT_ROUTER.ts +25 -0
  140. package/src/shared/CopyOptions.ts +19 -0
  141. package/src/shared/DEBUG_META.ts +6 -0
  142. package/src/shared/EARLY_CALLS.ts +8 -0
  143. package/src/shared/FAILURE_STATUS_TEXT.ts +48 -0
  144. package/src/shared/Failed.ts +146 -0
  145. package/src/shared/GLOBAL_GETS.ts +7 -0
  146. package/src/shared/Issues.ts +49 -0
  147. package/src/shared/JsonValue.ts +18 -0
  148. package/src/shared/LOAD_SIGNAL.ts +10 -0
  149. package/src/shared/MOUNT_META.ts +6 -0
  150. package/src/shared/Middleware.ts +34 -0
  151. package/src/shared/NAVIGATION_HEADER.ts +7 -0
  152. package/src/shared/PRINCIPAL_HEADER.ts +6 -0
  153. package/src/shared/RPC_SERVER.ts +67 -0
  154. package/src/shared/Raw.ts +90 -0
  155. package/src/shared/Schema.ts +229 -0
  156. package/src/shared/UNEXPECTED.ts +11 -0
  157. package/src/shared/URL_ATTRIBUTES.ts +19 -0
  158. package/src/shared/VERSION_HEADER.ts +6 -0
  159. package/src/shared/WORK.ts +37 -0
  160. package/src/shared/anchorMarkup.ts +15 -0
  161. package/src/shared/answerOf.ts +141 -0
  162. package/src/shared/applyPatch.ts +173 -0
  163. package/src/shared/armAnchor.ts +17 -0
  164. package/src/shared/attributeText.ts +50 -0
  165. package/src/shared/boundValue.ts +58 -0
  166. package/src/shared/cookies.ts +271 -0
  167. package/src/shared/csp.ts +55 -0
  168. package/src/shared/decodedOrKept.ts +14 -0
  169. package/src/shared/escapeText.ts +103 -0
  170. package/src/shared/framing.ts +131 -0
  171. package/src/shared/headKeyOf.ts +34 -0
  172. package/src/shared/health.ts +51 -0
  173. package/src/shared/index.ts +117 -0
  174. package/src/shared/isEventName.ts +10 -0
  175. package/src/shared/isRecord.ts +4 -0
  176. package/src/shared/issuesOf.ts +18 -0
  177. package/src/shared/jsonSchema.ts +50 -0
  178. package/src/shared/listOf.ts +20 -0
  179. package/src/shared/log.ts +284 -0
  180. package/src/shared/matchRoute.ts +99 -0
  181. package/src/shared/menuItem.ts +80 -0
  182. package/src/shared/mount.ts +45 -0
  183. package/src/shared/muxFrames.ts +35 -0
  184. package/src/shared/navigate.ts +26 -0
  185. package/src/shared/note.ts +24 -0
  186. package/src/shared/numberFromText.ts +10 -0
  187. package/src/shared/online.ts +19 -0
  188. package/src/shared/paint.ts +4 -0
  189. package/src/shared/principal.ts +145 -0
  190. package/src/shared/principalRotated.ts +47 -0
  191. package/src/shared/propCell.ts +99 -0
  192. package/src/shared/props.ts +24 -0
  193. package/src/shared/putOwn.ts +24 -0
  194. package/src/shared/queryText.ts +18 -0
  195. package/src/shared/reactive/CELL.ts +8 -0
  196. package/src/shared/reactive/Cursor.ts +223 -0
  197. package/src/shared/reactive/ENTRY_LIVES.ts +7 -0
  198. package/src/shared/reactive/Expiry.ts +103 -0
  199. package/src/shared/reactive/FOLLOWED.ts +8 -0
  200. package/src/shared/reactive/KEYED_BRAND.ts +8 -0
  201. package/src/shared/reactive/Keyed.ts +423 -0
  202. package/src/shared/reactive/MUTATION.ts +5 -0
  203. package/src/shared/reactive/NO_INITIAL.ts +6 -0
  204. package/src/shared/reactive/NotLanded.ts +21 -0
  205. package/src/shared/reactive/PATCHES.ts +11 -0
  206. package/src/shared/reactive/PATCH_SINKS.ts +26 -0
  207. package/src/shared/reactive/REACTIVE_BRAND.ts +9 -0
  208. package/src/shared/reactive/RESHAPING.ts +13 -0
  209. package/src/shared/reactive/Reactive.ts +4480 -0
  210. package/src/shared/reactive/SELECTION_MEMBERS.ts +12 -0
  211. package/src/shared/reactive/STREAMING.ts +5 -0
  212. package/src/shared/reactive/argsContract.ts +97 -0
  213. package/src/shared/reactive/byOf.ts +18 -0
  214. package/src/shared/reactive/callLoad.ts +200 -0
  215. package/src/shared/reactive/canonicalKey.ts +95 -0
  216. package/src/shared/reactive/chunksOfStream.ts +51 -0
  217. package/src/shared/reactive/index.ts +542 -0
  218. package/src/shared/reactive/isReactive.ts +19 -0
  219. package/src/shared/reactive/isThenable.ts +14 -0
  220. package/src/shared/reactive/matchesPattern.ts +16 -0
  221. package/src/shared/reactive/pairReactive.ts +41 -0
  222. package/src/shared/reactive/parameterDefaults.ts +356 -0
  223. package/src/shared/reactive/recordWrites.ts +472 -0
  224. package/src/shared/reactive/scoped.ts +157 -0
  225. package/src/shared/reactive/scoping.ts +64 -0
  226. package/src/shared/reactive/share.ts +91 -0
  227. package/src/shared/reactive/structural.ts +62 -0
  228. package/src/shared/reactive/tracking.ts +418 -0
  229. package/src/shared/reactive/watch.ts +310 -0
  230. package/src/shared/refuse.ts +224 -0
  231. package/src/shared/route.ts +29 -0
  232. package/src/shared/routePattern.ts +146 -0
  233. package/src/shared/rpc.ts +496 -0
  234. package/src/shared/rpcRequest.ts +73 -0
  235. package/src/shared/safeUrl.ts +68 -0
  236. package/src/shared/seededDocument.ts +36 -0
  237. package/src/shared/setUpLevels.ts +53 -0
  238. package/src/shared/slotValue.ts +34 -0
  239. package/src/shared/spread.ts +79 -0
  240. package/src/shared/takeEarlyCall.ts +86 -0
  241. package/src/shared/url.ts +140 -0
  242. package/src/shared/validateJson.ts +578 -0
  243. package/src/shared/versionInEtag.ts +14 -0
  244. package/src/shared/writePath.ts +95 -0
  245. package/src/ui/ArmRegion.ts +185 -0
  246. package/src/ui/LAYER_NAMES.ts +30 -0
  247. package/src/ui/List.ts +273 -0
  248. package/src/ui/Mismatch.ts +32 -0
  249. package/src/ui/RawRun.ts +99 -0
  250. package/src/ui/Router.ts +698 -0
  251. package/src/ui/Scope.ts +115 -0
  252. package/src/ui/TryRegion.ts +278 -0
  253. package/src/ui/adoptWalk.ts +126 -0
  254. package/src/ui/applyHead.ts +146 -0
  255. package/src/ui/bindElement.ts +44 -0
  256. package/src/ui/bindProperty.ts +79 -0
  257. package/src/ui/bindSpread.ts +44 -0
  258. package/src/ui/escapeless.ts +14 -0
  259. package/src/ui/index.ts +64 -0
  260. package/src/ui/leave.ts +35 -0
  261. package/src/ui/listenForRoutes.ts +92 -0
  262. package/src/ui/measureLayer.ts +34 -0
  263. package/src/ui/menuBridge.ts +19 -0
  264. package/src/ui/moveNode.ts +34 -0
  265. package/src/ui/parseMarkup.ts +35 -0
  266. package/src/ui/reconcile.ts +368 -0
  267. package/src/ui/regions.ts +137 -0
  268. package/src/ui/reportMenu.ts +57 -0
  269. package/src/ui/routing.ts +18 -0
  270. package/src/ui/rowKeyOf.ts +19 -0
  271. package/src/ui/rows.ts +99 -0
  272. package/src/ui/setAttribute.ts +37 -0
  273. package/src/ui/setClass.ts +27 -0
  274. package/src/ui/setMarkup.ts +20 -0
  275. package/src/ui/setStyleProperty.ts +30 -0
  276. package/src/ui/setText.ts +28 -0
  277. package/src/ui/socketWire.ts +258 -0
  278. package/src/ui/wire.ts +141 -0
  279. package/AGENTS.md +0 -446
  280. package/README.md +0 -249
  281. package/src/abideLsp.ts +0 -251
  282. package/src/abideModules.d.ts +0 -8
  283. package/src/abideResolverPlugin.ts +0 -1101
  284. package/src/appEntry.ts +0 -161
  285. package/src/assets/app.html +0 -12
  286. package/src/build.ts +0 -189
  287. package/src/buildCli.ts +0 -125
  288. package/src/buildDisconnected.ts +0 -117
  289. package/src/bundleApp.ts +0 -146
  290. package/src/bundleDisconnectedEntry.ts +0 -14
  291. package/src/checkAbide.ts +0 -145
  292. package/src/cliEntry.ts +0 -25
  293. package/src/clientBuildPlugins.ts +0 -33
  294. package/src/clientEntry.ts +0 -17
  295. package/src/compile.ts +0 -61
  296. package/src/controlServerWorker.ts +0 -433
  297. package/src/devEntry.ts +0 -381
  298. package/src/discoveryEntry.ts +0 -82
  299. package/src/initAgent.ts +0 -50
  300. package/src/lib/bundle/BundleMenu.ts +0 -12
  301. package/src/lib/bundle/BundleMenuItem.ts +0 -25
  302. package/src/lib/bundle/BundleWindow.ts +0 -37
  303. package/src/lib/bundle/WEBVIEW_BUILD_REVISION.ts +0 -9
  304. package/src/lib/bundle/WEBVIEW_VERSION.ts +0 -7
  305. package/src/lib/bundle/bindConnectedFlag.ts +0 -29
  306. package/src/lib/bundle/bindRequestNavigate.ts +0 -34
  307. package/src/lib/bundle/buildWebviewLib.ts +0 -111
  308. package/src/lib/bundle/bundled.ts +0 -35
  309. package/src/lib/bundle/disconnected.abide +0 -265
  310. package/src/lib/bundle/disconnected.css +0 -9
  311. package/src/lib/bundle/ensureWebviewLib.ts +0 -20
  312. package/src/lib/bundle/exitWithParent.ts +0 -30
  313. package/src/lib/bundle/infoPlist.ts +0 -52
  314. package/src/lib/bundle/installDownloads.ts +0 -34
  315. package/src/lib/bundle/installMacMenu.ts +0 -49
  316. package/src/lib/bundle/listenLocalControlServer.ts +0 -19
  317. package/src/lib/bundle/native/abideMenu.mm +0 -422
  318. package/src/lib/bundle/native/webview.h +0 -4557
  319. package/src/lib/bundle/onMenu.ts +0 -42
  320. package/src/lib/bundle/openWebview.ts +0 -104
  321. package/src/lib/bundle/pngToIcns.ts +0 -47
  322. package/src/lib/bundle/probeAbideServer.ts +0 -57
  323. package/src/lib/bundle/resolveServerBinary.ts +0 -12
  324. package/src/lib/bundle/resolveWebviewLib.ts +0 -53
  325. package/src/lib/bundle/serverBinaryFilename.ts +0 -8
  326. package/src/lib/bundle/signMacApp.ts +0 -37
  327. package/src/lib/bundle/spawnEmbeddedServer.ts +0 -73
  328. package/src/lib/bundle/stableLocalPort.ts +0 -19
  329. package/src/lib/bundle/waitForServer.ts +0 -28
  330. package/src/lib/bundle/webviewCachePath.ts +0 -23
  331. package/src/lib/bundle/webviewLibName.ts +0 -11
  332. package/src/lib/cli/completeCli.ts +0 -38
  333. package/src/lib/cli/connectToServer.ts +0 -23
  334. package/src/lib/cli/createClient.ts +0 -108
  335. package/src/lib/cli/dispatchCommand.ts +0 -72
  336. package/src/lib/cli/loadEnvFromBinaryDir.ts +0 -15
  337. package/src/lib/cli/parseArgvForRpc.ts +0 -131
  338. package/src/lib/cli/printCommandHelp.ts +0 -43
  339. package/src/lib/cli/printSessionHelp.ts +0 -28
  340. package/src/lib/cli/printSessionStatus.ts +0 -21
  341. package/src/lib/cli/printTopLevelHelp.ts +0 -83
  342. package/src/lib/cli/printTrimmed.ts +0 -8
  343. package/src/lib/cli/printValue.ts +0 -10
  344. package/src/lib/cli/renderCliCompletions.ts +0 -56
  345. package/src/lib/cli/resolveCliTarget.ts +0 -47
  346. package/src/lib/cli/runCli.ts +0 -188
  347. package/src/lib/cli/runSession.ts +0 -107
  348. package/src/lib/cli/startLocalInstance.ts +0 -14
  349. package/src/lib/cli/tokenizeArgvFlags.ts +0 -86
  350. package/src/lib/cli/tokenizeLine.ts +0 -51
  351. package/src/lib/cli/types/CliManifest.ts +0 -11
  352. package/src/lib/cli/types/CliManifestEntry.ts +0 -17
  353. package/src/lib/cli/types/CliTarget.ts +0 -13
  354. package/src/lib/mcp/annotationsForMethod.ts +0 -29
  355. package/src/lib/mcp/buildPrompts.ts +0 -25
  356. package/src/lib/mcp/createMcpResourceServer.ts +0 -113
  357. package/src/lib/mcp/createMcpServer.ts +0 -56
  358. package/src/lib/mcp/dispatchMcpRequest.ts +0 -159
  359. package/src/lib/mcp/mcpResourceServerSlot.ts +0 -13
  360. package/src/lib/mcp/mcpSurface.ts +0 -57
  361. package/src/lib/mcp/mcpTools.ts +0 -196
  362. package/src/lib/mcp/renderPrompt.ts +0 -25
  363. package/src/lib/mcp/toolResultFromResponse.ts +0 -100
  364. package/src/lib/mcp/types/JsonRpcRequest.ts +0 -12
  365. package/src/lib/mcp/types/JsonRpcResponse.ts +0 -20
  366. package/src/lib/mcp/types/McpResourceContents.ts +0 -10
  367. package/src/lib/mcp/types/McpResourceDescriptor.ts +0 -6
  368. package/src/lib/mcp/types/McpResourceServer.ts +0 -12
  369. package/src/lib/mcp/types/McpServer.ts +0 -9
  370. package/src/lib/mcp/types/McpServerOptions.ts +0 -16
  371. package/src/lib/mcp/types/McpSurface.ts +0 -15
  372. package/src/lib/mcp/types/PromptDescriptor.ts +0 -5
  373. package/src/lib/mcp/types/PromptMessage.ts +0 -2
  374. package/src/lib/mcp/types/ToolDescriptor.ts +0 -7
  375. package/src/lib/mcp/types/ToolResult.ts +0 -2
  376. package/src/lib/server/AppModule.ts +0 -47
  377. package/src/lib/server/DELETE.ts +0 -10
  378. package/src/lib/server/GET.ts +0 -10
  379. package/src/lib/server/HEAD.ts +0 -10
  380. package/src/lib/server/PATCH.ts +0 -10
  381. package/src/lib/server/POST.ts +0 -10
  382. package/src/lib/server/PUT.ts +0 -10
  383. package/src/lib/server/agent.ts +0 -86
  384. package/src/lib/server/appDataDir.ts +0 -16
  385. package/src/lib/server/cli/buildEnvContent.ts +0 -19
  386. package/src/lib/server/cli/createTarGz.ts +0 -77
  387. package/src/lib/server/cli/handleCliDownload.ts +0 -152
  388. package/src/lib/server/cli/handleCliInstall.ts +0 -37
  389. package/src/lib/server/cli/installScript.ts +0 -31
  390. package/src/lib/server/cli/maxSourceMtime.ts +0 -26
  391. package/src/lib/server/cookies.ts +0 -30
  392. package/src/lib/server/env.ts +0 -51
  393. package/src/lib/server/error.ts +0 -110
  394. package/src/lib/server/json.ts +0 -57
  395. package/src/lib/server/jsonl.ts +0 -47
  396. package/src/lib/server/prompts/definePrompt.ts +0 -21
  397. package/src/lib/server/prompts/promptRegistry.ts +0 -9
  398. package/src/lib/server/prompts/registerPrompt.ts +0 -6
  399. package/src/lib/server/prompts/renderPromptTemplate.ts +0 -17
  400. package/src/lib/server/prompts/types/Prompt.ts +0 -14
  401. package/src/lib/server/prompts/types/PromptOptions.ts +0 -12
  402. package/src/lib/server/prompts/types/PromptRegistryEntry.ts +0 -13
  403. package/src/lib/server/prompts/types/PromptRoutes.ts +0 -10
  404. package/src/lib/server/redirect.ts +0 -43
  405. package/src/lib/server/render.ts +0 -70
  406. package/src/lib/server/request.ts +0 -19
  407. package/src/lib/server/rpc/defineRpc.ts +0 -271
  408. package/src/lib/server/rpc/dispatchRpcInProcess.ts +0 -46
  409. package/src/lib/server/rpc/findRpcByCommandName.ts +0 -18
  410. package/src/lib/server/rpc/parseArgs.ts +0 -244
  411. package/src/lib/server/rpc/readBodyWithinLimit.ts +0 -47
  412. package/src/lib/server/rpc/registerRpc.ts +0 -6
  413. package/src/lib/server/rpc/resolveRpcJsonSchema.ts +0 -28
  414. package/src/lib/server/rpc/rpcRegistry.ts +0 -11
  415. package/src/lib/server/rpc/runWithRpcTimeout.ts +0 -58
  416. package/src/lib/server/rpc/types/RemoteHandler.ts +0 -31
  417. package/src/lib/server/rpc/types/RemoteRoutes.ts +0 -13
  418. package/src/lib/server/rpc/types/RpcHelper.ts +0 -185
  419. package/src/lib/server/rpc/types/RpcRegistryEntry.ts +0 -50
  420. package/src/lib/server/rpc/types/TypedError.ts +0 -18
  421. package/src/lib/server/rpc/types/TypedResponse.ts +0 -18
  422. package/src/lib/server/rpc/unprocessed.ts +0 -13
  423. package/src/lib/server/rpc/validationError.ts +0 -17
  424. package/src/lib/server/runtime/DEFAULT_PORT.ts +0 -6
  425. package/src/lib/server/runtime/DEV_READY_MESSAGE.ts +0 -6
  426. package/src/lib/server/runtime/DEV_REBUILD_MESSAGE.ts +0 -4
  427. package/src/lib/server/runtime/DEV_RELOAD_CLIENT_SCRIPT.ts +0 -92
  428. package/src/lib/server/runtime/SSR_SWAP_SCRIPT.ts +0 -19
  429. package/src/lib/server/runtime/STATUS_TEXT.ts +0 -22
  430. package/src/lib/server/runtime/STREAMED_HTML_HEADER.ts +0 -13
  431. package/src/lib/server/runtime/acceptsGzip.ts +0 -33
  432. package/src/lib/server/runtime/amendBroadcaster.ts +0 -53
  433. package/src/lib/server/runtime/buildCacheSnapshot.ts +0 -63
  434. package/src/lib/server/runtime/buildHealthPayload.ts +0 -34
  435. package/src/lib/server/runtime/buildInFlightSnapshot.ts +0 -35
  436. package/src/lib/server/runtime/buildInspectorSurface.ts +0 -47
  437. package/src/lib/server/runtime/buildOpenApiSpec.ts +0 -150
  438. package/src/lib/server/runtime/buildPreloadManifest.ts +0 -153
  439. package/src/lib/server/runtime/cacheControlForAsset.ts +0 -22
  440. package/src/lib/server/runtime/cacheStalenessBroadcaster.ts +0 -33
  441. package/src/lib/server/runtime/containsTraversal.ts +0 -41
  442. package/src/lib/server/runtime/createAppAssetServer.ts +0 -100
  443. package/src/lib/server/runtime/createAppRouteResolver.ts +0 -145
  444. package/src/lib/server/runtime/createAssetHeaderCache.ts +0 -31
  445. package/src/lib/server/runtime/createPlumbingRouter.ts +0 -212
  446. package/src/lib/server/runtime/createPublicAssetServer.ts +0 -76
  447. package/src/lib/server/runtime/createRouteDispatcher.ts +0 -121
  448. package/src/lib/server/runtime/createServer.ts +0 -605
  449. package/src/lib/server/runtime/createUiPageRenderer.ts +0 -489
  450. package/src/lib/server/runtime/crossOriginForbidden.ts +0 -17
  451. package/src/lib/server/runtime/crossOriginGate.ts +0 -29
  452. package/src/lib/server/runtime/devClientFingerprint.ts +0 -103
  453. package/src/lib/server/runtime/devReloadResponse.ts +0 -41
  454. package/src/lib/server/runtime/disableIdleTimeoutForStream.ts +0 -27
  455. package/src/lib/server/runtime/envSchemaStore.ts +0 -15
  456. package/src/lib/server/runtime/finalizeResponse.ts +0 -42
  457. package/src/lib/server/runtime/findOpenPort.ts +0 -21
  458. package/src/lib/server/runtime/flushingGzipStream.ts +0 -62
  459. package/src/lib/server/runtime/getActiveServer.ts +0 -6
  460. package/src/lib/server/runtime/globToPathSet.ts +0 -29
  461. package/src/lib/server/runtime/gzipResponse.ts +0 -57
  462. package/src/lib/server/runtime/inFlightRequests.ts +0 -13
  463. package/src/lib/server/runtime/inProcessServer.ts +0 -20
  464. package/src/lib/server/runtime/installAmbientScopeStore.ts +0 -54
  465. package/src/lib/server/runtime/internalErrorResponse.ts +0 -28
  466. package/src/lib/server/runtime/isCrossOriginRequest.ts +0 -23
  467. package/src/lib/server/runtime/listenOnOpenPort.ts +0 -36
  468. package/src/lib/server/runtime/logExposedSurfaces.ts +0 -156
  469. package/src/lib/server/runtime/maybeMountInspector.ts +0 -104
  470. package/src/lib/server/runtime/mimeForExtension.ts +0 -14
  471. package/src/lib/server/runtime/pageRenderSlot.ts +0 -15
  472. package/src/lib/server/runtime/pageUrlFromStore.ts +0 -15
  473. package/src/lib/server/runtime/parseIdleTimeout.ts +0 -10
  474. package/src/lib/server/runtime/parsePort.ts +0 -11
  475. package/src/lib/server/runtime/pathStore.ts +0 -15
  476. package/src/lib/server/runtime/registryManifests.ts +0 -66
  477. package/src/lib/server/runtime/renderCellBarrierStore.ts +0 -15
  478. package/src/lib/server/runtime/requestContext.ts +0 -5
  479. package/src/lib/server/runtime/resolvePageSnapshot.ts +0 -25
  480. package/src/lib/server/runtime/respondWithEmbeddedAsset.ts +0 -18
  481. package/src/lib/server/runtime/runWithRequestScope.ts +0 -165
  482. package/src/lib/server/runtime/serializeCacheSnapshot.ts +0 -31
  483. package/src/lib/server/runtime/serverSlot.ts +0 -13
  484. package/src/lib/server/runtime/setActiveServer.ts +0 -6
  485. package/src/lib/server/runtime/snapshotEntryFromCache.ts +0 -121
  486. package/src/lib/server/runtime/streamCacheResolutions.ts +0 -44
  487. package/src/lib/server/runtime/streamFromIterator.ts +0 -124
  488. package/src/lib/server/runtime/textResponse.ts +0 -23
  489. package/src/lib/server/runtime/typedErrorResponse.ts +0 -26
  490. package/src/lib/server/runtime/types/Assets.ts +0 -6
  491. package/src/lib/server/runtime/types/DevReloadStamp.ts +0 -14
  492. package/src/lib/server/runtime/types/InspectorCacheEntry.ts +0 -24
  493. package/src/lib/server/runtime/types/InspectorCacheSnapshot.ts +0 -11
  494. package/src/lib/server/runtime/types/InspectorContext.ts +0 -34
  495. package/src/lib/server/runtime/types/InspectorInFlightRequest.ts +0 -20
  496. package/src/lib/server/runtime/types/InspectorInFlightSnapshot.ts +0 -10
  497. package/src/lib/server/runtime/types/InspectorPrompt.ts +0 -15
  498. package/src/lib/server/runtime/types/InspectorRpc.ts +0 -27
  499. package/src/lib/server/runtime/types/InspectorSocket.ts +0 -17
  500. package/src/lib/server/runtime/types/InspectorSurface.ts +0 -16
  501. package/src/lib/server/runtime/types/RequestStore.ts +0 -125
  502. package/src/lib/server/runtime/warnUnguardedMcp.ts +0 -43
  503. package/src/lib/server/runtime/withResponseDefaults.ts +0 -29
  504. package/src/lib/server/server.ts +0 -33
  505. package/src/lib/server/socket.ts +0 -32
  506. package/src/lib/server/sockets/amendFamilyEntry.ts +0 -39
  507. package/src/lib/server/sockets/createSocketDispatcher.ts +0 -397
  508. package/src/lib/server/sockets/defineSocket.ts +0 -225
  509. package/src/lib/server/sockets/lookupSocket.ts +0 -6
  510. package/src/lib/server/sockets/registerSocket.ts +0 -18
  511. package/src/lib/server/sockets/socketOperations.ts +0 -36
  512. package/src/lib/server/sockets/socketRegistry.ts +0 -9
  513. package/src/lib/server/sockets/types/SocketOperation.ts +0 -22
  514. package/src/lib/server/sockets/types/SocketOptions.ts +0 -26
  515. package/src/lib/server/sockets/types/SocketRegistryEntry.ts +0 -19
  516. package/src/lib/server/sockets/types/SocketRoutes.ts +0 -10
  517. package/src/lib/server/sse.ts +0 -58
  518. package/src/lib/shared/ABIDE_PACKAGE_NAME.ts +0 -7
  519. package/src/lib/shared/ABIDE_VERSION.ts +0 -9
  520. package/src/lib/shared/AMEND_TOPIC_PREFIX.ts +0 -9
  521. package/src/lib/shared/ASYNC_CELL.ts +0 -5
  522. package/src/lib/shared/CACHE_CONTROL_VALUES.ts +0 -16
  523. package/src/lib/shared/CACHE_STALENESS_SOCKET.ts +0 -8
  524. package/src/lib/shared/CLI_PATH.ts +0 -7
  525. package/src/lib/shared/DEFER.ts +0 -8
  526. package/src/lib/shared/DEV_REBUILD_PATH.ts +0 -6
  527. package/src/lib/shared/DEV_RELOAD_PATH.ts +0 -6
  528. package/src/lib/shared/HEALTH_PATH.ts +0 -7
  529. package/src/lib/shared/HTTP_METHODS.ts +0 -6
  530. package/src/lib/shared/HttpError.ts +0 -30
  531. package/src/lib/shared/IDENTITY_PATH.ts +0 -6
  532. package/src/lib/shared/INSPECTOR_PATH.ts +0 -7
  533. package/src/lib/shared/MCP_PATH.ts +0 -6
  534. package/src/lib/shared/NAV_HEADER.ts +0 -8
  535. package/src/lib/shared/OFFLINE_HEADER.ts +0 -8
  536. package/src/lib/shared/PROXIED_SERVER_SUBDIRS.ts +0 -15
  537. package/src/lib/shared/REF_JSON_HEADER.ts +0 -9
  538. package/src/lib/shared/REF_JSON_TAGS.ts +0 -43
  539. package/src/lib/shared/REMOTE_FUNCTION.ts +0 -8
  540. package/src/lib/shared/REPLAYABLE_METHODS.ts +0 -12
  541. package/src/lib/shared/RESERVED_SOCKET_PREFIX.ts +0 -8
  542. package/src/lib/shared/RPC_ARGS_TYPE.ts +0 -7
  543. package/src/lib/shared/RPC_SHIM_GLOBALS.ts +0 -9
  544. package/src/lib/shared/SEEDS.ts +0 -33
  545. package/src/lib/shared/SOCKETS_PATH.ts +0 -7
  546. package/src/lib/shared/SOCKET_SEED.ts +0 -12
  547. package/src/lib/shared/SSR_SCRIPT_ID.ts +0 -11
  548. package/src/lib/shared/STREAMING_CONTENT_TYPES.ts +0 -12
  549. package/src/lib/shared/SocketDisconnectedError.ts +0 -13
  550. package/src/lib/shared/TEXT_PLAIN.ts +0 -7
  551. package/src/lib/shared/abideImportName.ts +0 -44
  552. package/src/lib/shared/abideLog.ts +0 -38
  553. package/src/lib/shared/activeCacheStore.ts +0 -12
  554. package/src/lib/shared/activePage.ts +0 -12
  555. package/src/lib/shared/amend.ts +0 -48
  556. package/src/lib/shared/amendBroadcastSlot.ts +0 -19
  557. package/src/lib/shared/appDataDir.ts +0 -34
  558. package/src/lib/shared/appNameSlot.ts +0 -10
  559. package/src/lib/shared/applyAmendLocally.ts +0 -20
  560. package/src/lib/shared/applyCacheStalenessLocally.ts +0 -18
  561. package/src/lib/shared/assertExhaustive.ts +0 -14
  562. package/src/lib/shared/attachRpcSelectorMethods.ts +0 -44
  563. package/src/lib/shared/attachSocketSelectorMethods.ts +0 -34
  564. package/src/lib/shared/augmentModule.ts +0 -18
  565. package/src/lib/shared/basePath.ts +0 -11
  566. package/src/lib/shared/basePathFromAppUrl.ts +0 -20
  567. package/src/lib/shared/baseSlot.ts +0 -9
  568. package/src/lib/shared/binaryDirEnvPath.ts +0 -12
  569. package/src/lib/shared/bodyValueForKind.ts +0 -34
  570. package/src/lib/shared/browserClientFlags.ts +0 -10
  571. package/src/lib/shared/buildArtifact.ts +0 -20
  572. package/src/lib/shared/buildRpcProxy.ts +0 -39
  573. package/src/lib/shared/buildRpcRequest.ts +0 -81
  574. package/src/lib/shared/buildSocketOverChannel.ts +0 -102
  575. package/src/lib/shared/bundleGraphFromMetafile.ts +0 -68
  576. package/src/lib/shared/bundleLayout.ts +0 -36
  577. package/src/lib/shared/cache.ts +0 -1584
  578. package/src/lib/shared/cacheEntryFromSnapshot.ts +0 -77
  579. package/src/lib/shared/cacheManagedSlot.ts +0 -10
  580. package/src/lib/shared/cacheReaderSocketSlot.ts +0 -11
  581. package/src/lib/shared/cacheStalenessSlot.ts +0 -21
  582. package/src/lib/shared/cacheStoreSlot.ts +0 -12
  583. package/src/lib/shared/cacheStores.ts +0 -10
  584. package/src/lib/shared/canonicalJson.ts +0 -86
  585. package/src/lib/shared/carriesBodyArgs.ts +0 -13
  586. package/src/lib/shared/changeAffectsClient.ts +0 -40
  587. package/src/lib/shared/clearLastConnection.ts +0 -7
  588. package/src/lib/shared/commandNameForUrl.ts +0 -17
  589. package/src/lib/shared/contentBodyKind.ts +0 -27
  590. package/src/lib/shared/contentTypeOf.ts +0 -6
  591. package/src/lib/shared/createCacheStore.ts +0 -147
  592. package/src/lib/shared/createChannelLog.ts +0 -146
  593. package/src/lib/shared/createLifecycleChannel.ts +0 -62
  594. package/src/lib/shared/createLivenessWatch.ts +0 -118
  595. package/src/lib/shared/createPushIterator.ts +0 -132
  596. package/src/lib/shared/createReachable.ts +0 -78
  597. package/src/lib/shared/createRemoteFunction.ts +0 -210
  598. package/src/lib/shared/createResolverSlot.ts +0 -30
  599. package/src/lib/shared/createRpcServerProgram.ts +0 -1007
  600. package/src/lib/shared/createSocketSubRegistry.ts +0 -112
  601. package/src/lib/shared/createSubscriber.ts +0 -55
  602. package/src/lib/shared/createTraceContext.ts +0 -21
  603. package/src/lib/shared/dataDirEnvPath.ts +0 -12
  604. package/src/lib/shared/debugGate.ts +0 -90
  605. package/src/lib/shared/decodeRefJson.ts +0 -112
  606. package/src/lib/shared/decodeResponse.ts +0 -54
  607. package/src/lib/shared/decodeWireBody.ts +0 -35
  608. package/src/lib/shared/detectRpcMethod.ts +0 -24
  609. package/src/lib/shared/detectTarget.ts +0 -27
  610. package/src/lib/shared/docSnapshotsSlot.ts +0 -13
  611. package/src/lib/shared/done.ts +0 -20
  612. package/src/lib/shared/emitLogRecord.ts +0 -217
  613. package/src/lib/shared/encodeRefJson.ts +0 -108
  614. package/src/lib/shared/encodeSeedValue.ts +0 -24
  615. package/src/lib/shared/encodeWireBody.ts +0 -18
  616. package/src/lib/shared/escapeHtml.ts +0 -15
  617. package/src/lib/shared/escapeRegex.ts +0 -9
  618. package/src/lib/shared/exeSuffix.ts +0 -9
  619. package/src/lib/shared/exitOnBuildFailure.ts +0 -18
  620. package/src/lib/shared/extraForwardHeaders.ts +0 -16
  621. package/src/lib/shared/fieldErrorsFromIssues.ts +0 -27
  622. package/src/lib/shared/fileName.ts +0 -9
  623. package/src/lib/shared/fileStem.ts +0 -11
  624. package/src/lib/shared/findExportCallSite.ts +0 -233
  625. package/src/lib/shared/formatTraceparent.ts +0 -6
  626. package/src/lib/shared/forwardHeaders.ts +0 -44
  627. package/src/lib/shared/generateDeclarations.ts +0 -72
  628. package/src/lib/shared/getRemoteMeta.ts +0 -5
  629. package/src/lib/shared/hasSeedableRequest.ts +0 -25
  630. package/src/lib/shared/health.ts +0 -179
  631. package/src/lib/shared/healthReadSlot.ts +0 -11
  632. package/src/lib/shared/healthSeedSlot.ts +0 -12
  633. package/src/lib/shared/html.ts +0 -19
  634. package/src/lib/shared/httpErrorFor.ts +0 -26
  635. package/src/lib/shared/hydrationWindow.ts +0 -53
  636. package/src/lib/shared/importNamesToStrip.ts +0 -13
  637. package/src/lib/shared/invalidate.ts +0 -39
  638. package/src/lib/shared/invalidateEvent.ts +0 -11
  639. package/src/lib/shared/invalidateTripwire.ts +0 -40
  640. package/src/lib/shared/isAbideHealthPayload.ts +0 -11
  641. package/src/lib/shared/isAsciiWhitespace.ts +0 -5
  642. package/src/lib/shared/isAsyncCell.ts +0 -11
  643. package/src/lib/shared/isAsyncIterable.ts +0 -8
  644. package/src/lib/shared/isCompileTarget.ts +0 -21
  645. package/src/lib/shared/isDebugEnabled.ts +0 -19
  646. package/src/lib/shared/isDebugNegated.ts +0 -17
  647. package/src/lib/shared/isIdentPart.ts +0 -9
  648. package/src/lib/shared/isIdentStart.ts +0 -8
  649. package/src/lib/shared/isLayoutFile.ts +0 -12
  650. package/src/lib/shared/isModuleNotFound.ts +0 -18
  651. package/src/lib/shared/isReadOnlyMethod.ts +0 -14
  652. package/src/lib/shared/isReplayableMethod.ts +0 -7
  653. package/src/lib/shared/isStreamingResponse.ts +0 -12
  654. package/src/lib/shared/isSubscribable.ts +0 -15
  655. package/src/lib/shared/isThenable.ts +0 -9
  656. package/src/lib/shared/jsonSchemaForPromptArguments.ts +0 -29
  657. package/src/lib/shared/jsonSchemaForSchema.ts +0 -39
  658. package/src/lib/shared/jsonSchemaForType.ts +0 -245
  659. package/src/lib/shared/jsonlErrorFrame.ts +0 -24
  660. package/src/lib/shared/keyForRemoteCall.ts +0 -30
  661. package/src/lib/shared/keyMatchesPrefix.ts +0 -9
  662. package/src/lib/shared/keyPrefixForRemote.ts +0 -12
  663. package/src/lib/shared/lastConnectionPath.ts +0 -7
  664. package/src/lib/shared/layoutChainForRoute.ts +0 -22
  665. package/src/lib/shared/lenientDecode.ts +0 -15
  666. package/src/lib/shared/loadEnvFile.ts +0 -17
  667. package/src/lib/shared/loadEnvFromDataDir.ts +0 -14
  668. package/src/lib/shared/loadProjectTsConfig.ts +0 -28
  669. package/src/lib/shared/log.ts +0 -24
  670. package/src/lib/shared/logClosingRecord.ts +0 -28
  671. package/src/lib/shared/logTapSlot.ts +0 -13
  672. package/src/lib/shared/manifestModule.ts +0 -39
  673. package/src/lib/shared/markFrameworkSourcesIgnored.ts +0 -47
  674. package/src/lib/shared/matchRoute.ts +0 -165
  675. package/src/lib/shared/matcherFromEnvelope.ts +0 -31
  676. package/src/lib/shared/memoizeByKey.ts +0 -32
  677. package/src/lib/shared/messageFromError.ts +0 -6
  678. package/src/lib/shared/normalizePathname.ts +0 -11
  679. package/src/lib/shared/normalizeTarget.ts +0 -10
  680. package/src/lib/shared/online.ts +0 -51
  681. package/src/lib/shared/page.ts +0 -30
  682. package/src/lib/shared/pageSlot.ts +0 -17
  683. package/src/lib/shared/pageUrlForFile.ts +0 -14
  684. package/src/lib/shared/parseBoundedEnvInt.ts +0 -20
  685. package/src/lib/shared/parseEnv.ts +0 -41
  686. package/src/lib/shared/parsePromptMarkdown.ts +0 -35
  687. package/src/lib/shared/parseRouteSegments.ts +0 -31
  688. package/src/lib/shared/parseTraceparent.ts +0 -26
  689. package/src/lib/shared/peek.ts +0 -46
  690. package/src/lib/shared/pending.ts +0 -36
  691. package/src/lib/shared/pendingAsyncCellsSlot.ts +0 -13
  692. package/src/lib/shared/prepareRemoteExport.ts +0 -40
  693. package/src/lib/shared/prepareRpcModule.ts +0 -240
  694. package/src/lib/shared/prepareSocketModule.ts +0 -46
  695. package/src/lib/shared/probeRegistries.ts +0 -68
  696. package/src/lib/shared/producerKey.ts +0 -32
  697. package/src/lib/shared/programNameForPackage.ts +0 -16
  698. package/src/lib/shared/promptNameForFile.ts +0 -10
  699. package/src/lib/shared/queryStringFromArgs.ts +0 -38
  700. package/src/lib/shared/randomHexId.ts +0 -14
  701. package/src/lib/shared/reachable.ts +0 -99
  702. package/src/lib/shared/readEnvFile.ts +0 -15
  703. package/src/lib/shared/readLastConnection.ts +0 -18
  704. package/src/lib/shared/readPackageJson.ts +0 -9
  705. package/src/lib/shared/recordRemoteMeta.ts +0 -5
  706. package/src/lib/shared/refresh.ts +0 -39
  707. package/src/lib/shared/refreshing.ts +0 -37
  708. package/src/lib/shared/remoteMetaStore.ts +0 -16
  709. package/src/lib/shared/requestScopeSlot.ts +0 -13
  710. package/src/lib/shared/resolveClientFlags.ts +0 -20
  711. package/src/lib/shared/resolvedCellsSlot.ts +0 -13
  712. package/src/lib/shared/responseBodyKind.ts +0 -35
  713. package/src/lib/shared/responseErrorText.ts +0 -9
  714. package/src/lib/shared/reviveWireField.ts +0 -49
  715. package/src/lib/shared/reviveWireOutput.ts +0 -36
  716. package/src/lib/shared/routeParamsShape.ts +0 -20
  717. package/src/lib/shared/rpcErrorRegistry.ts +0 -69
  718. package/src/lib/shared/rpcServerForRoot.ts +0 -25
  719. package/src/lib/shared/rpcTimeoutSlot.ts +0 -9
  720. package/src/lib/shared/rpcUrlForFile.ts +0 -19
  721. package/src/lib/shared/runningAsStandaloneBinary.ts +0 -13
  722. package/src/lib/shared/safeJsonForScript.ts +0 -17
  723. package/src/lib/shared/scanPages.ts +0 -25
  724. package/src/lib/shared/selectorMatcher.ts +0 -55
  725. package/src/lib/shared/selectorPrefix.ts +0 -32
  726. package/src/lib/shared/serializeEnv.ts +0 -30
  727. package/src/lib/shared/serializeSelector.ts +0 -69
  728. package/src/lib/shared/setAppName.ts +0 -5
  729. package/src/lib/shared/setOwnProperty.ts +0 -19
  730. package/src/lib/shared/setsIntersect.ts +0 -15
  731. package/src/lib/shared/sharedCacheStore.ts +0 -14
  732. package/src/lib/shared/sharedCacheStoreSlot.ts +0 -10
  733. package/src/lib/shared/skipNonCode.ts +0 -230
  734. package/src/lib/shared/snapshotShippable.ts +0 -23
  735. package/src/lib/shared/snippet.ts +0 -30
  736. package/src/lib/shared/socketNameForFile.ts +0 -11
  737. package/src/lib/shared/socketTailsSlot.ts +0 -13
  738. package/src/lib/shared/socketTapSlot.ts +0 -12
  739. package/src/lib/shared/sseErrorFrame.ts +0 -29
  740. package/src/lib/shared/streamResponse.ts +0 -180
  741. package/src/lib/shared/streamedCellsSlot.ts +0 -14
  742. package/src/lib/shared/stripImport.ts +0 -29
  743. package/src/lib/shared/subscribableFromResponse.ts +0 -51
  744. package/src/lib/shared/subscribableProbes.ts +0 -111
  745. package/src/lib/shared/tailProbeSlot.ts +0 -23
  746. package/src/lib/shared/toTagSet.ts +0 -4
  747. package/src/lib/shared/trace.ts +0 -16
  748. package/src/lib/shared/types/AmendApply.ts +0 -15
  749. package/src/lib/shared/types/AsyncComputed.ts +0 -20
  750. package/src/lib/shared/types/AsyncState.ts +0 -13
  751. package/src/lib/shared/types/CacheEntry.ts +0 -100
  752. package/src/lib/shared/types/CacheInvalidation.ts +0 -9
  753. package/src/lib/shared/types/CacheOnContext.ts +0 -15
  754. package/src/lib/shared/types/CacheOptions.ts +0 -53
  755. package/src/lib/shared/types/CachePolicy.ts +0 -31
  756. package/src/lib/shared/types/CacheReaderHook.ts +0 -11
  757. package/src/lib/shared/types/CacheSelector.ts +0 -17
  758. package/src/lib/shared/types/CacheSnapshotEntry.ts +0 -32
  759. package/src/lib/shared/types/CacheStalenessApply.ts +0 -13
  760. package/src/lib/shared/types/CacheStalenessFrame.ts +0 -24
  761. package/src/lib/shared/types/CacheStats.ts +0 -13
  762. package/src/lib/shared/types/CacheStore.ts +0 -45
  763. package/src/lib/shared/types/ChannelLog.ts +0 -13
  764. package/src/lib/shared/types/ClientFlags.ts +0 -13
  765. package/src/lib/shared/types/CompileTarget.ts +0 -6
  766. package/src/lib/shared/types/DebugGate.ts +0 -10
  767. package/src/lib/shared/types/DocSnapshots.ts +0 -12
  768. package/src/lib/shared/types/ErrorJsonSchemas.ts +0 -8
  769. package/src/lib/shared/types/ErrorSpec.ts +0 -11
  770. package/src/lib/shared/types/FrameworkLog.ts +0 -13
  771. package/src/lib/shared/types/HttpMethod.ts +0 -3
  772. package/src/lib/shared/types/InputCoercion.ts +0 -17
  773. package/src/lib/shared/types/LastConnection.ts +0 -9
  774. package/src/lib/shared/types/Log.ts +0 -13
  775. package/src/lib/shared/types/LogRecord.ts +0 -42
  776. package/src/lib/shared/types/LogVoice.ts +0 -7
  777. package/src/lib/shared/types/NamedAsyncIterable.ts +0 -26
  778. package/src/lib/shared/types/OutputWirePlan.ts +0 -17
  779. package/src/lib/shared/types/PageSnapshot.ts +0 -14
  780. package/src/lib/shared/types/PagesScan.ts +0 -7
  781. package/src/lib/shared/types/PendingAsyncCells.ts +0 -10
  782. package/src/lib/shared/types/PromptArgument.ts +0 -12
  783. package/src/lib/shared/types/RawRemoteFunction.ts +0 -20
  784. package/src/lib/shared/types/RemoteCallable.ts +0 -40
  785. package/src/lib/shared/types/RemoteFunction.ts +0 -116
  786. package/src/lib/shared/types/ReplayableMethod.ts +0 -7
  787. package/src/lib/shared/types/RequestScopeInfo.ts +0 -16
  788. package/src/lib/shared/types/ResolvedCells.ts +0 -11
  789. package/src/lib/shared/types/ResolverSlot.ts +0 -13
  790. package/src/lib/shared/types/ReturnBody.ts +0 -15
  791. package/src/lib/shared/types/RpcBuildStamps.ts +0 -32
  792. package/src/lib/shared/types/RpcError.ts +0 -26
  793. package/src/lib/shared/types/RpcErrorGuard.ts +0 -35
  794. package/src/lib/shared/types/RpcInvoker.ts +0 -6
  795. package/src/lib/shared/types/RpcOptions.ts +0 -22
  796. package/src/lib/shared/types/Socket.ts +0 -54
  797. package/src/lib/shared/types/SocketChannel.ts +0 -17
  798. package/src/lib/shared/types/SocketClientFrame.ts +0 -19
  799. package/src/lib/shared/types/SocketServerFrame.ts +0 -24
  800. package/src/lib/shared/types/SocketSubCallbacks.ts +0 -13
  801. package/src/lib/shared/types/SocketTails.ts +0 -13
  802. package/src/lib/shared/types/SourceMap.ts +0 -14
  803. package/src/lib/shared/types/SsrBootState.ts +0 -27
  804. package/src/lib/shared/types/SsrPayload.ts +0 -36
  805. package/src/lib/shared/types/StandardSchemaV1.ts +0 -56
  806. package/src/lib/shared/types/StreamPolicy.ts +0 -11
  807. package/src/lib/shared/types/StreamedCells.ts +0 -19
  808. package/src/lib/shared/types/StreamedResolution.ts +0 -28
  809. package/src/lib/shared/types/TailHooks.ts +0 -13
  810. package/src/lib/shared/types/TraceContext.ts +0 -17
  811. package/src/lib/shared/types/ValidationErrorData.ts +0 -20
  812. package/src/lib/shared/types/WireKind.ts +0 -11
  813. package/src/lib/shared/url.ts +0 -141
  814. package/src/lib/shared/validationHttpError.ts +0 -33
  815. package/src/lib/shared/warmSeedKey.ts +0 -16
  816. package/src/lib/shared/wireJsonReplacer.ts +0 -30
  817. package/src/lib/shared/withBase.ts +0 -10
  818. package/src/lib/shared/withBaseUrl.ts +0 -17
  819. package/src/lib/shared/withCacheManaged.ts +0 -18
  820. package/src/lib/shared/withJsonSchema.ts +0 -21
  821. package/src/lib/shared/writeDts.ts +0 -19
  822. package/src/lib/shared/writeHealthDts.ts +0 -36
  823. package/src/lib/shared/writeLastConnection.ts +0 -13
  824. package/src/lib/shared/writePublicAssetsDts.ts +0 -27
  825. package/src/lib/shared/writeRoutesDts.ts +0 -41
  826. package/src/lib/shared/writeRpcDts.ts +0 -60
  827. package/src/lib/shared/writeTestRpcDts.ts +0 -45
  828. package/src/lib/shared/writeTestSocketsDts.ts +0 -34
  829. package/src/lib/test/assertAgentFrameConformance.ts +0 -73
  830. package/src/lib/test/createScriptedSurface.ts +0 -45
  831. package/src/lib/test/createTestApp.ts +0 -242
  832. package/src/lib/test/createTestSocketChannel.ts +0 -85
  833. package/src/lib/ui/README.md +0 -86
  834. package/src/lib/ui/activePendingCells.ts +0 -14
  835. package/src/lib/ui/amendReaderHook.ts +0 -125
  836. package/src/lib/ui/compile/ABIDE_SEMANTIC_TOKENS_LEGEND.ts +0 -79
  837. package/src/lib/ui/compile/AbideCompileError.ts +0 -16
  838. package/src/lib/ui/compile/BLOCK_KEYWORDS.ts +0 -21
  839. package/src/lib/ui/compile/SSR_ESCAPE.ts +0 -40
  840. package/src/lib/ui/compile/TS_PRINTER.ts +0 -7
  841. package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +0 -86
  842. package/src/lib/ui/compile/VOID_TAGS.ts +0 -22
  843. package/src/lib/ui/compile/abideUiPlugin.ts +0 -109
  844. package/src/lib/ui/compile/analyzeComponent.ts +0 -222
  845. package/src/lib/ui/compile/asOutlet.ts +0 -30
  846. package/src/lib/ui/compile/assertTranspiles.ts +0 -19
  847. package/src/lib/ui/compile/assetModulesFile.ts +0 -32
  848. package/src/lib/ui/compile/assignmentTargetNames.ts +0 -54
  849. package/src/lib/ui/compile/asyncInterpolationFields.ts +0 -152
  850. package/src/lib/ui/compile/asyncValuePositionError.ts +0 -21
  851. package/src/lib/ui/compile/asyncValuePositionInterpolations.ts +0 -64
  852. package/src/lib/ui/compile/attrLiftPosition.ts +0 -18
  853. package/src/lib/ui/compile/awaitPlan.ts +0 -60
  854. package/src/lib/ui/compile/awaitSubjectExpr.ts +0 -23
  855. package/src/lib/ui/compile/bindListenEvent.ts +0 -18
  856. package/src/lib/ui/compile/cachedShadowProgram.ts +0 -39
  857. package/src/lib/ui/compile/cachedSourceFile.ts +0 -40
  858. package/src/lib/ui/compile/catchBinding.ts +0 -10
  859. package/src/lib/ui/compile/classStyleMergePlan.ts +0 -108
  860. package/src/lib/ui/compile/classifyInterpolationType.ts +0 -46
  861. package/src/lib/ui/compile/collectAbideDiagnostics.ts +0 -166
  862. package/src/lib/ui/compile/compileComponent.ts +0 -46
  863. package/src/lib/ui/compile/compileModule.ts +0 -306
  864. package/src/lib/ui/compile/compileSSR.ts +0 -119
  865. package/src/lib/ui/compile/compileShadow.ts +0 -1326
  866. package/src/lib/ui/compile/componentOrdinals.ts +0 -39
  867. package/src/lib/ui/compile/composeProps.ts +0 -64
  868. package/src/lib/ui/compile/createShadowLanguageService.ts +0 -348
  869. package/src/lib/ui/compile/createShadowProgram.ts +0 -127
  870. package/src/lib/ui/compile/createShadowScope.ts +0 -42
  871. package/src/lib/ui/compile/declaredNames.ts +0 -36
  872. package/src/lib/ui/compile/decodeHtmlEntities.ts +0 -53
  873. package/src/lib/ui/compile/destructureBindingNames.ts +0 -38
  874. package/src/lib/ui/compile/desugarSignals.ts +0 -1113
  875. package/src/lib/ui/compile/eachPlan.ts +0 -61
  876. package/src/lib/ui/compile/elementPlan.ts +0 -55
  877. package/src/lib/ui/compile/encodeSemanticTokens.ts +0 -60
  878. package/src/lib/ui/compile/expressionIsPrefixEvaluable.ts +0 -19
  879. package/src/lib/ui/compile/generateBuild.ts +0 -903
  880. package/src/lib/ui/compile/generateSSR.ts +0 -967
  881. package/src/lib/ui/compile/groupBindParts.ts +0 -28
  882. package/src/lib/ui/compile/hasTopLevelAwait.ts +0 -28
  883. package/src/lib/ui/compile/hoistCells.ts +0 -120
  884. package/src/lib/ui/compile/hoistableAwaits.ts +0 -183
  885. package/src/lib/ui/compile/hoistableChildRenders.ts +0 -112
  886. package/src/lib/ui/compile/identifierReferencePattern.ts +0 -13
  887. package/src/lib/ui/compile/ifPlan.ts +0 -36
  888. package/src/lib/ui/compile/interpolatedTemplateLiteral.ts +0 -27
  889. package/src/lib/ui/compile/interpolationClassifierForRoot.ts +0 -32
  890. package/src/lib/ui/compile/isAnchorPositioned.ts +0 -19
  891. package/src/lib/ui/compile/isControlFlow.ts +0 -20
  892. package/src/lib/ui/compile/isFunctionScopeBoundary.ts +0 -20
  893. package/src/lib/ui/compile/isPlainIdentifier.ts +0 -7
  894. package/src/lib/ui/compile/isSpuriousAsyncReadDiagnostic.ts +0 -215
  895. package/src/lib/ui/compile/isTextLeaf.ts +0 -16
  896. package/src/lib/ui/compile/isWhitespaceText.ts +0 -19
  897. package/src/lib/ui/compile/liftAsyncSubExpressions.ts +0 -166
  898. package/src/lib/ui/compile/liftScriptSeed.ts +0 -47
  899. package/src/lib/ui/compile/loadShadowTsConfig.ts +0 -31
  900. package/src/lib/ui/compile/lowerAsyncInterpolations.ts +0 -92
  901. package/src/lib/ui/compile/lowerCompoundAssignment.ts +0 -49
  902. package/src/lib/ui/compile/lowerContext.ts +0 -167
  903. package/src/lib/ui/compile/lowerDocAccess.ts +0 -302
  904. package/src/lib/ui/compile/lowerScript.ts +0 -190
  905. package/src/lib/ui/compile/lowerUpdateExpression.ts +0 -32
  906. package/src/lib/ui/compile/makeVarNamer.ts +0 -10
  907. package/src/lib/ui/compile/nearestProjectRoot.ts +0 -16
  908. package/src/lib/ui/compile/nodeAtShadowOffset.ts +0 -28
  909. package/src/lib/ui/compile/offsetToLineColumn.ts +0 -16
  910. package/src/lib/ui/compile/offsetToPosition.ts +0 -9
  911. package/src/lib/ui/compile/pagePropsType.ts +0 -23
  912. package/src/lib/ui/compile/parseTemplate.ts +0 -25
  913. package/src/lib/ui/compile/parseTemplateRecovering.ts +0 -1385
  914. package/src/lib/ui/compile/prepareNestedScript.ts +0 -62
  915. package/src/lib/ui/compile/reactiveBinding.ts +0 -47
  916. package/src/lib/ui/compile/referencedIdentifiers.ts +0 -35
  917. package/src/lib/ui/compile/remapShadowDiagnostic.ts +0 -30
  918. package/src/lib/ui/compile/renameSignalRefs.ts +0 -425
  919. package/src/lib/ui/compile/resolveAbideImports.ts +0 -29
  920. package/src/lib/ui/compile/resolveBranches.ts +0 -21
  921. package/src/lib/ui/compile/resolveReactiveExport.ts +0 -92
  922. package/src/lib/ui/compile/scopeAttr.ts +0 -9
  923. package/src/lib/ui/compile/scopeCss.ts +0 -138
  924. package/src/lib/ui/compile/seedTypeClassifierForRoot.ts +0 -60
  925. package/src/lib/ui/compile/shadowInterpolationClassifier.ts +0 -47
  926. package/src/lib/ui/compile/shadowNaming.ts +0 -11
  927. package/src/lib/ui/compile/signalCallee.ts +0 -24
  928. package/src/lib/ui/compile/skeletonContext.ts +0 -133
  929. package/src/lib/ui/compile/skeletonable.ts +0 -68
  930. package/src/lib/ui/compile/snippetPlan.ts +0 -28
  931. package/src/lib/ui/compile/sourceFileOptionsSignature.ts +0 -20
  932. package/src/lib/ui/compile/sourceToShadowOffset.ts +0 -24
  933. package/src/lib/ui/compile/spreadExcludedNames.ts +0 -27
  934. package/src/lib/ui/compile/staticAttr.ts +0 -11
  935. package/src/lib/ui/compile/staticAttrValue.ts +0 -13
  936. package/src/lib/ui/compile/staticTextPart.ts +0 -12
  937. package/src/lib/ui/compile/stripEffects.ts +0 -48
  938. package/src/lib/ui/compile/structuralHeadTokens.ts +0 -107
  939. package/src/lib/ui/compile/switchPlan.ts +0 -28
  940. package/src/lib/ui/compile/templateAnchorAdapter.ts +0 -61
  941. package/src/lib/ui/compile/templateElementAdapter.ts +0 -44
  942. package/src/lib/ui/compile/templateSemanticTokens.ts +0 -21
  943. package/src/lib/ui/compile/templateStartOffset.ts +0 -15
  944. package/src/lib/ui/compile/tryPlan.ts +0 -37
  945. package/src/lib/ui/compile/types/AbideDiagnostic.ts +0 -14
  946. package/src/lib/ui/compile/types/AnalyzedComponent.ts +0 -42
  947. package/src/lib/ui/compile/types/AsyncInterpolationField.ts +0 -19
  948. package/src/lib/ui/compile/types/Binding.ts +0 -24
  949. package/src/lib/ui/compile/types/CompiledShadow.ts +0 -27
  950. package/src/lib/ui/compile/types/ElementPlan.ts +0 -43
  951. package/src/lib/ui/compile/types/InterpolationClassifier.ts +0 -12
  952. package/src/lib/ui/compile/types/InterpolationKind.ts +0 -7
  953. package/src/lib/ui/compile/types/ParseDiagnostic.ts +0 -8
  954. package/src/lib/ui/compile/types/SeedTypeClassifier.ts +0 -15
  955. package/src/lib/ui/compile/types/SemanticToken.ts +0 -11
  956. package/src/lib/ui/compile/types/ShadowKind.ts +0 -9
  957. package/src/lib/ui/compile/types/ShadowScope.ts +0 -19
  958. package/src/lib/ui/compile/types/SkeletonContext.ts +0 -21
  959. package/src/lib/ui/compile/types/TemplateAttr.ts +0 -34
  960. package/src/lib/ui/compile/types/TemplateNode.ts +0 -137
  961. package/src/lib/ui/compile/types/TextPart.ts +0 -8
  962. package/src/lib/ui/compile/types/ValuePositionInterpolation.ts +0 -13
  963. package/src/lib/ui/compile/unwrapParens.ts +0 -10
  964. package/src/lib/ui/compile/walkAnchorOrder.ts +0 -57
  965. package/src/lib/ui/compile/walkElementOrder.ts +0 -60
  966. package/src/lib/ui/compile/withBindings.ts +0 -45
  967. package/src/lib/ui/compile/wrapReactionCellSources.ts +0 -121
  968. package/src/lib/ui/compile/wrapReactiveSeeds.ts +0 -44
  969. package/src/lib/ui/compile/wrapSeed.ts +0 -28
  970. package/src/lib/ui/compile/writtenTemplateNames.ts +0 -84
  971. package/src/lib/ui/computed.ts +0 -75
  972. package/src/lib/ui/createScope.ts +0 -157
  973. package/src/lib/ui/dom/MATHML_NAMESPACE.ts +0 -6
  974. package/src/lib/ui/dom/SVG_NAMESPACE.ts +0 -8
  975. package/src/lib/ui/dom/anchorCursor.ts +0 -25
  976. package/src/lib/ui/dom/anchoredBranch.ts +0 -153
  977. package/src/lib/ui/dom/appendSnippet.ts +0 -75
  978. package/src/lib/ui/dom/appendStatic.ts +0 -26
  979. package/src/lib/ui/dom/appendText.ts +0 -160
  980. package/src/lib/ui/dom/appendTextAt.ts +0 -39
  981. package/src/lib/ui/dom/assertClaimedText.ts +0 -30
  982. package/src/lib/ui/dom/attach.ts +0 -25
  983. package/src/lib/ui/dom/attr.ts +0 -57
  984. package/src/lib/ui/dom/awaitBlock.ts +0 -314
  985. package/src/lib/ui/dom/awaitSubject.ts +0 -118
  986. package/src/lib/ui/dom/bindProp.ts +0 -22
  987. package/src/lib/ui/dom/bindSelectValue.ts +0 -48
  988. package/src/lib/ui/dom/bindableProp.ts +0 -47
  989. package/src/lib/ui/dom/buildDetachedRange.ts +0 -31
  990. package/src/lib/ui/dom/cellPending.ts +0 -24
  991. package/src/lib/ui/dom/claimText.ts +0 -38
  992. package/src/lib/ui/dom/clearBetween.ts +0 -16
  993. package/src/lib/ui/dom/cloneStatic.ts +0 -38
  994. package/src/lib/ui/dom/commentData.ts +0 -14
  995. package/src/lib/ui/dom/depthZeroNodes.ts +0 -34
  996. package/src/lib/ui/dom/discardAndRebuild.ts +0 -23
  997. package/src/lib/ui/dom/discardBoundary.ts +0 -46
  998. package/src/lib/ui/dom/disposeRange.ts +0 -18
  999. package/src/lib/ui/dom/domAnchorAdapter.ts +0 -29
  1000. package/src/lib/ui/dom/domElementAdapter.ts +0 -20
  1001. package/src/lib/ui/dom/each.ts +0 -253
  1002. package/src/lib/ui/dom/eachAsync.ts +0 -188
  1003. package/src/lib/ui/dom/effectiveChildNamespace.ts +0 -13
  1004. package/src/lib/ui/dom/enterNamespace.ts +0 -20
  1005. package/src/lib/ui/dom/fillBefore.ts +0 -42
  1006. package/src/lib/ui/dom/fillBoundary.ts +0 -38
  1007. package/src/lib/ui/dom/fillRange.ts +0 -30
  1008. package/src/lib/ui/dom/foreignWrapperTag.ts +0 -22
  1009. package/src/lib/ui/dom/hydrate.ts +0 -34
  1010. package/src/lib/ui/dom/inheritedNamespace.ts +0 -19
  1011. package/src/lib/ui/dom/isComment.ts +0 -6
  1012. package/src/lib/ui/dom/isElement.ts +0 -6
  1013. package/src/lib/ui/dom/markerDepthDelta.ts +0 -19
  1014. package/src/lib/ui/dom/matchingRangeClose.ts +0 -29
  1015. package/src/lib/ui/dom/mergeProps.ts +0 -32
  1016. package/src/lib/ui/dom/mount.ts +0 -30
  1017. package/src/lib/ui/dom/mountChild.ts +0 -94
  1018. package/src/lib/ui/dom/mountRange.ts +0 -45
  1019. package/src/lib/ui/dom/mountSlot.ts +0 -38
  1020. package/src/lib/ui/dom/mountSwappableRange.ts +0 -122
  1021. package/src/lib/ui/dom/moveRange.ts +0 -19
  1022. package/src/lib/ui/dom/mutateDocContainer.ts +0 -65
  1023. package/src/lib/ui/dom/on.ts +0 -33
  1024. package/src/lib/ui/dom/openMarker.ts +0 -22
  1025. package/src/lib/ui/dom/outlet.ts +0 -63
  1026. package/src/lib/ui/dom/parseRawNodes.ts +0 -17
  1027. package/src/lib/ui/dom/readCall.ts +0 -29
  1028. package/src/lib/ui/dom/readCell.ts +0 -55
  1029. package/src/lib/ui/dom/readTextOrSuspend.ts +0 -21
  1030. package/src/lib/ui/dom/removeRange.ts +0 -18
  1031. package/src/lib/ui/dom/replaceRange.ts +0 -24
  1032. package/src/lib/ui/dom/restProps.ts +0 -32
  1033. package/src/lib/ui/dom/skeleton.ts +0 -153
  1034. package/src/lib/ui/dom/spreadAttrs.ts +0 -95
  1035. package/src/lib/ui/dom/spreadProps.ts +0 -31
  1036. package/src/lib/ui/dom/switchBlock.ts +0 -80
  1037. package/src/lib/ui/dom/templateFor.ts +0 -28
  1038. package/src/lib/ui/dom/tryBlock.ts +0 -263
  1039. package/src/lib/ui/dom/types/EachRow.ts +0 -21
  1040. package/src/lib/ui/dom/types/SkeletonHoles.ts +0 -10
  1041. package/src/lib/ui/dom/types/SwitchCase.ts +0 -11
  1042. package/src/lib/ui/dom/when.ts +0 -58
  1043. package/src/lib/ui/dom/withScope.ts +0 -37
  1044. package/src/lib/ui/dom/withSuspense.ts +0 -22
  1045. package/src/lib/ui/dom/writeCell.ts +0 -22
  1046. package/src/lib/ui/effect.ts +0 -24
  1047. package/src/lib/ui/enterScope.ts +0 -18
  1048. package/src/lib/ui/exitScope.ts +0 -8
  1049. package/src/lib/ui/finalizeStreamedChildren.ts +0 -89
  1050. package/src/lib/ui/flight.ts +0 -56
  1051. package/src/lib/ui/html.ts +0 -39
  1052. package/src/lib/ui/isolateCellBarrier.ts +0 -17
  1053. package/src/lib/ui/linked.ts +0 -125
  1054. package/src/lib/ui/navigate.ts +0 -77
  1055. package/src/lib/ui/probeNavigation.ts +0 -33
  1056. package/src/lib/ui/props.ts +0 -17
  1057. package/src/lib/ui/remoteProxy.ts +0 -256
  1058. package/src/lib/ui/renderChain.ts +0 -113
  1059. package/src/lib/ui/renderToStream.ts +0 -128
  1060. package/src/lib/ui/resumeSeedScript.ts +0 -27
  1061. package/src/lib/ui/router.ts +0 -649
  1062. package/src/lib/ui/runtime/AsyncCellError.ts +0 -21
  1063. package/src/lib/ui/runtime/BRANCH_SEGMENT.ts +0 -24
  1064. package/src/lib/ui/runtime/CELL_SEED.ts +0 -12
  1065. package/src/lib/ui/runtime/CHILD_PRESENT.ts +0 -8
  1066. package/src/lib/ui/runtime/CURRENT_BOUNDARY.ts +0 -11
  1067. package/src/lib/ui/runtime/CURRENT_PATH.ts +0 -29
  1068. package/src/lib/ui/runtime/CURRENT_SCOPE.ts +0 -23
  1069. package/src/lib/ui/runtime/DOC_SEED.ts +0 -10
  1070. package/src/lib/ui/runtime/HOLE_ATTRIBUTE.ts +0 -9
  1071. package/src/lib/ui/runtime/NODE_STATE.ts +0 -22
  1072. package/src/lib/ui/runtime/OUTLET_MARKER.ts +0 -10
  1073. package/src/lib/ui/runtime/OUTLET_TAG.ts +0 -7
  1074. package/src/lib/ui/runtime/OWNER.ts +0 -8
  1075. package/src/lib/ui/runtime/PENDING_OUTLET.ts +0 -8
  1076. package/src/lib/ui/runtime/RANGE_MARKER.ts +0 -16
  1077. package/src/lib/ui/runtime/REACTIVE_CONTEXT.ts +0 -20
  1078. package/src/lib/ui/runtime/RENDER.ts +0 -35
  1079. package/src/lib/ui/runtime/REQUEST_SUPERSEDED.ts +0 -8
  1080. package/src/lib/ui/runtime/RESUME.ts +0 -21
  1081. package/src/lib/ui/runtime/SEED_MARKS.ts +0 -14
  1082. package/src/lib/ui/runtime/STREAMED_CELLS.ts +0 -57
  1083. package/src/lib/ui/runtime/SuspenseSignal.ts +0 -24
  1084. package/src/lib/ui/runtime/abortNode.ts +0 -22
  1085. package/src/lib/ui/runtime/ambientPathBacking.ts +0 -32
  1086. package/src/lib/ui/runtime/ambientScopeBacking.ts +0 -26
  1087. package/src/lib/ui/runtime/applyPatchToTree.ts +0 -54
  1088. package/src/lib/ui/runtime/batch.ts +0 -22
  1089. package/src/lib/ui/runtime/blockId.ts +0 -31
  1090. package/src/lib/ui/runtime/boundaryFor.ts +0 -11
  1091. package/src/lib/ui/runtime/cellBarrierBacking.ts +0 -30
  1092. package/src/lib/ui/runtime/claimChild.ts +0 -8
  1093. package/src/lib/ui/runtime/claimExpected.ts +0 -27
  1094. package/src/lib/ui/runtime/claimMarker.ts +0 -13
  1095. package/src/lib/ui/runtime/claimRun.ts +0 -22
  1096. package/src/lib/ui/runtime/clientPage.ts +0 -116
  1097. package/src/lib/ui/runtime/consumeSeed.ts +0 -38
  1098. package/src/lib/ui/runtime/createAsyncCell.ts +0 -358
  1099. package/src/lib/ui/runtime/createComputedNode.ts +0 -19
  1100. package/src/lib/ui/runtime/createDoc.ts +0 -334
  1101. package/src/lib/ui/runtime/createEffectNode.ts +0 -81
  1102. package/src/lib/ui/runtime/createSignalNode.ts +0 -19
  1103. package/src/lib/ui/runtime/currentAbortSignal.ts +0 -26
  1104. package/src/lib/ui/runtime/detachLink.ts +0 -21
  1105. package/src/lib/ui/runtime/endTracking.ts +0 -24
  1106. package/src/lib/ui/runtime/enterRenderPass.ts +0 -13
  1107. package/src/lib/ui/runtime/escapeKey.ts +0 -19
  1108. package/src/lib/ui/runtime/exitRenderPass.ts +0 -7
  1109. package/src/lib/ui/runtime/flushEffects.ts +0 -91
  1110. package/src/lib/ui/runtime/generationGuard.ts +0 -40
  1111. package/src/lib/ui/runtime/historyEntries.ts +0 -151
  1112. package/src/lib/ui/runtime/inScope.ts +0 -19
  1113. package/src/lib/ui/runtime/isAsyncFunction.ts +0 -14
  1114. package/src/lib/ui/runtime/nextBlockId.ts +0 -12
  1115. package/src/lib/ui/runtime/parkCursor.ts +0 -10
  1116. package/src/lib/ui/runtime/pathSegments.ts +0 -10
  1117. package/src/lib/ui/runtime/reactiveAbortState.ts +0 -15
  1118. package/src/lib/ui/runtime/readNode.ts +0 -38
  1119. package/src/lib/ui/runtime/renderPath.ts +0 -16
  1120. package/src/lib/ui/runtime/reportHydrationDivergence.ts +0 -30
  1121. package/src/lib/ui/runtime/routeBareSeed.ts +0 -28
  1122. package/src/lib/ui/runtime/runHydrationPass.ts +0 -69
  1123. package/src/lib/ui/runtime/runNode.ts +0 -75
  1124. package/src/lib/ui/runtime/runtimePath.ts +0 -9
  1125. package/src/lib/ui/runtime/scope.ts +0 -46
  1126. package/src/lib/ui/runtime/scopeGroup.ts +0 -40
  1127. package/src/lib/ui/runtime/toTeardown.ts +0 -38
  1128. package/src/lib/ui/runtime/track.ts +0 -60
  1129. package/src/lib/ui/runtime/trigger.ts +0 -74
  1130. package/src/lib/ui/runtime/types/AbideHistoryState.ts +0 -9
  1131. package/src/lib/ui/runtime/types/Boundary.ts +0 -9
  1132. package/src/lib/ui/runtime/types/Cell.ts +0 -7
  1133. package/src/lib/ui/runtime/types/Computed.ts +0 -3
  1134. package/src/lib/ui/runtime/types/Doc.ts +0 -24
  1135. package/src/lib/ui/runtime/types/EffectResult.ts +0 -10
  1136. package/src/lib/ui/runtime/types/HydrationCursor.ts +0 -8
  1137. package/src/lib/ui/runtime/types/NavVerdict.ts +0 -9
  1138. package/src/lib/ui/runtime/types/Patch.ts +0 -11
  1139. package/src/lib/ui/runtime/types/PathWalk.ts +0 -10
  1140. package/src/lib/ui/runtime/types/ReactiveLink.ts +0 -21
  1141. package/src/lib/ui/runtime/types/ReactiveNode.ts +0 -33
  1142. package/src/lib/ui/runtime/types/RenderContext.ts +0 -10
  1143. package/src/lib/ui/runtime/types/Route.ts +0 -9
  1144. package/src/lib/ui/runtime/types/RouteLoader.ts +0 -7
  1145. package/src/lib/ui/runtime/types/SsrRender.ts +0 -34
  1146. package/src/lib/ui/runtime/types/State.ts +0 -3
  1147. package/src/lib/ui/runtime/types/Teardown.ts +0 -5
  1148. package/src/lib/ui/runtime/types/UiComponent.ts +0 -24
  1149. package/src/lib/ui/runtime/types/UiProps.ts +0 -12
  1150. package/src/lib/ui/runtime/unescapeKey.ts +0 -12
  1151. package/src/lib/ui/runtime/unlinkDeps.ts +0 -28
  1152. package/src/lib/ui/runtime/untrack.ts +0 -20
  1153. package/src/lib/ui/runtime/updateIfNecessary.ts +0 -40
  1154. package/src/lib/ui/runtime/walkPath.ts +0 -41
  1155. package/src/lib/ui/runtime/withOptionalPath.ts +0 -8
  1156. package/src/lib/ui/runtime/withPath.ts +0 -16
  1157. package/src/lib/ui/runtime/withPathFrom.ts +0 -20
  1158. package/src/lib/ui/runtime/withoutHydration.ts +0 -22
  1159. package/src/lib/ui/runtime/writeNode.ts +0 -16
  1160. package/src/lib/ui/scope.ts +0 -20
  1161. package/src/lib/ui/seedBootState.ts +0 -53
  1162. package/src/lib/ui/seedStreamedResolution.ts +0 -56
  1163. package/src/lib/ui/settleAsyncCells.ts +0 -51
  1164. package/src/lib/ui/socketChannel.ts +0 -156
  1165. package/src/lib/ui/socketProxy.ts +0 -47
  1166. package/src/lib/ui/startClient.ts +0 -156
  1167. package/src/lib/ui/state.ts +0 -77
  1168. package/src/lib/ui/subscribeCacheStaleness.ts +0 -85
  1169. package/src/lib/ui/trackedComputed.ts +0 -68
  1170. package/src/lib/ui/tryEncodeResume.ts +0 -11
  1171. package/src/lib/ui/types/Layouts.ts +0 -9
  1172. package/src/lib/ui/types/Pages.ts +0 -8
  1173. package/src/lib/ui/types/Scope.ts +0 -68
  1174. package/src/lib/ui/watch.ts +0 -150
  1175. package/src/preload.ts +0 -19
  1176. package/src/scaffold.ts +0 -153
  1177. package/src/serverBuildPlugins.ts +0 -25
  1178. package/src/serverEntry.ts +0 -138
  1179. package/src/zodCjsPlugin.ts +0 -51
  1180. package/template/.zed/settings.json +0 -10
  1181. package/template/CLAUDE.md +0 -22
  1182. package/template/bunfig.toml +0 -4
  1183. package/template/package.json +0 -21
  1184. package/template/src/app.ts +0 -28
  1185. package/template/src/bundle/icon.png +0 -0
  1186. package/template/src/cli/banner.txt +0 -3
  1187. package/template/src/cli/footer.txt +0 -1
  1188. package/template/src/server/config.ts +0 -17
  1189. package/template/src/server/rpc/getHello.ts +0 -38
  1190. package/template/src/ui/app.css +0 -21
  1191. package/template/src/ui/app.html +0 -24
  1192. package/template/src/ui/pages/about/page.abide +0 -7
  1193. package/template/src/ui/pages/layout.abide +0 -19
  1194. package/template/src/ui/pages/page.abide +0 -19
  1195. package/template/test/app.test.ts +0 -30
  1196. package/template/tsconfig.json +0 -18
  1197. package/tsconfig.app.json +0 -17
@@ -0,0 +1,1343 @@
1
+ import {
2
+ RAW_CLOSE,
3
+ RAW_OPEN,
4
+ REGION_CLOSE,
5
+ REGION_OPEN,
6
+ ROW_OPEN,
7
+ } from '#shared/ANCHORS.ts'
8
+ import { anchorMarkup } from '#shared/anchorMarkup.ts'
9
+ import { CHILDREN } from '#shared/CHILDREN.ts'
10
+ import { type CheckerAnswer, UNCHECKED } from './CheckerAnswer.ts'
11
+ import {
12
+ Cursor,
13
+ type PlacedNode,
14
+ placeTemplate,
15
+ REGION_ROOT,
16
+ ROW_ROOT,
17
+ } from './Cursor.ts'
18
+ import {
19
+ type ClassifiedAttribute,
20
+ classifyAttributes,
21
+ isBound,
22
+ isSingleRooted,
23
+ isSlot,
24
+ } from './classifyTemplate.ts'
25
+ import { decodeCharacterReferences } from './decodeCharacterReferences.ts'
26
+ import { moduleImports } from './emitComponent.ts'
27
+ import { invocationProps, passedName } from './invocationProps.ts'
28
+ import { isNamedAlone } from './isNamedAlone.ts'
29
+ import { Lowering, PROPS } from './Lowering.ts'
30
+ import type { AbideFile } from './parseAbide.ts'
31
+ import {
32
+ CLIENT_LANE,
33
+ chosenArm,
34
+ headSink,
35
+ mergedValue,
36
+ renderMarkup,
37
+ rowMarkup,
38
+ unlandable,
39
+ type ValueRender,
40
+ } from './renderMarkup.ts'
41
+ import { SHARED_NAMES } from './SHARED_NAMES.ts'
42
+ import { RUNTIME_SPECIFIER, SHARED_SPECIFIER } from './SPECIFIERS.ts'
43
+ import {
44
+ insideShare,
45
+ resumedShare,
46
+ SETTLED_AT,
47
+ shareScope,
48
+ } from './shareScope.ts'
49
+ import { splitImports } from './splitImports.ts'
50
+ import type {
51
+ Attribute,
52
+ ElementNode,
53
+ ForBlock,
54
+ InlineComponent,
55
+ Setup,
56
+ TemplateNode,
57
+ } from './TemplateNode.ts'
58
+
59
+ // The client half of one `.abide`. WHERE A NODE STANDS IS DECIDED ONCE, by `placeTemplate`, and the
60
+ // server's markup is rendered from the same positions this module walks, builds and fills from. So
61
+ // the position the server wrote to and the position this module walks to are one answer, rather
62
+ // than two walks held in agreement by the predicates they share.
63
+ //
64
+ // NOTHING IS ADDED TO THE DOCUMENT to make this work. Each node is found from the one before it or
65
+ // the one it stands in, which is exact for a region whose shape is static — and a compiled
66
+ // template's is, up to the boundaries where 32.12, 32.13 and 32.15 make it depend on a value.
67
+ // Those boundaries are where a marker earns its place, and the walk steps over each from its
68
+ // closing anchor; nowhere before them does a marker earn anything.
69
+ //
70
+ // 41.6 — hydration re-executes the setup, so the values the client starts from are the values the
71
+ // document was rendered with.
72
+
73
+ /**
74
+ * One region's emission: the lines it pushes, and the module it is emitted into.
75
+ *
76
+ * THE ACCUMULATORS ARE THE REGION'S AND THE NAMING IS THE MODULE'S. `chain`, `helpers` and `lines`
77
+ * belong to the one region being emitted — the page, an arm, a row, a slot's fallback, a caller's
78
+ * children — while the counter that names a nested region is shared by every region of the module,
79
+ * so two regions never claim one name.
80
+ */
81
+ class RegionEmission {
82
+ /** 32.43 — the region's inline components, declared ahead of everything that invokes them. */
83
+ defs: string[] = []
84
+ /** The walk: one `const` per position it needs, each found from the one before it. */
85
+ readonly chain: string[] = []
86
+ readonly helpers: string[] = []
87
+ /** The units, each guarded apart on a page (`guard`). */
88
+ readonly lines: string[] = []
89
+ readonly lowering: Lowering
90
+ private readonly counter: { next: number }
91
+
92
+ constructor(lowering: Lowering, counter = { next: 0 }) {
93
+ this.lowering = lowering
94
+ this.counter = counter
95
+ }
96
+
97
+ /** The next region's name under `prefix`, unique in the module. */
98
+ claim(prefix: string): string {
99
+ const name = `${prefix}${this.counter.next}`
100
+ this.counter.next += 1
101
+ return name
102
+ }
103
+
104
+ /** A region nested in this one, named from the same module. */
105
+ nested(): RegionEmission {
106
+ return new RegionEmission(this.lowering, this.counter)
107
+ }
108
+
109
+ /** A nested region's body, in the order the emitted function needs it: walk, helpers, units. */
110
+ body(): string[] {
111
+ return [...this.defs, ...this.chain, ...this.helpers, ...this.lines]
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Which empty regions a client module fills itself: a routed page's, an invoked row's, or both.
117
+ *
118
+ * A file a ROUTE reaches (30.11) is mounted against a page no server painted, once a
119
+ * navigation; a file another INVOKES
120
+ * as a component (32.17) can stand in a row a list grew by, once A ROW. Both need a second copy of
121
+ * the template, and one that needs neither is 34% more client than it needs: measured at 1797 ->
122
+ * 2405 shipped lines over the corpus with every file carrying one. INVOKED decides whether that
123
+ * copy is markup or a build (`Cursor.repeated`) — a page's fill is one parse, and a component's is
124
+ * a parse per row — and ROUTED decides whether it carries a head (39.6). A file can be both, and
125
+ * then each fact decides its own half.
126
+ *
127
+ * WHICH FILES THOSE ARE IS THE BUILD'S KNOWLEDGE, being a fact about the import graph and the file
128
+ * tree rather than about this file, so it arrives rather than being guessed here — and it DEFAULTS
129
+ * TO NEITHER, because the wrong answer costs a static page the "ships no runtime" fact
130
+ * (`compileApp`).
131
+ */
132
+ export type SelfFill = 'none' | 'routed' | 'invoked' | 'both'
133
+
134
+ // The mount's third argument, which only the router passes (`Router.mountFrom`).
135
+ const ROUTED = '__routed'
136
+
137
+ /**
138
+ * The client module for one `.abide`: its mount, and its own fill where `selfFill` asks.
139
+ *
140
+ * `''` where there is nothing to hydrate and nothing imports it by name.
141
+ */
142
+ export function emitClient(
143
+ file: AbideFile,
144
+ answer: CheckerAnswer = UNCHECKED,
145
+ selfFill: SelfFill = 'none',
146
+ /** Where each specifier this file imports landed in the build (`splitImports`). */
147
+ landed: ReadonlyMap<string, string> = new Map(),
148
+ ): string {
149
+ const carriesOwnMarkup = selfFill !== 'none'
150
+ const lowering = new Lowering(file, answer)
151
+ // THE TEMPLATE IS PLACED ONCE (`placeTemplate`) and everything this module emits is rendered
152
+ // from what was placed: the mount's walk, a region's build, and the markup a region made once
153
+ // fills from — the same positions the server's markup is rendered from.
154
+ const page = new Cursor(
155
+ undefined,
156
+ undefined,
157
+ false,
158
+ selfFill === 'invoked' || selfFill === 'both',
159
+ )
160
+ page.components = file.components
161
+ placeTemplate(file.template, page)
162
+ const { defs, chain, helpers, lines } = emitRegion(
163
+ page,
164
+ new RegionEmission(lowering),
165
+ )
166
+
167
+ // 34.2 — A `<script module>` IS PROCESS-WIDE IN A BROWSER, which is MODULE SCOPE: it is
168
+ // evaluated once when this module is first imported rather than once per `mount`, so a second
169
+ // mount of the same page reads what the first one left.
170
+ const moduleSetup = splitImports(lowering.modules(), '.client', landed)
171
+ // 32.17 — A COMPONENT FILLS ITS OWN REGION where the server wrote none. A row the list grew by
172
+ // is built in the browser, and the child's markup is in the child's SERVER module — which the
173
+ // browser may not reach. So the caller writes the anchor pair alone and the child fills it
174
+ // from the template this module already holds, once, inside the instance whose setup just ran.
175
+ // Rendering it from the caller instead would mean the child's setup running twice per row: one
176
+ // run for the markup and another for the bindings.
177
+ //
178
+ // 39.6 — A ROUTE LEVEL APPLIES ITS OWN HEAD THERE, for the same reason: an empty region is
179
+ // one no server painted, so no server wrote this level's head either. Inside `mount`, after
180
+ // the setup, because a `<title>{title}</title>` reads the instance's names as a body slot does
181
+ // — at module scope it was a ReferenceError on every navigation to it. Before the fill, so the
182
+ // title the reader sees is the page they are arriving at for however long the build takes;
183
+ // and a layout mounts before the page in its slot, so the deepest contribution lands last and
184
+ // wins (39.4). A region the server painted is hydrated with the head the server wrote.
185
+ //
186
+ // ONLY WHERE THE ROUTER MOUNTED IT, which it says with `ROUTED`: the server writes the heads of
187
+ // the route's chain alone, and an invoked component fills an empty region once per row the list
188
+ // grew by — applying a head there is a parse and a walk of `document.head` a row. So a file that
189
+ // is both routed and invoked titles the document as a page and leaves it alone as a row.
190
+ const routed = selfFill === 'routed' || selfFill === 'both'
191
+ const head = routed ? headSink(file) : undefined
192
+ const headMarkup =
193
+ head === undefined ? "''" : renderMarkup(head, lowering, CLIENT_LANE)
194
+ const heads = headMarkup !== "''"
195
+ // 39.13 — A HEAD THAT READS SOMETHING LIVE FOLLOWS IT, from a watch the page's scope owns — live
196
+ // by the rule `emitRegion` binds by. One that reads nothing that moves is applied once.
197
+ const liveHeads = head !== undefined && heads && readsLive(head, lowering)
198
+ // 39.14 — THE HEAD IS LEFT ON THE LEVEL the router handed in, painted or not, for the router
199
+ // to read when this level leaves or a level under it does. One thunk, which the apply below
200
+ // reads too, so the markup expression is emitted once.
201
+ const registered = heads
202
+ ? `if (${ROUTED}) ${ROUTED}.head = () => ${headMarkup}\n`
203
+ : ''
204
+ const applied = heads
205
+ ? `if (${ROUTED}) ${lowering.use('applyHead')}(${ROUTED}.head()); `
206
+ : ''
207
+ // Applied with the fill either way, so the watch's first run only subscribes: what it would
208
+ // write is already there, from the server or from the line above.
209
+ if (liveHeads)
210
+ lines.push(
211
+ `if (${ROUTED}) ${lowering.use('liveHead')}(${SCOPE}, ${ROUTED}.head)`,
212
+ )
213
+ const builds = carriesOwnMarkup && page.positions.length > 0
214
+ let fills = ''
215
+ if (applied !== '' || builds) {
216
+ const build = builds
217
+ ? `function __build(__document) {\n ${emitMaker(page, lowering)}\n}\n`
218
+ : ''
219
+ // THE HEAD GOES BEFORE THE FILL, so the guard is written out where there is one to apply.
220
+ fills =
221
+ applied === ''
222
+ ? `${registered}${build}${lowering.use('fillEmpty')}(${REGION_ROOT}, __build)\n`
223
+ : `${registered}${build}if (${lowering.use('isEmptyRegion')}(${REGION_ROOT})) { ${applied}${builds ? `${lowering.use('fillRegion')}(${REGION_ROOT}, __build)` : ''} }\n`
224
+ }
225
+
226
+ // NOTHING LIVE IS NO MODULE: every unit the page's region pushes is a binding, a listener or a
227
+ // region, so an empty `lines` is a page with nothing live anywhere in it.
228
+ // A blank run is only walked because something AFTER it is found through it, so with no
229
+ // binding, no listener and no region anywhere in the page there is nothing to walk to.
230
+ //
231
+ // A FILL IS SOMETHING TO DO, which is why this asks `fills` rather than `lines` alone.
232
+ // An INVOKED component with no binding in it still owns the markup for a row the browser grew
233
+ // — the caller writes the anchor pair and nothing else (32.17) — so without its module every
234
+ // browser-grown row of a static child would be empty.
235
+ //
236
+ // A FILE MOUNTED AGAINST AN EMPTY REGION SHIPS A MODULE REGARDLESS: the router or the caller's
237
+ // client module imports it by name, so the no-op is what it ships.
238
+ //
239
+ // 41.6 — BUT A `<script>` IS SOMETHING TO DO: hydration re-runs every setup, and a static
240
+ // component's can still open a watch, write a shared value or listen on the window.
241
+ const live = lines.length > 0
242
+ const setup = splitImports(lowering.scripts(), '.client', landed)
243
+ if (!live && fills === '' && setup.body === '')
244
+ return carriesOwnMarkup ? 'export default () => {}\n' : ''
245
+
246
+ // A SCOPE IS WHAT THERE IS TO STOP, so a module with nothing live opens none. A static child
247
+ // still ships a module — it fills the anchors of a row the browser grew — and making it
248
+ // allocate a `Scope`, its `stops` array and an entry in the caller's `children` per row is
249
+ // three allocations a row for a mount whose body is empty. `Scope.own(undefined)` already
250
+ // reads a mount that returns nothing, which is the same answer the no-op module gives.
251
+ //
252
+ // 41.10 — THE PAGE IS THE ONE REGION THAT CANNOT REBUILD, so it is the one that has to survive
253
+ // a refusal binding by binding. Every other region answers a mismatch by re-rendering itself
254
+ // from its own markup (`mountFunction`); the page has no block around it and rebuilding it
255
+ // would throw away the document the server sent, focus, scroll and all, which is exactly what
256
+ // the clause forbids.
257
+ //
258
+ // ONE `try` AROUND ALL OF THEM WAS THE SAME FAILURE `Mismatch` WAS WRITTEN AGAINST: it traded
259
+ // the throw for a warning and still skipped every binding and listener after the one that
260
+ // refused, so a page whose first slot disagreed was served looking right and completely dead
261
+ // below that point. Guarded per unit, what is lost is the unit that actually disagreed.
262
+ //
263
+ // A UNIT IS WHAT EACH EMITTER PUSHES — an anchor, an address and its binding, a listener, a
264
+ // bound attribute, a whole block or list — and it is independent by construction: every name a
265
+ // unit declares is read inside it, the anchors excepted, and those are declared above. The
266
+ // wrapper is the SAME BYTES every time, which is what makes the repetition nearly free once
267
+ // gzipped, where a `guard(() => …)` helper would be a closure allocated per binding at mount.
268
+
269
+ // THE WALK STANDS OUTSIDE EVERY GUARD, which is why it cannot throw (see `emitRegion`): it runs
270
+ // once, top to bottom, after `fills` has put the page in place, and each unit then checks the
271
+ // one node it was handed.
272
+ const owning = scopedSetup(setup.body, lowering)
273
+ const bindings = scopeBindings(owning, chain, lines, lowering)
274
+
275
+ // 10.5 on the other side, and the same scope: the child's `mount` is called from inside the
276
+ // parent's, so the chain a key is looked up is the component tree here too.
277
+ // 10.5 — CAPTURED WHERE A DEFERRED MOUNT CAN NEED IT. A row or an arm mounted after the fact
278
+ // runs from a `watch` effect, with nothing on the stack; this is the scope it resumes.
279
+ const captured = page.defersSetup
280
+ ? `const ${SHARE_AT} = ${lowering.use('currentShare')}()\n`
281
+ : ''
282
+ const { opened, closed } = shareScope(lowering, '')
283
+ // Ahead of the imports, which are read off what the lowering was asked for.
284
+ const levelMarkup = `${[...defs, ...helpers].join('\n')}\n${fills}${captured}${bindings}`
285
+ const markup = routed
286
+ ? deferredMarkup(levelMarkup, owning.declared, lowering)
287
+ : levelMarkup
288
+ // The escaping is an APP's (`@abide/abide`); everything else is the client runtime's (`@abide/abide/runtime`).
289
+ // THE SETUP IS NOT RE-INDENTED. Adding a margin to every line rewrites the INSIDE of a
290
+ // multi-line template literal, so a string constant gains four spaces it never had.
291
+ return `${moduleImports(lowering, (name) => (SHARED_NAMES.has(name) ? SHARED_SPECIFIER : RUNTIME_SPECIFIER), [moduleSetup, setup])}
292
+ ${moduleSetup.body === '' ? '' : `${moduleSetup.body}\n`}\
293
+ export default function mount(${REGION_ROOT}${routed ? `, ${PROPS} = {}, ${ROUTED}` : lowering.takesProps() ? `, ${PROPS} = {}` : ''}) {
294
+ ${opened}${owning.opened}${setup.body}
295
+ ${owning.handed}${markup}${owning.closed}${closed}
296
+ }
297
+ `
298
+ }
299
+
300
+ /**
301
+ * 12.4, 12.13 — THE SCOPE IS MADE BEFORE THE SETUP, so the watches the setup opens land in it as
302
+ * they open (`collectWatches`) and a watch has one owner from the start. The collection stops before
303
+ * the markup: a binding is its scope's by `Scope.watch`, and a child mounted there collects its own.
304
+ *
305
+ * `declared` says the scope exists — a body with no setup leaves it to `scopeBindings`, which makes
306
+ * none where nothing is live.
307
+ */
308
+ function scopedSetup(
309
+ body: string,
310
+ lowering: Lowering,
311
+ /**
312
+ * 10.5 — a branch-local setup, which a later swap or a grown row runs from a `watch` effect with
313
+ * no share scope current, so it resumes its instance's (`SHARE_AT`).
314
+ */
315
+ resumes = false,
316
+ ): { opened: string; handed: string; closed: string; declared: boolean } {
317
+ if (body === '')
318
+ return { opened: '', handed: '', closed: '', declared: false }
319
+ const collect = lowering.use('collectWatches')
320
+ const share = resumes ? resumedShare(lowering, SHARE_AT) : undefined
321
+ const resume = share ? `${share.resume}\n` : ''
322
+ const leave = share ? `; ${share.leave}` : ''
323
+ return {
324
+ opened: `${resume}const ${SCOPE} = new ${lowering.use('Scope')}()\nconst __owner = ${collect}(${SCOPE}.stops)\ntry {\n`,
325
+ handed: `${collect}(undefined)\n`,
326
+ // A SETUP THAT THROWS answers no scope for anything to hold, so it is stopped here — under
327
+ // a `{#try}` every retry would otherwise leave one more watch running.
328
+ closed: `\n} catch (thrown) {\n${SCOPE}.stop()\nthrow thrown\n} finally { ${collect}(__owner)${leave} }`,
329
+ declared: true,
330
+ }
331
+ }
332
+
333
+ /**
334
+ * A component's bindings over the scope its setup made, or a scope of their own where it made none.
335
+ *
336
+ * A BODY WITH NOTHING LIVE ANSWERS NO SCOPE — `Scope.own(undefined)` reads it as static — unless its
337
+ * setup opened something, and then that is what there is to stop.
338
+ */
339
+ function scopeBindings(
340
+ owning: { declared: boolean },
341
+ chain: string[],
342
+ lines: string[],
343
+ lowering: Lowering,
344
+ ): string {
345
+ if (lines.length === 0)
346
+ return owning.declared
347
+ ? `return ${SCOPE}.stops.length === 0 ? undefined : ${SCOPE}`
348
+ : ''
349
+ return `${owning.declared ? '' : `const ${SCOPE} = new ${lowering.use('Scope')}()\n`}\
350
+ ${chain.map((line) => `${line}\n`).join('')}\
351
+ ${lines.map((unit) => guard(unit, lowering)).join('\n')}
352
+ return ${SCOPE}`
353
+ }
354
+
355
+ /**
356
+ * A routed level's markup, handed to the router to run once every level is set up.
357
+ *
358
+ * 41.19 ON THE CLIENT — EVERY LEVEL IS SET UP BEFORE ANY IS HYDRATED, as `composePage` sets every
359
+ * level up before it builds any. A page's setup can write what its layout's markup reads, and the
360
+ * server painted the layout after that write: hydrating the layout first, inside its own mount,
361
+ * read the value before the page had written it and disagreed with the document. So a level the
362
+ * router mounts leaves its markup on the level it was handed, which the router runs once the whole
363
+ * chain is set up; anything else that mounts the file runs it at once. The share scope the setup
364
+ * ran in is resumed for it (10.5), as `emitComponent`'s deferred build resumes one — and left on
365
+ * the level too, for the router to set the level below up inside it.
366
+ */
367
+ function deferredMarkup(
368
+ markup: string,
369
+ /** The setup made the scope, so the level holds it before its markup runs — or if it never does. */
370
+ declared: boolean,
371
+ lowering: Lowering,
372
+ ): string {
373
+ return `const ${SETTLED_AT} = ${lowering.use('currentShare')}()
374
+ function __markup(${REGION_ROOT}) {
375
+ ${insideShare(lowering, SETTLED_AT, markup)}
376
+ }
377
+ if (${ROUTED}) { ${ROUTED}.markup = __markup; ${ROUTED}.share = ${SETTLED_AT}; return${declared ? ` ${SCOPE}` : ''} }
378
+ return __markup(${REGION_ROOT})`
379
+ }
380
+
381
+ /**
382
+ * One unit of a component's mount, guarded apart from the others.
383
+ *
384
+ * The wrapper is the SAME BYTES every time, which is what makes the repetition nearly free once
385
+ * gzipped, where a `guard(() => …)` helper would be a closure allocated per binding at mount.
386
+ */
387
+ function guard(unit: string, lowering: Lowering): string {
388
+ return `try {\n${unit}\n} catch (thrown) { if (!${lowering.use('warnMismatch')}(thrown)) throw thrown }`
389
+ }
390
+
391
+ /**
392
+ * An inline component on the client: the mount a file component's module exports, declared in
393
+ * place.
394
+ *
395
+ * 32.17, 32.40 — INVOKED AS A FILE COMPONENT IS, against its region and with the record of
396
+ * accessors its pattern binds from, and it FILLS ITS OWN REGION where no server painted one — an
397
+ * invoked file's `SelfFill`, which every inline component is, and built rather than parsed since
398
+ * it can stand in a row (`Cursor.repeated`). Its units are guarded apart as a file's are.
399
+ *
400
+ * 32.42 — DECLARED WHERE ITS REGION MOUNTS, so it closes over every name in scope there.
401
+ */
402
+ function clientComponent(
403
+ component: InlineComponent,
404
+ parent: RegionEmission,
405
+ ): string {
406
+ const lowering = parent.lowering
407
+ const sink = new Cursor(undefined, undefined, false, true)
408
+ sink.components = component.components
409
+ placeTemplate(component.children, sink)
410
+ const { defs, chain, helpers, lines } = emitRegion(sink, parent.nested())
411
+ const head =
412
+ component.pattern === '' ? '' : `${lowering.setup(component)}\n`
413
+ const setup =
414
+ component.setup === null ? '' : `${lowering.setup(component.setup)}\n`
415
+ const owning = scopedSetup(setup, lowering)
416
+ const fill =
417
+ sink.positions.length === 0
418
+ ? ''
419
+ : `function __build(__document) {\n ${emitMaker(sink, lowering)}\n}
420
+ ${lowering.use('fillEmpty')}(${REGION_ROOT}, __build)\n`
421
+ const captured = sink.defersSetup
422
+ ? `const ${SHARE_AT} = ${lowering.use('currentShare')}()\n`
423
+ : ''
424
+ const bindings = scopeBindings(owning, chain, lines, lowering)
425
+ // 10.5, 32.46 — its own share scope per instance, as on the server (`serverComponent`).
426
+ const { opened, closed } = shareScope(lowering, '')
427
+ return `function ${component.name}(${REGION_ROOT}, ${PROPS} = {}) {
428
+ ${opened}${head}${owning.opened}${setup}${owning.handed}${[...defs, ...helpers].join('\n')}
429
+ ${fill}${captured}${bindings}${owning.closed}${closed}
430
+ }`
431
+ }
432
+
433
+ /**
434
+ * The statements declaring a region's inline components on the client: the ones its body declares
435
+ * (32.43), each under its name, and the ones an invocation in it is passed (32.50), each under
436
+ * `passedName`.
437
+ *
438
+ * DECLARED IN THE REGION EVEN WHERE NOTHING IN IT IS READ, a row's included: one function a row
439
+ * mount, which `inlineRowShare.ts` prices inside the noise of the mount around it. Hoisting the
440
+ * ones that read nothing of the row would be a scope analysis and a branch with no ratio to earn it.
441
+ */
442
+ function definitions(sink: Cursor, region: RegionEmission): string[] {
443
+ const out: string[] = []
444
+ for (const component of sink.components)
445
+ out.push(clientComponent(component, region))
446
+ for (const at of sink.positions)
447
+ if (at.kind === 'region' && at.holder.kind === 'element')
448
+ for (const passed of at.holder.passed)
449
+ out.push(
450
+ `const ${passedName(passed)} = ${clientComponent(passed, region)}`,
451
+ )
452
+ return out
453
+ }
454
+
455
+ /**
456
+ * Whether a placed region reads anything that moves.
457
+ *
458
+ * 39.13 — by `emitRegion`'s own rule: a nested region, a live text run, or an attribute
459
+ * `lowering.isLive` says is.
460
+ */
461
+ function readsLive(sink: Cursor, lowering: Lowering): boolean {
462
+ for (const at of sink.positions) {
463
+ if (at.kind === 'region') return true
464
+ if (at.kind === 'text') {
465
+ if (lowering.isLiveRun(at.run)) return true
466
+ continue
467
+ }
468
+ for (const one of classifyAttributes(
469
+ at.holder as ElementNode,
470
+ lowering,
471
+ ))
472
+ if (one.live) return true
473
+ }
474
+ return false
475
+ }
476
+
477
+ /**
478
+ * One region's bindings, as its walk, its helpers and its guarded units.
479
+ *
480
+ * Emitted against the region's own root: the page, a `{#if}` arm, a `{#for}` row, a `<slot/>`
481
+ * fallback or a caller's children. Each is a sink of its own (`Cursor`), so `__c1` in one and
482
+ * `__c1` in another are different nodes and neither region can reach the other's.
483
+ *
484
+ * TWO KINDS OF LINE, and the split is 41.10's. The WALK — one `const` per position it needs, each
485
+ * found from the one before it — goes into `chain` and NEVER THROWS: an absent node is carried
486
+ * forward as `undefined`. The UNITS go into `lines`, and each CHECKS the node it was handed
487
+ * (`elementHere`, `textHere`, `regionFound`). On a page, where every unit is guarded apart, a node
488
+ * that disagrees then loses the unit that needed it and nothing after it — the locality a path
489
+ * re-walked from the root used to buy, without re-walking.
490
+ *
491
+ * THE WALK IS PRUNED. A position is walked when something at or after it in its parent needs it —
492
+ * a binding, or a later position found through it — so a static subtree and a static tail are
493
+ * never visited. A blank run standing before something walked is put back as the walk passes
494
+ * (`runHere`), because what follows it is found from it.
495
+ */
496
+ function emitRegion(sink: Cursor, region: RegionEmission): RegionEmission {
497
+ const lowering = region.lowering
498
+ const chain = region.chain
499
+ const lines = region.lines
500
+ const positions = sink.positions
501
+ // Each bound element's attributes, classified once and read by both passes below.
502
+ const bound = new Map<PlacedNode, ClassifiedAttribute[]>()
503
+ const live = new Set<PlacedNode>()
504
+ for (const at of positions) {
505
+ if (at.kind === 'region') {
506
+ live.add(at)
507
+ continue
508
+ }
509
+ if (at.kind === 'text') {
510
+ if (lowering.isLiveRun(at.run)) live.add(at)
511
+ continue
512
+ }
513
+ const classified = classifyAttributes(
514
+ at.holder as ElementNode,
515
+ lowering,
516
+ )
517
+ if (!classified.some(isBound)) continue
518
+ bound.set(at, classified)
519
+ live.add(at)
520
+ }
521
+
522
+ // BACKWARDS, so everything after a position — its later siblings and its own descendants — is
523
+ // decided before it is. `followed` holds the frames, keyed by the element they stand inside,
524
+ // that have a walked position later than the one being decided.
525
+ const walked = new Set<PlacedNode>()
526
+ const followed = new Set<PlacedNode | null>()
527
+ for (let index = positions.length - 1; index >= 0; index -= 1) {
528
+ const at = positions[index] as PlacedNode
529
+ if (!live.has(at) && !followed.has(at) && !followed.has(at.within))
530
+ continue
531
+ walked.add(at)
532
+ followed.add(at.within)
533
+ }
534
+
535
+ for (const at of positions) {
536
+ if (!walked.has(at)) continue
537
+ if (at.kind === 'region')
538
+ chain.push(
539
+ `const ${at.name} = ${lowering.use('regionHere')}(${at.from})`,
540
+ )
541
+ // A RUN THAT CAN HOLD MARKUP (32.26) is stepped over to its closing anchor where it does,
542
+ // and a blank one is put back where it rendered nothing — the same step (`runHere`). A run
543
+ // of proven parts is text for good and is its node as found.
544
+ else if (
545
+ at.kind === 'text' &&
546
+ (at.blank || lowering.holdsMarkup(at.run))
547
+ )
548
+ chain.push(
549
+ `const ${at.name} = ${lowering.use('runHere')}(${at.from}, ${at.blank ? at.parent : 'null'})`,
550
+ )
551
+ else chain.push(`const ${at.name} = ${at.from}`)
552
+ }
553
+
554
+ // THE UNITS, in the order a page always installed them — text, listeners, attributes, the node
555
+ // handed over, then the regions. The walk does not depend on it; a `bind:element` callback has
556
+ // always run with every other binding already in place, and that is kept.
557
+ const texts: string[] = []
558
+ const handlers: string[] = []
559
+ const attributes: string[] = []
560
+ const elements: string[] = []
561
+ const regions: PlacedNode[] = []
562
+ for (const at of positions) {
563
+ if (!live.has(at)) continue
564
+ if (at.kind === 'region') {
565
+ regions.push(at)
566
+ continue
567
+ }
568
+ const slot = at.name.slice('__c'.length)
569
+ if (at.kind === 'text') {
570
+ const values: string[] = []
571
+ const brands: string[] = []
572
+ const text: string[] = []
573
+ const markup: string[] = []
574
+ for (let piece = 0; piece < at.run.length; piece += 1) {
575
+ const node = at.run[piece] as TemplateNode
576
+ if (node.kind === 'text') {
577
+ markup.push(JSON.stringify(node.text))
578
+ // 32.27 — static text is markup, and `data` is not a parse: a piece with an
579
+ // entity in it goes in as the characters it stands for, decoded by the build.
580
+ text.push(
581
+ JSON.stringify(
582
+ decodeCharacterReferences(node.text, 'text'),
583
+ ),
584
+ )
585
+ continue
586
+ }
587
+ const value = `__v${slot}_${piece}`
588
+ values.push(`${value} = ${lowering.expression(node)}`)
589
+ brands.push(`${lowering.use('isRaw')}(${value})`)
590
+ text.push(`${lowering.use('escapeless')}(${value})`)
591
+ markup.push(`${lowering.use('escapeText')}(${value})`)
592
+ }
593
+ // RESOLVED ONCE, and the binding closes over what it resolved to. The node a position
594
+ // lands on is the same one on every run while the run holds text — the walk put a blank
595
+ // run's back and `setText` never removes it — so re-finding it per write is the same
596
+ // answer bought again: measured in Chromium at 0.47 µs a write against 0.22 µs with the
597
+ // node held. 32.26 is the one write that changes it: a `Raw` part turns the run into an
598
+ // anchored one (`setMarkup`) and a later text value turns it back, so each write hands
599
+ // back what the run now is and the binding holds that.
600
+ texts.push(
601
+ `let __t${slot} = ${lowering.use('textHere')}(${at.name})
602
+ ${SCOPE}.watch(() => {
603
+ const ${values.join(', ')}
604
+ __t${slot} = ${brands.join(' || ')} ? ${lowering.use('setMarkup')}(__t${slot}, ${markup.join(' + ')}) : ${lowering.use('setText')}(__t${slot}, ${text.join(' + ')})
605
+ })`,
606
+ )
607
+ continue
608
+ }
609
+ const element = `${lowering.use('elementHere')}(${at.name}, ${JSON.stringify(at.tag)})`
610
+ // 32.3 — THE ATTRIBUTE BINDING. The server wrote the value standing at render; this is
611
+ // what keeps writing it. ONCE PER ELEMENT, NOT PER ATTRIBUTE: `<a href={u} title={t}>` is
612
+ // one element and two bindings, and a refusal loses exactly what it should either way,
613
+ // because every binding in the group needs the element the check refused.
614
+ const writes: string[] = []
615
+ const binds: string[] = []
616
+ const spreads: string[] = []
617
+ for (const one of bound.get(at) as ClassifiedAttribute[]) {
618
+ if (!isBound(one)) continue
619
+ if (one.kind === 'handler')
620
+ handlers.push(
621
+ `${element}.addEventListener(${JSON.stringify(one.event)}, ${lowering.expression(one.attribute)})`,
622
+ )
623
+ // 32.5, 32.7, 32.8 — THE PROPERTY AND THE VALUE, IN STEP BOTH WAYS: a watch on this
624
+ // region's scope writes the property, and a listener writes it back.
625
+ else if (one.kind === 'bound')
626
+ binds.push(
627
+ `${lowering.use('bindProperty')}(${element}, ${JSON.stringify(one.bind)}, ${lowering.reference(one.attribute)}, ${SCOPE})`,
628
+ )
629
+ // 32.11 — THE SPREAD, KEPT WRITTEN: an attribute it stops carrying is removed.
630
+ else if (one.kind === 'spread')
631
+ spreads.push(
632
+ `${lowering.use('bindSpread')}(${element}, () => (${lowering.expression(one.attribute)}), ${JSON.stringify(one.explicit)}, ${SCOPE})`,
633
+ )
634
+ // 32.9 — THE NODE, HANDED OVER, once. Not a watch: what the value takes is the element,
635
+ // which is the same node on every run a watch would have made — and the callback
636
+ // form's `Disposer` goes on this region's scope, so a widget it set up is torn down
637
+ // when the nodes it was set up over leave.
638
+ else if (one.kind === 'element')
639
+ elements.push(
640
+ `const __r${slot} = ${lowering.use('bindElement')}(${element}, ${lowering.reference(one.attribute)})
641
+ if (__r${slot} !== undefined) ${SCOPE}.stops.push(__r${slot})`,
642
+ )
643
+ // 32.20 IS THE INTERPOLATION'S CLAUSE ON THIS SIDE TOO, and 32.37's absence with it:
644
+ // `setAttribute` answers through `attributeText`, as the server's markup did, so a
645
+ // `javascript:` the server refused is refused the moment the value moves too.
646
+ // A WATCH PER ATTRIBUTE, not one over the group: two attributes reading two
647
+ // different values would otherwise each wake for the other's write.
648
+ else {
649
+ const { write, name } =
650
+ one.kind === 'merged' && one.toggles !== undefined
651
+ ? one.toggles
652
+ : {
653
+ write: 'attribute' as const,
654
+ name: one.attribute.name,
655
+ }
656
+ writes.push(
657
+ `${SCOPE}.watch(() => ${lowering.use(WRITES[write])}(__a${slot}, ${JSON.stringify(name)}, ${lowering.expression(one.attribute)}))`,
658
+ )
659
+ }
660
+ }
661
+ if (writes.length > 0)
662
+ attributes.push(
663
+ `const __a${slot} = ${element}\n${writes.join('\n')}`,
664
+ )
665
+ for (const unit of binds) attributes.push(unit)
666
+ for (const unit of spreads) attributes.push(unit)
667
+ }
668
+ for (const unit of texts) lines.push(unit)
669
+ for (const unit of handlers) lines.push(unit)
670
+ for (const unit of attributes) lines.push(unit)
671
+ for (const unit of elements) lines.push(unit)
672
+
673
+ for (const at of regions) {
674
+ const holder = at.holder
675
+ if (holder.kind === 'block') {
676
+ if (holder.block === 'for') emitList(at, holder, region)
677
+ else if (holder.block === 'try') emitTry(at, holder, region)
678
+ else emitBlock(at, holder, region)
679
+ } else if (holder.kind === 'element') {
680
+ if (isSlot(holder)) emitSlot(at, region)
681
+ else emitInvocation(at, holder, region)
682
+ }
683
+ }
684
+ // 32.43 — A REGION THAT MOUNTS NOTHING INVOKES NOTHING, so what it declares is reached from
685
+ // nowhere and is not declared: a row declaring a component it never invokes stays a row whose
686
+ // mount is the shared empty one.
687
+ if (lines.length > 0) region.defs = definitions(sink, region)
688
+ return region
689
+ }
690
+
691
+ // A region's bindings go through its SCOPE, so what replaced the region can stop them (see
692
+ // `Scope`). In the framework's own `__` namespace because a row binds the AUTHOR's item name as a
693
+ // parameter in the same scope.
694
+ const SCOPE = '__scope'
695
+
696
+ // Which runtime write each kind of attribute binding is handed to. A record rather than a chain
697
+ // of ternaries, so a fourth kind is a row here and the call site stays one line — all three take
698
+ // the same three arguments, which is what makes them one site at all.
699
+ const WRITES = {
700
+ attribute: 'setAttribute',
701
+ class: 'setClass',
702
+ style: 'setStyleProperty',
703
+ } as const
704
+
705
+ // The share scope an instance captures for its deferred mounts (10.5), named apart from the one an
706
+ // instance OPENS (`shareScope`): a page that shares nothing still carries this for a child that does.
707
+ const SHARE_AT = '__shareAt'
708
+
709
+ // The document a region's maker is handed and builds its nodes from.
710
+ const DOCUMENT = '__document'
711
+
712
+ // A run's anchors while it holds markup (32.30), as the JS string literals a built run parses with.
713
+ const RAW_OPEN_MARKUP = JSON.stringify(anchorMarkup(RAW_OPEN))
714
+ const RAW_CLOSE_MARKUP = JSON.stringify(anchorMarkup(RAW_CLOSE))
715
+
716
+ /**
717
+ * The body of the function that makes a region's nodes from a `__document`.
718
+ *
719
+ * WHAT MAKES A REGION'S NODES, as the body of a function taking the region's `__document`: the
720
+ * row, the arm, the slot's fallback, the caller's children and the page that fills itself are all
721
+ * made the same way. BUILT from the positions the markup walk placed (`emitBuild`) — or, where the
722
+ * region holds content only the parser makes right (`isParserOwned`), PARSED from the very markup
723
+ * the server writes, which is the one representation that cannot disagree with it.
724
+ *
725
+ * THE MARKUP IS ASKED FOR ONLY WHERE IT IS USED, as a thunk: writing it binds the markup writer's
726
+ * names (`escapeText`, `slotValue`), and a module that builds would import them for nothing.
727
+ */
728
+ function emitMaker(
729
+ sink: Cursor,
730
+ lowering: Lowering,
731
+ markup = (): string => renderMarkup(sink, lowering, CLIENT_LANE),
732
+ anchored = false,
733
+ ): string {
734
+ // A REGION MADE ONCE IS PARSED. One parse of a whole region costs what building it costs
735
+ // (measured at 86-100% of building it) and ships as the markup string rather than as the code that builds it
736
+ // — building a docs page's own fill was +4.3% gzipped on the whole client for nothing.
737
+ let parsed = !sink.repeated
738
+ for (const at of sink.positions) parsed ||= at.parserOwned
739
+ if (parsed)
740
+ return `return ${lowering.use('markupNodes')}(${DOCUMENT}, ${markup()})`
741
+ return emitBuild(sink, anchored, lowering)
742
+ }
743
+
744
+ /**
745
+ * The body that builds a row's nodes with DOM calls, from the positions `placeTemplate` placed.
746
+ *
747
+ * The same positions the row's mount walks (`emitRegion`), under the same slot names. So a row has
748
+ * one description:
749
+ * the server writes it as bytes, `make` builds it, `mount` finds it, and none of the three can
750
+ * disagree about where a node stands.
751
+ *
752
+ * BUILT RATHER THAN PARSED, and the whole of why: `markupNodes` sets `template.innerHTML` once a
753
+ * row, measured (`bun run bench:reorder`) at ~19 µs a row and ~90% of building a list, and ~88% of
754
+ * it FIXED — what costs is invoking the parser, not parsing. A row that reads PAGE state priced at
755
+ * n=1000 (`selectedRowShare.ts`): 21.6-22.2 ms parsed, 3.5-3.6 ms built, the parsed layer alone
756
+ * longer than a frame. The server is untouched; only a row the browser grows goes through `make`.
757
+ *
758
+ * THE BUILD WRITES WHAT THE MARKUP WRITES, MINUS WHAT THE MOUNT WILL WRITE. `makeRow` calls `make`
759
+ * and then `mount`, so a value the mount binds — a run or an attribute reading a `Reactive` — is
760
+ * written by the binding's first run and the build leaves it: a live run is an empty text node, a
761
+ * live attribute is not set. Everything else takes the value the parser would have made of the
762
+ * server's bytes — `escapeless` for an expression, and the build's own decode for a static one
763
+ * (`decodeCharacterReferences`). A merged `class` or `style` is
764
+ * written whole, through the same structure the markup takes (`mergedValue`), so the two are one
765
+ * string.
766
+ *
767
+ * A BLANK RUN IS BUILT ONLY WHEN IT HAS SOMETHING IN IT, because that is what the server does: a
768
+ * run of expressions that stringify to '' writes no node, and the mount's walk puts one back
769
+ * (`runHere`) exactly where it would for a row the server painted.
770
+ *
771
+ * A NESTED REGION IS AN EMPTY ANCHOR PAIR, filled by its own machinery on the mount's first run
772
+ * (`fillEmpty`), and a component or a slot is the same pair filled by the child.
773
+ */
774
+ function emitBuild(row: Cursor, anchored: boolean, lowering: Lowering): string {
775
+ const lines: string[] = ['const __built = []']
776
+ if (anchored)
777
+ lines.push(
778
+ `__built.push(${DOCUMENT}.createComment(${JSON.stringify(ROW_OPEN)}))`,
779
+ )
780
+ const render = buildRender(lowering)
781
+ const into = (at: PlacedNode, node: string): string =>
782
+ at.within === null
783
+ ? `__built.push(${node})`
784
+ : `${at.within.name}.appendChild(${node})`
785
+ for (const at of row.positions) {
786
+ if (at.kind === 'region') {
787
+ lines.push(
788
+ into(
789
+ at,
790
+ `${DOCUMENT}.createComment(${JSON.stringify(REGION_OPEN)})`,
791
+ ),
792
+ into(
793
+ at,
794
+ `${DOCUMENT}.createComment(${JSON.stringify(REGION_CLOSE)})`,
795
+ ),
796
+ )
797
+ continue
798
+ }
799
+ if (at.kind === 'text') {
800
+ for (const line of builtRun(at, lowering, into)) lines.push(line)
801
+ continue
802
+ }
803
+ lines.push(
804
+ `const ${at.name} = ${DOCUMENT}.createElement(${JSON.stringify(at.tag)})`,
805
+ )
806
+ for (const one of classifyAttributes(
807
+ at.holder as ElementNode,
808
+ lowering,
809
+ )) {
810
+ const value = builtAttribute(one, lowering, render)
811
+ if (value === null) continue
812
+ const set = `${at.name}.setAttribute(${JSON.stringify(one.kind === 'merged' ? one.group?.name : one.attribute.name)}, `
813
+ // 32.37 — a whole-value attribute may be absent, which the server wrote as nothing.
814
+ lines.push(
815
+ one.kind === 'dynamic'
816
+ ? `{ const __text = ${value}; if (__text !== null) ${set}__text) }`
817
+ : `${set}${value})`,
818
+ )
819
+ }
820
+ lines.push(into(at, at.name))
821
+ }
822
+ lines.push('return __built')
823
+ return lines.join('\n ')
824
+ }
825
+
826
+ /**
827
+ * The lines that build one text run of a built row.
828
+ *
829
+ * A RUN, BUILT. What the server writes for a run is its static bytes and each expression escaped —
830
+ * except a `Raw` value (32.26), whose html goes in unescaped, is PARSED into elements, and is
831
+ * anchored (`markupRun`). A text node cannot hold that, so a run whose expression answers a `Raw`
832
+ * is parsed from the very markup the server writes for it, anchors and all — the parser for the one
833
+ * thing only it makes — and every other run is one text node. The check is an `instanceof` a piece,
834
+ * which is what `escapeText` pays already.
835
+ *
836
+ * A run reading a `Reactive` is the mount's to write: an empty node where the run always renders
837
+ * one, and none where it can render none (a blank run), which is what the server leaves too.
838
+ */
839
+ function builtRun(
840
+ at: PlacedNode,
841
+ lowering: Lowering,
842
+ into: (at: PlacedNode, node: string) => string,
843
+ ): string[] {
844
+ const make = (text: string): string =>
845
+ into(at, `${DOCUMENT}.createTextNode(${text})`)
846
+ if (lowering.isLiveRun(at.run)) return at.blank ? [] : [make("''")]
847
+ const lines: string[] = []
848
+ const text: string[] = []
849
+ const markup: string[] = []
850
+ const raw: string[] = []
851
+ for (let piece = 0; piece < at.run.length; piece += 1) {
852
+ const node = at.run[piece] as TemplateNode
853
+ if (node.kind === 'text') {
854
+ text.push(
855
+ JSON.stringify(decodeCharacterReferences(node.text, 'text')),
856
+ )
857
+ markup.push(JSON.stringify(node.text))
858
+ continue
859
+ }
860
+ const value = `${at.name}_${piece}`
861
+ lines.push(`const ${value} = ${lowering.expression(node)}`)
862
+ text.push(`${lowering.use('escapeless')}(${value})`)
863
+ markup.push(`${lowering.use('escapeText')}(${value})`)
864
+ raw.push(`${lowering.use('isRaw')}(${value})`)
865
+ }
866
+ const whole = text.length === 0 ? "''" : text.join(' + ')
867
+ if (raw.length === 0) {
868
+ lines.push(make(whole))
869
+ return lines
870
+ }
871
+ lines.push(
872
+ `if (${raw.join(' || ')}) for (const __made of ${lowering.use('markupNodes')}(${DOCUMENT}, ${RAW_OPEN_MARKUP} + ${markup.join(' + ')} + ${RAW_CLOSE_MARKUP})) ${into(at, '__made')}`,
873
+ )
874
+ if (!at.blank) {
875
+ lines.push(`else ${make(whole)}`)
876
+ return lines
877
+ }
878
+ lines.push(`else if ((${at.name} = ${whole}) !== '') ${make(at.name)}`)
879
+ lines.splice(lines.length - 2, 0, `let ${at.name}`)
880
+ return lines
881
+ }
882
+
883
+ /**
884
+ * One attribute's value as `setAttribute` takes it, or null for one the build leaves alone.
885
+ *
886
+ * What the markup writes, less what the mount writes: 32.5, 32.11 — a bind and a spread are written
887
+ * by their bindings, installed on a built row too, and so is a live value (32.3).
888
+ */
889
+ function builtAttribute(
890
+ one: ClassifiedAttribute,
891
+ lowering: Lowering,
892
+ render: ValueRender,
893
+ ): string | null {
894
+ if (one.kind === 'merged')
895
+ return one.group === undefined
896
+ ? null
897
+ : mergedValue(one.group, lowering, render)
898
+ if (one.kind === 'dynamic')
899
+ return one.live
900
+ ? null
901
+ : `${lowering.use('attributeText')}(${JSON.stringify(one.attribute.name)}, ${lowering.expression(one.attribute)})`
902
+ if (one.kind !== 'static' || one.bytes === undefined) return null
903
+ if (one.attribute.value === '') return "''"
904
+ // 32.28 — a URL attribute's bytes are its value escaped whole, so they decode back to it exactly.
905
+ return render.bytes(one.bytes)
906
+ }
907
+
908
+ /**
909
+ * The build's half of `ValueRender`: what the parser makes of each piece the markup escapes.
910
+ *
911
+ * A merge member reading a `Reactive` is still evaluated here, under 41.4's guard, because a merged
912
+ * attribute is written whole or not at all.
913
+ */
914
+ function buildRender(lowering: Lowering): ValueRender {
915
+ const guarded = (attribute: Attribute): string =>
916
+ `${lowering.use('escapeless')}(${unlandable(lowering, attribute, lowering.expression(attribute))})`
917
+ return {
918
+ dynamic: guarded,
919
+ declaration: (attribute) =>
920
+ `${lowering.use('oneStyleValue')}(${guarded(attribute)})`,
921
+ bytes: (bytes) =>
922
+ JSON.stringify(decodeCharacterReferences(bytes, 'attribute')),
923
+ }
924
+ }
925
+
926
+ /**
927
+ * Emits a region's `_build` and `_mount` pair into `helpers`, for a region nobody painted.
928
+ *
929
+ * 32.17 and 32.18 are the same mechanism from two sides — a caller's children handed to a
930
+ * child, and the child's own fallback for a slot nothing was passed — so they are one emitter
931
+ * rather than two that have to be kept byte-compatible by hand.
932
+ */
933
+ function emitFillable(
934
+ name: string,
935
+ sink: Cursor,
936
+ region: RegionEmission,
937
+ ): void {
938
+ const lowering = region.lowering
939
+ const filled = emitRegion(sink, region.nested())
940
+ region.helpers.push(
941
+ `function ${name}_build(__document) {\n ${emitMaker(sink, lowering)}\n}`,
942
+ )
943
+ region.helpers.push(
944
+ mountFunction(
945
+ name,
946
+ REGION_ROOT,
947
+ filled.body(),
948
+ `${lowering.use('fillRegion')}(${REGION_ROOT}, ${name}_build)`,
949
+ lowering,
950
+ sink.defersSetup,
951
+ ),
952
+ )
953
+ }
954
+
955
+ /**
956
+ * The source of a region's `_mount` function, which rebuilds the region on a mismatch.
957
+ *
958
+ * 41.10 — A MISMATCH REBUILDS THIS BLOCK OR ROW AND NOTHING WIDER. What the server wrote is what
959
+ * hydration walks; where it disagrees, it is re-rendered from the same markup a swap or a new row
960
+ * uses (`rebuild`) and wired again. `__rebuilt` is what stops a document that disagrees for some
961
+ * other reason from rebuilding forever — the second failure is the author's to see.
962
+ */
963
+ function mountFunction(
964
+ name: string,
965
+ parameters: string,
966
+ body: string[],
967
+ rebuild: string,
968
+ lowering: Lowering,
969
+ resumes: boolean,
970
+ /**
971
+ * 12.13 — the branch-local setup made the scope (`scopedSetup`), holding its watches, and the
972
+ * mount binds into it. A refusal stops only what the mount opened, past `__mark`.
973
+ */
974
+ declared = false,
975
+ ): string {
976
+ // A BODY THAT BINDS NOTHING HAS NOTHING TO STOP AND NOTHING TO REFUSE, so it opens no scope
977
+ // and no `try`: every mount of it answers the one shared empty scope. A static row's two
978
+ // allocations — the `Scope` and its `stops` — are otherwise paid per row for a body that is
979
+ // empty.
980
+ if (body.length === 0)
981
+ return `const ${name}_mount = () => ${declared ? SCOPE : lowering.use('EMPTY_SCOPE')}`
982
+ const mount = [
983
+ declared
984
+ ? ` const __mark = ${SCOPE}.stops.length`
985
+ : ` const ${SCOPE} = new ${lowering.use('Scope')}()`,
986
+ ` try {`,
987
+ ...body.map((line) => ` ${line}`),
988
+ ` } catch (thrown) {`,
989
+ ` ${SCOPE}.stop(${declared ? '__mark' : ''})`,
990
+ ` if (__rebuilt || !${lowering.use('warnMismatch')}(thrown)) throw thrown`,
991
+ ` ${rebuild}`,
992
+ ` return ${name}_mount(${parameters}, true)`,
993
+ ` }`,
994
+ ` return ${SCOPE}`,
995
+ ].join('\n')
996
+ // 10.5 — the instance's own scope, put back for a mount that happens later than its caller's.
997
+ // Only where a component stands below this region: nothing else can read it.
998
+ return `const ${name}_mount = (${parameters}, __rebuilt) => {\n${resumes ? insideShare(lowering, SHARE_AT, mount) : mount}\n}`
999
+ }
1000
+
1001
+ /**
1002
+ * Emits a component invocation's client mount: the child mounting itself against its region.
1003
+ *
1004
+ * 32.17 ON THE CLIENT — the child mounts ITSELF, against the region its markup was written into.
1005
+ * The parent hands over the same accessors it handed the server emitter (33.5), so the prop is the
1006
+ * caller's expression on both sides and the child re-reads it when the parent's value moves.
1007
+ *
1008
+ * THE CHILD'S MOUNT IS ITS OWN MODULE'S. `import Total from './Total.abide'` is the default export
1009
+ * of the client module that file compiled to (`splitImports`), so the binding the author wrote
1010
+ * is the function called here — the parent emits no copy of the child's bindings, and a child
1011
+ * changed in place is re-emitted alone.
1012
+ */
1013
+ function emitInvocation(
1014
+ at: PlacedNode,
1015
+ node: ElementNode,
1016
+ region: RegionEmission,
1017
+ ): void {
1018
+ const lowering = region.lowering
1019
+ const props = invocationProps(node, lowering)
1020
+ // 32.18 — THE CHILDREN ARE MARKUP AND A MOUNT, and they have to be both: the markup is what
1021
+ // fills a slot the server never painted, and the mount is the CALLER's bindings — which only
1022
+ // this module has, addressed from a region only the child knows where to put.
1023
+ const children = at.inner[0]
1024
+ if (children !== undefined) {
1025
+ const kids = region.claim('kd')
1026
+ emitFillable(kids, children, region)
1027
+ props.push(
1028
+ `${JSON.stringify(CHILDREN)}: () => ({ build: ${kids}_build, mount: ${kids}_mount })`,
1029
+ )
1030
+ }
1031
+ // THE CHILD'S SCOPE IS OWNED. Its bindings live as long as its nodes do, and what removes
1032
+ // those nodes is this region — a row that leaves, an arm that swaps — so the scope that stops
1033
+ // them has to be the one this region holds. Held rather than drained, because a child holding
1034
+ // an arm or a list of its own owns scopes that its disposer list does not reach.
1035
+ //
1036
+ // 14.7 — the call runs the child's setup, and nothing it reads subscribes a caller: an arm's
1037
+ // swap and a list's rows both mount untracked (`ArmRegion`, `updateList`).
1038
+ const chosen = lowering.chosenTag(node)
1039
+ if (chosen === undefined) {
1040
+ region.lines.push(
1041
+ `${SCOPE}.own(${node.tag}(${lowering.use('regionFound')}(${at.name}), { ${props.join(', ')} }))`,
1042
+ )
1043
+ return
1044
+ }
1045
+ // 32.34, 32.35 — A TAG CHOOSING BY A VALUE IS AN `{#if}` WHOSE ARMS ARE COMPONENTS
1046
+ // (`ChosenRegion`): the watch reads which, and the region swaps.
1047
+ const name = region.claim('dc')
1048
+ region.lines.push(`const ${name} = new ${lowering.use('ChosenRegion')}(${lowering.use('regionFound')}(${at.name}), ${SCOPE}, { ${props.join(', ')} }, ${SHARE_AT})
1049
+ ${SCOPE}.watch(() => ${name}.show(${chosen}))`)
1050
+ }
1051
+
1052
+ /**
1053
+ * Emits a `<slot/>`'s client unit: the caller's children, or the child's own fallback.
1054
+ *
1055
+ * 32.18 ON THE CHILD'S SIDE — the position the caller's children render into. Not a watch and not
1056
+ * a swap: whether children were given is fixed at the call site, so this is read once and the
1057
+ * region holds whichever of the two was decided there for the rest of its life.
1058
+ *
1059
+ * THE FALLBACK IS THE CHILD'S OWN, so it is emitted here as an arm is — its markup for a region
1060
+ * nobody painted, its bindings for one somebody did.
1061
+ */
1062
+ function emitSlot(at: PlacedNode, region: RegionEmission): void {
1063
+ const lowering = region.lowering
1064
+ const name = region.claim('sl')
1065
+
1066
+ emitFillable(name, at.inner[0] as Cursor, region)
1067
+
1068
+ // THE EMPTY REGION IS THE ONE THE SERVER DID NOT PAINT — a child built in the browser (32.17)
1069
+ // or a page navigated to (30.7). Filled from whichever side owns what goes there, and then
1070
+ // mounted from the same side, so the markup and the bindings can never come from two.
1071
+ region.lines.push(`const ${name} = ${lowering.use('regionFound')}(${at.name})
1072
+ const ${name}_kids = ${PROPS}[${JSON.stringify(CHILDREN)}] === undefined ? undefined : ${PROPS}[${JSON.stringify(CHILDREN)}]()
1073
+ ${lowering.use('fillEmpty')}(${name}, ${name}_kids === undefined ? ${name}_build : ${name}_kids.build)
1074
+ ${SCOPE}.own(${name}_kids === undefined ? ${name}_mount(${name}) : ${name}_kids.mount(${name}))`)
1075
+ }
1076
+
1077
+ /**
1078
+ * Emits an `{#if}` chain's client unit, which hydrates the arm the server rendered.
1079
+ *
1080
+ * 32.12 — one arm renders. The SERVER already rendered one, so the first run HYDRATES it rather
1081
+ * than replacing it: a page that re-renders every region on load creates every node twice and
1082
+ * throws away the document it was sent. The condition is evaluated once a run, the first run
1083
+ * included — the arm hydrated is the arm the watch then compares against.
1084
+ */
1085
+ function emitBlock(
1086
+ at: PlacedNode,
1087
+ block: Extract<TemplateNode, { kind: 'block'; block: 'if' }>,
1088
+ region: RegionEmission,
1089
+ ): void {
1090
+ const lowering = region.lowering
1091
+ const name = region.claim('rg')
1092
+
1093
+ // `{:else}` carries no condition and is the floor; with no `{:else}` the floor is one arm past
1094
+ // the last, which builds nothing and binds nothing.
1095
+ const floor = block.branches.at(-1)?.subject !== ''
1096
+ const take = chosenArm(
1097
+ block.branches,
1098
+ lowering,
1099
+ String,
1100
+ String(block.branches.length),
1101
+ )
1102
+ const mounted = emitArms(
1103
+ name,
1104
+ at,
1105
+ region,
1106
+ undefined,
1107
+ block.branches.map((branch) => branch.setup),
1108
+ floor,
1109
+ )
1110
+ // ONE UNIT: `${name}` is read by the watch below, and a caller that guards its units apart
1111
+ // (`emitClient`) would put a `const` in one block and its only reader in the next. Every name a
1112
+ // unit declares is read inside it — that is what makes a unit independent, and it is the
1113
+ // property the page's per-binding guard rests on. What a swap does is `ArmRegion`'s.
1114
+ //
1115
+ // 14.2 — A CHAIN WHOSE EVERY SUBJECT IS PROVEN STATIC IS DECIDED ONCE, outside any watch: the arm
1116
+ // it takes can never change, and a watch over it is a reader that can never wake. Unproven, the
1117
+ // watch stays, and tracking decides what it reads.
1118
+ const show = `${name}.show(${take})`
1119
+ region.lines.push(`const ${name} = new ${lowering.use('ArmRegion')}(${lowering.use('regionFound')}(${at.name}), ${SCOPE}, ${name}_arms, ${mounted})
1120
+ ${lowering.isLiveChain(block.branches) ? `${SCOPE}.watch(() => ${show})` : show}`)
1121
+ }
1122
+
1123
+ /**
1124
+ * Emits a `{#try}` block's client unit: the body until something in it fails, then the catch.
1125
+ *
1126
+ * 32.16 — A `{#try}` TAKES ITS BODY UNTIL SOMETHING IN IT FAILS, and its catch from then until the
1127
+ * failure clears. The boundary is the region's, and the catch reads the failure by the name the
1128
+ * author bound. Two arms, so the arm taken is `0` or `1` and never the `{#if}` floor.
1129
+ */
1130
+ function emitTry(
1131
+ at: PlacedNode,
1132
+ block: Extract<TemplateNode, { kind: 'block'; block: 'try' }>,
1133
+ region: RegionEmission,
1134
+ ): void {
1135
+ const lowering = region.lowering
1136
+ const name = region.claim('rg')
1137
+ // HANDED IN, not read off the boundary: the arms are hoisted where the region's own names are
1138
+ // out of reach, and each instance has a failure of its own. The catch's binding is its setup.
1139
+ emitArms(
1140
+ name,
1141
+ at,
1142
+ region,
1143
+ block.error === '' ? '' : `const ${block.error} = __caught`,
1144
+ undefined,
1145
+ false,
1146
+ )
1147
+
1148
+ // ONE UNIT, for `emitBlock`'s reason. What the body and the catch do is `TryRegion`'s.
1149
+ region.lines.push(`const ${name} = new ${lowering.use('TryRegion')}(${lowering.use('regionFound')}(${at.name}), ${SCOPE}, ${name}_arms)
1150
+ ${SCOPE}.watch(() => ${name}.follow())`)
1151
+ }
1152
+
1153
+ /**
1154
+ * Emits a block's arm builders into `helpers`; returns whether any arm has a mount.
1155
+ *
1156
+ * A BLOCK'S ARMS, each set up the way `List.setUp` sets up a row: `${name}_arms[arm]` is called once
1157
+ * each time that arm is swapped in, and answers the arm's `{ build, mount }`. An arm with a setup of
1158
+ * its own — a branch-local `<script>` (14.8), or the `{#try}` catch's binding of the failure it is
1159
+ * handed — declares its builder and mount after it, so both close over its names; every other arm
1160
+ * answers the one record built with the region. With `floor`, one more arm past the last builds
1161
+ * nothing and binds nothing: the `{#if}` with no `{:else}` and no subject true.
1162
+ */
1163
+ function emitArms(
1164
+ name: string,
1165
+ at: PlacedNode,
1166
+ region: RegionEmission,
1167
+ /** The `{#try}` catch's binding, `''` where it binds no name; `undefined` for an `{#if}`. */
1168
+ caught: string | undefined,
1169
+ /** 14.8 — each `{#if}` arm's branch-local `<script>`, or `null`. */
1170
+ setups: readonly (Setup | null)[] | undefined,
1171
+ floor: boolean,
1172
+ ): boolean {
1173
+ const lowering = region.lowering
1174
+ const helpers = region.helpers
1175
+ const fillRegion = lowering.use('fillRegion')
1176
+ const arms: string[] = []
1177
+ // A `{#try}` always mounts: its catch binds the failure, and its body mounts under the boundary.
1178
+ let mounted = caught !== undefined
1179
+ for (let arm = 0; arm < at.inner.length; arm += 1) {
1180
+ const sink = at.inner[arm] as Cursor
1181
+ const own = `${name}_a${arm}`
1182
+ // A NESTED REGION'S HELPERS BELONG TO THE SCOPE THAT OWNS THEM. Hoisted to `mount` they
1183
+ // read names this arm binds and nothing else does, which is a ReferenceError at the first
1184
+ // swap rather than at compile time. AND SO DOES ITS WALK, for the same reason: each arm's
1185
+ // mount is a function of its own, so two arms may name a slot `__c0` and neither can see
1186
+ // the other's.
1187
+ const body = emitRegion(sink, region.nested()).body()
1188
+ if (body.length > 0) mounted = true
1189
+ const setup = setups?.[arm] ?? null
1190
+ // 12.13 — AN ARM WITH A `<script>` HAS SOMETHING TO STOP even where it binds nothing: the
1191
+ // watches that script opened, in the scope its mount answers to the block.
1192
+ if (setup !== null) mounted = true
1193
+ const local =
1194
+ setup !== null
1195
+ ? lowering.setup(setup)
1196
+ : arm === 1 && caught !== undefined
1197
+ ? caught
1198
+ : ''
1199
+ const builders = `const ${own}_build = function (__document) {\n${emitMaker(sink, lowering)}\n}\n${mountFunction(own, REGION_ROOT, body, `${fillRegion}(${REGION_ROOT}, ${own}_build)`, lowering, sink.defersSetup, setup !== null)}`
1200
+ if (local === '') {
1201
+ helpers.push(
1202
+ `${builders}\nconst ${own}_arm = { build: ${own}_build, mount: ${own}_mount }`,
1203
+ )
1204
+ arms.push(`() => ${own}_arm`)
1205
+ } else if (setup === null)
1206
+ arms.push(
1207
+ `(__caught) => {\n${local}\n${builders}\nreturn { build: ${own}_build, mount: ${own}_mount }\n}`,
1208
+ )
1209
+ else {
1210
+ const owning = scopedSetup(local, lowering, true)
1211
+ arms.push(
1212
+ `(__caught) => {\n${owning.opened}${local}\n${owning.handed}${builders}\nreturn { build: ${own}_build, mount: ${own}_mount }${owning.closed}\n}`,
1213
+ )
1214
+ }
1215
+ }
1216
+ if (floor) {
1217
+ helpers.push(
1218
+ `const ${name}_floor = { build: undefined, mount: () => ${lowering.use('EMPTY_SCOPE')} }`,
1219
+ )
1220
+ arms.push(`() => ${name}_floor`)
1221
+ }
1222
+ helpers.push(`const ${name}_arms = [\n${arms.join(',\n')}\n]`)
1223
+ return mounted
1224
+ }
1225
+
1226
+ /**
1227
+ * Emits a `{#for}` list's client unit, which hydrates the rows the server rendered.
1228
+ *
1229
+ * 32.13 — the list. The server already rendered the rows, so the first update HYDRATES them:
1230
+ * every row's element is already in the document and only its bindings are missing. Only a change
1231
+ * to the list reconciles, and only the rows that moved move.
1232
+ *
1233
+ * 32.21 — the subject is read ONCE for the block. 32.22 — an absent subject iterates zero times.
1234
+ */
1235
+ function emitList(
1236
+ position: PlacedNode,
1237
+ block: ForBlock,
1238
+ region: RegionEmission,
1239
+ ): void {
1240
+ const lowering = region.lowering
1241
+ const name = region.claim('ls')
1242
+
1243
+ const row = position.inner[0] as Cursor
1244
+ const subject = lowering.expression(block)
1245
+ // THE ROW BINDS ITS OWN NAME. Every emitted row function takes the author's item and index as
1246
+ // its parameters, so the body's expressions read exactly what the author wrote and nothing
1247
+ // rewrites already-emitted source — a rename by regex reaches inside static text and cannot
1248
+ // reach a nested region's helper at all.
1249
+ const item = block.item
1250
+ const at = block.index === '' ? '__at' : block.index
1251
+ // 41.8 — with no `by`, the key is the POSITION, which is 32.13's positional reconcile: a row
1252
+ // is whatever is in that slot, and a reorder rewrites the rows rather than moving them.
1253
+ // 31.10 — the item and the index SHADOW the page's names for the row, and the projection is
1254
+ // what says so: they are a `for … of` binding there, so no read in the body or the key reaches
1255
+ // the page's name of the same spelling.
1256
+ const written = `(${item}, ${at}) => ${block.key === '' ? at : lowering.key(block)}`
1257
+ // 32.32 — ONLY A NAME ALONE hands the list its `Reactive`. Any other subject is a value computed
1258
+ // from one, which declared no `by` of its own, and evaluating it a second time to ask would run
1259
+ // the computation twice. `reference` keeps the name the `Reactive` (31.3) rather than a read.
1260
+ const key =
1261
+ block.key === '' && isNamedAlone(block.subject.trim())
1262
+ ? `${lowering.use('rowKeyOf')}(${lowering.reference(block)}, ${written})`
1263
+ : written
1264
+
1265
+ const single = isSingleRooted(block.children)
1266
+
1267
+ const rowRegion = emitRegion(row, region.nested())
1268
+
1269
+ // `List` hands the row its document — see `emitMaker` for which rows are parsed instead.
1270
+ const make = `const ${name}_make = (__document, ${item}, ${at}) => {\n ${emitMaker(row, lowering, () => rowMarkup(row, !single, lowering, CLIENT_LANE), !single)}\n}`
1271
+
1272
+ // A row that cannot be hydrated is REBUILT by the same `make`, in place, and the row's record
1273
+ // takes its new first node.
1274
+ const builders = [
1275
+ make,
1276
+ mountFunction(
1277
+ name,
1278
+ `${ROW_ROOT}, ${item}, ${at}`,
1279
+ // The row's walk, INSIDE the mount's one `try` rather than above it, because a row
1280
+ // rebuilds whole: a node that refused is the row disagreeing, and re-making it is the
1281
+ // answer the page does not have.
1282
+ rowRegion.body(),
1283
+ `${lowering.use('replaceRow')}(${ROW_ROOT}, ${name}_make(${ROW_ROOT}.node.ownerDocument, ${item}, ${at}))`,
1284
+ lowering,
1285
+ row.defersSetup,
1286
+ block.setup !== null,
1287
+ ),
1288
+ ].join('\n')
1289
+ // THE LIST CALLS `_setUp` ONCE PER ROW (`List.setUp`). 14.8 — a row with a branch-local
1290
+ // `<script>` runs it there, and the row's `make` and `mount` are declared after it, so both close
1291
+ // over its names and neither runs it again. Every other row gets the list's one record back.
1292
+ region.helpers.push(
1293
+ [
1294
+ // What the subject iterates as is `listOf`'s question, asked inside the runtime.
1295
+ `const ${name}_subject = () => ${subject}`,
1296
+ `const ${name}_key = ${key}`,
1297
+ block.setup !== null
1298
+ ? rowSetUp(
1299
+ name,
1300
+ item,
1301
+ at,
1302
+ lowering.setup(block.setup),
1303
+ builders,
1304
+ lowering,
1305
+ )
1306
+ : `${builders}\nconst ${name}_builders = { make: ${name}_make, mount: ${name}_mount }\nconst ${name}_setUp = () => ${name}_builders`,
1307
+ ].join('\n'),
1308
+ )
1309
+
1310
+ // ONE UNIT, for `emitBlock`'s reason: the list's region and the `List` built over it are both
1311
+ // read by the watch, so the three lines cannot be guarded apart.
1312
+ // OWNED BY THE REGION ABOVE IT: `dropRow` stops a row as the list churns, but a block removed
1313
+ // whole drops no rows, so `List.stop` is what reaches the ones still standing.
1314
+ region.lines.push(
1315
+ `const ${name} = ${lowering.use('regionFound')}(${position.name})
1316
+ const ${name}_list = ${SCOPE}.own(${lowering.use('listAt')}(${name}, ${single ? 'false' : 'true'}, ${name}_key, ${name}_setUp))
1317
+ ${SCOPE}.watch(() => ${lowering.use('updateList')}(${name}_list, ${name}_subject()))`,
1318
+ )
1319
+ }
1320
+
1321
+ /**
1322
+ * A row's `_setUp` where the row has a branch-local `<script>` (14.8): runs it once for the row,
1323
+ * and answers the builders that close over its names.
1324
+ *
1325
+ * 12.13 — the watches the script opened are the row's, in the scope its mount binds into.
1326
+ */
1327
+ function rowSetUp(
1328
+ name: string,
1329
+ item: string,
1330
+ at: string,
1331
+ local: string,
1332
+ builders: string,
1333
+ lowering: Lowering,
1334
+ ): string {
1335
+ const owning = scopedSetup(local, lowering, true)
1336
+ // The mount takes the setUp's own item and index again, shadowing them with the same values, so
1337
+ // the row record `List` hands in is the only thing that is new.
1338
+ return `const ${name}_setUp = (${item}, ${at}) => {
1339
+ ${owning.opened}${local}
1340
+ ${owning.handed}${builders}
1341
+ return { make: ${name}_make, mount: ${name}_mount }${owning.closed}
1342
+ }`
1343
+ }