@abide/abide 0.28.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 (562) hide show
  1. package/CHANGELOG.md +607 -0
  2. package/LICENSE +21 -0
  3. package/README.md +154 -0
  4. package/bin/abide.ts +212 -0
  5. package/package.json +155 -0
  6. package/src/abideLsp.ts +211 -0
  7. package/src/abideModules.d.ts +8 -0
  8. package/src/abideResolverPlugin.ts +923 -0
  9. package/src/appEntry.ts +151 -0
  10. package/src/assets/app.html +12 -0
  11. package/src/build.ts +143 -0
  12. package/src/buildCli.ts +127 -0
  13. package/src/buildDisconnected.ts +118 -0
  14. package/src/bundleApp.ts +147 -0
  15. package/src/bundleDisconnectedEntry.ts +14 -0
  16. package/src/checkAbide.ts +77 -0
  17. package/src/cliEntry.ts +25 -0
  18. package/src/clientBuildPlugins.ts +33 -0
  19. package/src/clientEntry.ts +17 -0
  20. package/src/compile.ts +63 -0
  21. package/src/controlServerWorker.ts +426 -0
  22. package/src/devEntry.ts +250 -0
  23. package/src/discoveryEntry.ts +81 -0
  24. package/src/lib/bundle/BundleMenu.ts +12 -0
  25. package/src/lib/bundle/BundleMenuItem.ts +25 -0
  26. package/src/lib/bundle/BundleWindow.ts +37 -0
  27. package/src/lib/bundle/WEBVIEW_BUILD_REVISION.ts +9 -0
  28. package/src/lib/bundle/WEBVIEW_VERSION.ts +7 -0
  29. package/src/lib/bundle/bindConnectedFlag.ts +29 -0
  30. package/src/lib/bundle/bindRequestNavigate.ts +34 -0
  31. package/src/lib/bundle/buildWebviewLib.ts +111 -0
  32. package/src/lib/bundle/bundled.ts +35 -0
  33. package/src/lib/bundle/disconnected.abide +236 -0
  34. package/src/lib/bundle/disconnected.css +9 -0
  35. package/src/lib/bundle/ensureWebviewLib.ts +20 -0
  36. package/src/lib/bundle/exitWithParent.ts +28 -0
  37. package/src/lib/bundle/infoPlist.ts +46 -0
  38. package/src/lib/bundle/installDownloads.ts +24 -0
  39. package/src/lib/bundle/installMacMenu.ts +39 -0
  40. package/src/lib/bundle/listenLocalControlServer.ts +19 -0
  41. package/src/lib/bundle/native/abideMenu.mm +422 -0
  42. package/src/lib/bundle/native/webview.h +4557 -0
  43. package/src/lib/bundle/onMenu.ts +42 -0
  44. package/src/lib/bundle/openWebview.ts +104 -0
  45. package/src/lib/bundle/pngToIcns.ts +47 -0
  46. package/src/lib/bundle/probeAbideServer.ts +57 -0
  47. package/src/lib/bundle/resolveServerBinary.ts +12 -0
  48. package/src/lib/bundle/resolveWebviewLib.ts +53 -0
  49. package/src/lib/bundle/serverBinaryFilename.ts +8 -0
  50. package/src/lib/bundle/signMacApp.ts +37 -0
  51. package/src/lib/bundle/spawnEmbeddedServer.ts +64 -0
  52. package/src/lib/bundle/stableLocalPort.ts +19 -0
  53. package/src/lib/bundle/waitForServer.ts +23 -0
  54. package/src/lib/bundle/webviewCachePath.ts +23 -0
  55. package/src/lib/bundle/webviewLibName.ts +11 -0
  56. package/src/lib/cli/connectToServer.ts +23 -0
  57. package/src/lib/cli/createClient.ts +108 -0
  58. package/src/lib/cli/dispatchCommand.ts +71 -0
  59. package/src/lib/cli/loadEnvFromBinaryDir.ts +15 -0
  60. package/src/lib/cli/parseArgvForRpc.ts +100 -0
  61. package/src/lib/cli/printHelp.ts +119 -0
  62. package/src/lib/cli/printSessionHelp.ts +27 -0
  63. package/src/lib/cli/printSessionStatus.ts +21 -0
  64. package/src/lib/cli/printTrimmed.ts +8 -0
  65. package/src/lib/cli/printValue.ts +10 -0
  66. package/src/lib/cli/resolveCliTarget.ts +48 -0
  67. package/src/lib/cli/runCli.ts +176 -0
  68. package/src/lib/cli/runSession.ts +108 -0
  69. package/src/lib/cli/startLocalInstance.ts +14 -0
  70. package/src/lib/cli/tokenizeLine.ts +51 -0
  71. package/src/lib/cli/types/CliManifest.ts +9 -0
  72. package/src/lib/cli/types/CliManifestEntry.ts +17 -0
  73. package/src/lib/cli/types/CliTarget.ts +13 -0
  74. package/src/lib/mcp/annotationsForMethod.ts +29 -0
  75. package/src/lib/mcp/createMcpResourceServer.ts +102 -0
  76. package/src/lib/mcp/createMcpServer.ts +48 -0
  77. package/src/lib/mcp/dispatchMcpRequest.ts +138 -0
  78. package/src/lib/mcp/mcpResourceServerSlot.ts +18 -0
  79. package/src/lib/mcp/mcpSurface.ts +295 -0
  80. package/src/lib/mcp/toolResultFromResponse.ts +66 -0
  81. package/src/lib/mcp/types/JsonRpcRequest.ts +12 -0
  82. package/src/lib/mcp/types/JsonRpcResponse.ts +20 -0
  83. package/src/lib/mcp/types/McpResourceContents.ts +10 -0
  84. package/src/lib/mcp/types/McpResourceDescriptor.ts +6 -0
  85. package/src/lib/mcp/types/McpResourceServer.ts +12 -0
  86. package/src/lib/mcp/types/McpServer.ts +9 -0
  87. package/src/lib/mcp/types/McpServerOptions.ts +16 -0
  88. package/src/lib/server/AppModule.ts +47 -0
  89. package/src/lib/server/DELETE.ts +10 -0
  90. package/src/lib/server/GET.ts +10 -0
  91. package/src/lib/server/HEAD.ts +10 -0
  92. package/src/lib/server/PATCH.ts +10 -0
  93. package/src/lib/server/POST.ts +10 -0
  94. package/src/lib/server/PUT.ts +10 -0
  95. package/src/lib/server/agent.ts +86 -0
  96. package/src/lib/server/appDataDir.ts +16 -0
  97. package/src/lib/server/cli/buildEnvContent.ts +19 -0
  98. package/src/lib/server/cli/createTarGz.ts +77 -0
  99. package/src/lib/server/cli/handleCliDownload.ts +150 -0
  100. package/src/lib/server/cli/handleCliInstall.ts +37 -0
  101. package/src/lib/server/cli/installScript.ts +31 -0
  102. package/src/lib/server/cli/maxSourceMtime.ts +26 -0
  103. package/src/lib/server/cookies.ts +30 -0
  104. package/src/lib/server/env.ts +51 -0
  105. package/src/lib/server/error.ts +73 -0
  106. package/src/lib/server/json.ts +42 -0
  107. package/src/lib/server/jsonl.ts +47 -0
  108. package/src/lib/server/prompts/definePrompt.ts +21 -0
  109. package/src/lib/server/prompts/promptRegistry.ts +9 -0
  110. package/src/lib/server/prompts/registerPrompt.ts +6 -0
  111. package/src/lib/server/prompts/renderPromptTemplate.ts +17 -0
  112. package/src/lib/server/prompts/types/Prompt.ts +13 -0
  113. package/src/lib/server/prompts/types/PromptOptions.ts +12 -0
  114. package/src/lib/server/prompts/types/PromptRegistryEntry.ts +13 -0
  115. package/src/lib/server/prompts/types/PromptRoutes.ts +10 -0
  116. package/src/lib/server/reachable.ts +45 -0
  117. package/src/lib/server/redirect.ts +43 -0
  118. package/src/lib/server/request.ts +19 -0
  119. package/src/lib/server/rpc/defineVerb.ts +210 -0
  120. package/src/lib/server/rpc/dispatchVerbInProcess.ts +46 -0
  121. package/src/lib/server/rpc/findVerbByCommandName.ts +18 -0
  122. package/src/lib/server/rpc/parseArgs.ts +127 -0
  123. package/src/lib/server/rpc/readBodyWithinLimit.ts +44 -0
  124. package/src/lib/server/rpc/registerVerb.ts +6 -0
  125. package/src/lib/server/rpc/runWithVerbTimeout.ts +49 -0
  126. package/src/lib/server/rpc/types/RemoteHandler.ts +27 -0
  127. package/src/lib/server/rpc/types/RemoteRoutes.ts +13 -0
  128. package/src/lib/server/rpc/types/TypedResponse.ts +18 -0
  129. package/src/lib/server/rpc/types/VerbHelper.ts +87 -0
  130. package/src/lib/server/rpc/types/VerbRegistryEntry.ts +35 -0
  131. package/src/lib/server/rpc/unprocessed.ts +14 -0
  132. package/src/lib/server/rpc/verbRegistry.ts +11 -0
  133. package/src/lib/server/runtime/DEFAULT_PORT.ts +6 -0
  134. package/src/lib/server/runtime/DEV_READY_MESSAGE.ts +6 -0
  135. package/src/lib/server/runtime/DEV_REBUILD_MESSAGE.ts +4 -0
  136. package/src/lib/server/runtime/DEV_RELOAD_CLIENT_SCRIPT.ts +107 -0
  137. package/src/lib/server/runtime/SSR_SWAP_SCRIPT.ts +16 -0
  138. package/src/lib/server/runtime/acceptsGzip.ts +24 -0
  139. package/src/lib/server/runtime/buildCacheSnapshot.ts +61 -0
  140. package/src/lib/server/runtime/buildHealthPayload.ts +34 -0
  141. package/src/lib/server/runtime/buildInspectorSurface.ts +37 -0
  142. package/src/lib/server/runtime/buildOpenApiSpec.ts +106 -0
  143. package/src/lib/server/runtime/cacheControlForAsset.ts +22 -0
  144. package/src/lib/server/runtime/containsTraversal.ts +37 -0
  145. package/src/lib/server/runtime/createAppAssetServer.ts +76 -0
  146. package/src/lib/server/runtime/createAssetHeaderCache.ts +31 -0
  147. package/src/lib/server/runtime/createPublicAssetServer.ts +67 -0
  148. package/src/lib/server/runtime/createReachable.ts +109 -0
  149. package/src/lib/server/runtime/createRouteDispatcher.ts +127 -0
  150. package/src/lib/server/runtime/createServer.ts +674 -0
  151. package/src/lib/server/runtime/createUiPageRenderer.ts +181 -0
  152. package/src/lib/server/runtime/crossOriginForbidden.ts +17 -0
  153. package/src/lib/server/runtime/crossOriginGate.ts +29 -0
  154. package/src/lib/server/runtime/devClientFingerprint.ts +117 -0
  155. package/src/lib/server/runtime/devHotModuleResponse.ts +40 -0
  156. package/src/lib/server/runtime/devReloadResponse.ts +41 -0
  157. package/src/lib/server/runtime/disableIdleTimeoutForStream.ts +27 -0
  158. package/src/lib/server/runtime/envSchemaStore.ts +15 -0
  159. package/src/lib/server/runtime/findOpenPort.ts +21 -0
  160. package/src/lib/server/runtime/getActiveServer.ts +6 -0
  161. package/src/lib/server/runtime/globToPathSet.ts +29 -0
  162. package/src/lib/server/runtime/gzipResponse.ts +46 -0
  163. package/src/lib/server/runtime/inProcessServer.ts +20 -0
  164. package/src/lib/server/runtime/internalErrorResponse.ts +25 -0
  165. package/src/lib/server/runtime/isCrossOriginRequest.ts +23 -0
  166. package/src/lib/server/runtime/listenOnOpenPort.ts +36 -0
  167. package/src/lib/server/runtime/logExposedSurfaces.ts +156 -0
  168. package/src/lib/server/runtime/maybeMountInspector.ts +97 -0
  169. package/src/lib/server/runtime/mimeForExtension.ts +14 -0
  170. package/src/lib/server/runtime/pageUrlFromStore.ts +15 -0
  171. package/src/lib/server/runtime/parseIdleTimeout.ts +10 -0
  172. package/src/lib/server/runtime/parsePort.ts +11 -0
  173. package/src/lib/server/runtime/registryManifests.ts +66 -0
  174. package/src/lib/server/runtime/requestContext.ts +5 -0
  175. package/src/lib/server/runtime/resolvePageSnapshot.ts +25 -0
  176. package/src/lib/server/runtime/respondWithEmbeddedAsset.ts +18 -0
  177. package/src/lib/server/runtime/runWithRequestScope.ts +150 -0
  178. package/src/lib/server/runtime/safeJsonForScript.ts +17 -0
  179. package/src/lib/server/runtime/serializeCacheSnapshot.ts +45 -0
  180. package/src/lib/server/runtime/serverSlot.ts +13 -0
  181. package/src/lib/server/runtime/setActiveServer.ts +6 -0
  182. package/src/lib/server/runtime/snapshotEntryFromCache.ts +83 -0
  183. package/src/lib/server/runtime/streamCacheResolutions.ts +37 -0
  184. package/src/lib/server/runtime/streamFromIterator.ts +86 -0
  185. package/src/lib/server/runtime/types/Assets.ts +6 -0
  186. package/src/lib/server/runtime/types/DevReloadStamp.ts +18 -0
  187. package/src/lib/server/runtime/types/InspectorCacheEntry.ts +24 -0
  188. package/src/lib/server/runtime/types/InspectorCacheSnapshot.ts +11 -0
  189. package/src/lib/server/runtime/types/InspectorContext.ts +30 -0
  190. package/src/lib/server/runtime/types/InspectorSocket.ts +17 -0
  191. package/src/lib/server/runtime/types/InspectorSurface.ts +13 -0
  192. package/src/lib/server/runtime/types/InspectorVerb.ts +27 -0
  193. package/src/lib/server/runtime/types/RequestStore.ts +55 -0
  194. package/src/lib/server/runtime/warnUnguardedMcp.ts +32 -0
  195. package/src/lib/server/runtime/withResponseDefaults.ts +24 -0
  196. package/src/lib/server/server.ts +33 -0
  197. package/src/lib/server/socket.ts +32 -0
  198. package/src/lib/server/sockets/createSocketDispatcher.ts +337 -0
  199. package/src/lib/server/sockets/defineSocket.ts +179 -0
  200. package/src/lib/server/sockets/lookupSocket.ts +6 -0
  201. package/src/lib/server/sockets/registerSocket.ts +6 -0
  202. package/src/lib/server/sockets/socketOperations.ts +36 -0
  203. package/src/lib/server/sockets/socketRegistry.ts +9 -0
  204. package/src/lib/server/sockets/types/Socket.ts +23 -0
  205. package/src/lib/server/sockets/types/SocketClientFrame.ts +19 -0
  206. package/src/lib/server/sockets/types/SocketOperation.ts +22 -0
  207. package/src/lib/server/sockets/types/SocketOptions.ts +26 -0
  208. package/src/lib/server/sockets/types/SocketRegistryEntry.ts +19 -0
  209. package/src/lib/server/sockets/types/SocketRoutes.ts +10 -0
  210. package/src/lib/server/sockets/types/SocketServerFrame.ts +24 -0
  211. package/src/lib/server/sse.ts +54 -0
  212. package/src/lib/shared/ABIDE_PACKAGE_NAME.ts +7 -0
  213. package/src/lib/shared/ABIDE_VERSION.ts +9 -0
  214. package/src/lib/shared/CACHE_CONTROL_VALUES.ts +16 -0
  215. package/src/lib/shared/CACHE_WRAPPED.ts +8 -0
  216. package/src/lib/shared/CLI_PATH.ts +7 -0
  217. package/src/lib/shared/DEV_HOT_PREFIX.ts +7 -0
  218. package/src/lib/shared/DEV_RELOAD_PATH.ts +6 -0
  219. package/src/lib/shared/HEALTH_PATH.ts +7 -0
  220. package/src/lib/shared/HttpError.ts +20 -0
  221. package/src/lib/shared/IDENTITY_PATH.ts +6 -0
  222. package/src/lib/shared/INSPECTOR_PATH.ts +7 -0
  223. package/src/lib/shared/NAV_HEADER.ts +8 -0
  224. package/src/lib/shared/OFFLINE_HEADER.ts +8 -0
  225. package/src/lib/shared/REMOTE_FUNCTION.ts +8 -0
  226. package/src/lib/shared/REPLAYABLE_METHODS.ts +12 -0
  227. package/src/lib/shared/SOCKETS_PATH.ts +7 -0
  228. package/src/lib/shared/STREAMING_CONTENT_TYPES.ts +11 -0
  229. package/src/lib/shared/SocketDisconnectedError.ts +13 -0
  230. package/src/lib/shared/TEXT_PLAIN.ts +7 -0
  231. package/src/lib/shared/abideImportName.ts +44 -0
  232. package/src/lib/shared/abideLog.ts +38 -0
  233. package/src/lib/shared/activeCacheStore.ts +20 -0
  234. package/src/lib/shared/activePage.ts +25 -0
  235. package/src/lib/shared/appDataDir.ts +34 -0
  236. package/src/lib/shared/appNameSlot.ts +10 -0
  237. package/src/lib/shared/basePath.ts +10 -0
  238. package/src/lib/shared/basePathFromAppUrl.ts +20 -0
  239. package/src/lib/shared/baseSlot.ts +14 -0
  240. package/src/lib/shared/binaryDirEnvPath.ts +12 -0
  241. package/src/lib/shared/browserClientFlags.ts +10 -0
  242. package/src/lib/shared/buildRpcProxy.ts +39 -0
  243. package/src/lib/shared/buildRpcRequest.ts +70 -0
  244. package/src/lib/shared/buildSocketOverChannel.ts +58 -0
  245. package/src/lib/shared/bundleLayout.ts +36 -0
  246. package/src/lib/shared/cache.ts +951 -0
  247. package/src/lib/shared/cacheEntryFromSnapshot.ts +59 -0
  248. package/src/lib/shared/cacheStoreSlot.ts +16 -0
  249. package/src/lib/shared/cacheStores.ts +10 -0
  250. package/src/lib/shared/canonicalJson.ts +63 -0
  251. package/src/lib/shared/carriesBodyArgs.ts +13 -0
  252. package/src/lib/shared/clearLastConnection.ts +7 -0
  253. package/src/lib/shared/commandNameForUrl.ts +17 -0
  254. package/src/lib/shared/createCacheStore.ts +104 -0
  255. package/src/lib/shared/createChannelLog.ts +122 -0
  256. package/src/lib/shared/createLifecycleChannel.ts +56 -0
  257. package/src/lib/shared/createLivenessWatch.ts +118 -0
  258. package/src/lib/shared/createPushIterator.ts +127 -0
  259. package/src/lib/shared/createRemoteFunction.ts +122 -0
  260. package/src/lib/shared/createSubscriber.ts +55 -0
  261. package/src/lib/shared/createTraceContext.ts +21 -0
  262. package/src/lib/shared/dataDirEnvPath.ts +12 -0
  263. package/src/lib/shared/decodeResponse.ts +47 -0
  264. package/src/lib/shared/detectTarget.ts +27 -0
  265. package/src/lib/shared/detectVerbMethod.ts +17 -0
  266. package/src/lib/shared/emitLogRecord.ts +190 -0
  267. package/src/lib/shared/exeSuffix.ts +9 -0
  268. package/src/lib/shared/exitOnBuildFailure.ts +17 -0
  269. package/src/lib/shared/extraForwardHeaders.ts +16 -0
  270. package/src/lib/shared/fileStem.ts +9 -0
  271. package/src/lib/shared/findExportCallSite.ts +476 -0
  272. package/src/lib/shared/formatTraceparent.ts +6 -0
  273. package/src/lib/shared/forwardHeaders.ts +44 -0
  274. package/src/lib/shared/getRemoteMeta.ts +5 -0
  275. package/src/lib/shared/globalCacheStore.ts +15 -0
  276. package/src/lib/shared/globalCacheStoreSlot.ts +14 -0
  277. package/src/lib/shared/health.ts +179 -0
  278. package/src/lib/shared/healthReadSlot.ts +11 -0
  279. package/src/lib/shared/healthSeedSlot.ts +12 -0
  280. package/src/lib/shared/html.ts +38 -0
  281. package/src/lib/shared/importNamesToStrip.ts +13 -0
  282. package/src/lib/shared/invalidateEvent.ts +11 -0
  283. package/src/lib/shared/invalidateTripwire.ts +40 -0
  284. package/src/lib/shared/isAbideHealthPayload.ts +11 -0
  285. package/src/lib/shared/isCompileTarget.ts +15 -0
  286. package/src/lib/shared/isDebugEnabled.ts +26 -0
  287. package/src/lib/shared/isDebugNegated.ts +19 -0
  288. package/src/lib/shared/isModuleNotFound.ts +16 -0
  289. package/src/lib/shared/isReadOnlyMethod.ts +14 -0
  290. package/src/lib/shared/isReplayableMethod.ts +7 -0
  291. package/src/lib/shared/isStreamingResponse.ts +11 -0
  292. package/src/lib/shared/isSubscribable.ts +15 -0
  293. package/src/lib/shared/jsonSchemaForPromptArguments.ts +29 -0
  294. package/src/lib/shared/jsonSchemaForSchema.ts +39 -0
  295. package/src/lib/shared/jsonlErrorFrame.ts +24 -0
  296. package/src/lib/shared/keyForRemoteCall.ts +29 -0
  297. package/src/lib/shared/keyMatchesPrefix.ts +9 -0
  298. package/src/lib/shared/lastConnectionPath.ts +7 -0
  299. package/src/lib/shared/layoutChainForRoute.ts +22 -0
  300. package/src/lib/shared/loadEnvFile.ts +17 -0
  301. package/src/lib/shared/loadEnvFromDataDir.ts +14 -0
  302. package/src/lib/shared/log.ts +24 -0
  303. package/src/lib/shared/logClosingRecord.ts +28 -0
  304. package/src/lib/shared/logTapSlot.ts +13 -0
  305. package/src/lib/shared/manifestModule.ts +39 -0
  306. package/src/lib/shared/matchesDebugPattern.ts +16 -0
  307. package/src/lib/shared/memoizeByKey.ts +32 -0
  308. package/src/lib/shared/normalizeTarget.ts +10 -0
  309. package/src/lib/shared/online.ts +51 -0
  310. package/src/lib/shared/page.ts +30 -0
  311. package/src/lib/shared/pageSlot.ts +17 -0
  312. package/src/lib/shared/pageUrlForFile.ts +14 -0
  313. package/src/lib/shared/parseBoundedEnvInt.ts +20 -0
  314. package/src/lib/shared/parseDebugPatterns.ts +21 -0
  315. package/src/lib/shared/parseEnv.ts +30 -0
  316. package/src/lib/shared/parsePromptMarkdown.ts +35 -0
  317. package/src/lib/shared/parseRouteSegments.ts +22 -0
  318. package/src/lib/shared/parseTraceparent.ts +26 -0
  319. package/src/lib/shared/pending.ts +30 -0
  320. package/src/lib/shared/prepareRpcModule.ts +59 -0
  321. package/src/lib/shared/prepareSocketModule.ts +49 -0
  322. package/src/lib/shared/probeRegistries.ts +68 -0
  323. package/src/lib/shared/producerKey.ts +32 -0
  324. package/src/lib/shared/programNameForPackage.ts +14 -0
  325. package/src/lib/shared/promptNameForFile.ts +10 -0
  326. package/src/lib/shared/queryStringFromArgs.ts +27 -0
  327. package/src/lib/shared/randomHexId.ts +14 -0
  328. package/src/lib/shared/readEnvFile.ts +15 -0
  329. package/src/lib/shared/readLastConnection.ts +18 -0
  330. package/src/lib/shared/readPackageJson.ts +9 -0
  331. package/src/lib/shared/recordRemoteMeta.ts +5 -0
  332. package/src/lib/shared/refreshing.ts +31 -0
  333. package/src/lib/shared/remoteMetaStore.ts +16 -0
  334. package/src/lib/shared/requestScopeSlot.ts +15 -0
  335. package/src/lib/shared/resolveClientFlags.ts +20 -0
  336. package/src/lib/shared/responseErrorText.ts +9 -0
  337. package/src/lib/shared/rpcTimeoutSlot.ts +9 -0
  338. package/src/lib/shared/rpcUrlForFile.ts +19 -0
  339. package/src/lib/shared/runningAsStandaloneBinary.ts +13 -0
  340. package/src/lib/shared/selectorMatcher.ts +68 -0
  341. package/src/lib/shared/selectorPrefix.ts +39 -0
  342. package/src/lib/shared/serializeEnv.ts +18 -0
  343. package/src/lib/shared/setAppName.ts +5 -0
  344. package/src/lib/shared/setBaseResolver.ts +6 -0
  345. package/src/lib/shared/setCacheStoreResolver.ts +6 -0
  346. package/src/lib/shared/setGlobalCacheStoreResolver.ts +6 -0
  347. package/src/lib/shared/setPageResolver.ts +7 -0
  348. package/src/lib/shared/setRequestScopeResolver.ts +6 -0
  349. package/src/lib/shared/snippet.ts +25 -0
  350. package/src/lib/shared/socketNameForFile.ts +11 -0
  351. package/src/lib/shared/socketTapSlot.ts +12 -0
  352. package/src/lib/shared/sseErrorFrame.ts +29 -0
  353. package/src/lib/shared/streamResponse.ts +169 -0
  354. package/src/lib/shared/stripImport.ts +27 -0
  355. package/src/lib/shared/subscribableFromResponse.ts +51 -0
  356. package/src/lib/shared/tailProbeSlot.ts +16 -0
  357. package/src/lib/shared/toBunRoutePattern.ts +28 -0
  358. package/src/lib/shared/toScopeSet.ts +4 -0
  359. package/src/lib/shared/trace.ts +16 -0
  360. package/src/lib/shared/types/CacheEntry.ts +84 -0
  361. package/src/lib/shared/types/CacheInvalidation.ts +9 -0
  362. package/src/lib/shared/types/CacheOnContext.ts +25 -0
  363. package/src/lib/shared/types/CacheOptions.ts +39 -0
  364. package/src/lib/shared/types/CacheSelector.ts +17 -0
  365. package/src/lib/shared/types/CacheSnapshot.ts +16 -0
  366. package/src/lib/shared/types/CacheSnapshotEntry.ts +17 -0
  367. package/src/lib/shared/types/CacheStats.ts +13 -0
  368. package/src/lib/shared/types/CacheStore.ts +39 -0
  369. package/src/lib/shared/types/ChannelLog.ts +13 -0
  370. package/src/lib/shared/types/ClientFlags.ts +11 -0
  371. package/src/lib/shared/types/CompileTarget.ts +6 -0
  372. package/src/lib/shared/types/FrameworkLog.ts +13 -0
  373. package/src/lib/shared/types/HttpVerb.ts +1 -0
  374. package/src/lib/shared/types/LastConnection.ts +9 -0
  375. package/src/lib/shared/types/Log.ts +13 -0
  376. package/src/lib/shared/types/LogRecord.ts +42 -0
  377. package/src/lib/shared/types/LogVoice.ts +7 -0
  378. package/src/lib/shared/types/PageSnapshot.ts +14 -0
  379. package/src/lib/shared/types/PromptArgument.ts +12 -0
  380. package/src/lib/shared/types/RawRemoteFunction.ts +14 -0
  381. package/src/lib/shared/types/RemoteCallable.ts +12 -0
  382. package/src/lib/shared/types/RemoteFunction.ts +47 -0
  383. package/src/lib/shared/types/ReplayableMethod.ts +7 -0
  384. package/src/lib/shared/types/RequestScopeInfo.ts +16 -0
  385. package/src/lib/shared/types/RpcInvoker.ts +6 -0
  386. package/src/lib/shared/types/SocketChannel.ts +17 -0
  387. package/src/lib/shared/types/SocketSubCallbacks.ts +13 -0
  388. package/src/lib/shared/types/StandardSchemaV1.ts +56 -0
  389. package/src/lib/shared/types/StreamedResolution.ts +10 -0
  390. package/src/lib/shared/types/Subscribable.ts +26 -0
  391. package/src/lib/shared/types/TailHooks.ts +12 -0
  392. package/src/lib/shared/types/TailOptions.ts +10 -0
  393. package/src/lib/shared/types/TraceContext.ts +17 -0
  394. package/src/lib/shared/url.ts +118 -0
  395. package/src/lib/shared/withBase.ts +11 -0
  396. package/src/lib/shared/withBaseUrl.ts +17 -0
  397. package/src/lib/shared/withJsonSchema.ts +21 -0
  398. package/src/lib/shared/writeDts.ts +12 -0
  399. package/src/lib/shared/writeHealthDts.ts +36 -0
  400. package/src/lib/shared/writeLastConnection.ts +13 -0
  401. package/src/lib/shared/writePublicAssetsDts.ts +31 -0
  402. package/src/lib/shared/writeRoutesDts.ts +73 -0
  403. package/src/lib/shared/writeRpcDts.ts +49 -0
  404. package/src/lib/shared/writeTestRpcDts.ts +45 -0
  405. package/src/lib/shared/writeTestSocketsDts.ts +34 -0
  406. package/src/lib/test/assertAgentFrameConformance.ts +73 -0
  407. package/src/lib/test/createScriptedSurface.ts +45 -0
  408. package/src/lib/test/createTestApp.ts +203 -0
  409. package/src/lib/test/createTestSocketChannel.ts +142 -0
  410. package/src/lib/ui/README.md +86 -0
  411. package/src/lib/ui/compile/SSR_ESCAPE.ts +25 -0
  412. package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +36 -0
  413. package/src/lib/ui/compile/VOID_TAGS.ts +21 -0
  414. package/src/lib/ui/compile/abideUiPlugin.ts +65 -0
  415. package/src/lib/ui/compile/analyzeComponent.ts +117 -0
  416. package/src/lib/ui/compile/assetModulesFile.ts +32 -0
  417. package/src/lib/ui/compile/branchElements.ts +50 -0
  418. package/src/lib/ui/compile/collectAbideDiagnostics.ts +59 -0
  419. package/src/lib/ui/compile/compileComponent.ts +20 -0
  420. package/src/lib/ui/compile/compileModule.ts +116 -0
  421. package/src/lib/ui/compile/compileSSR.ts +36 -0
  422. package/src/lib/ui/compile/compileShadow.ts +352 -0
  423. package/src/lib/ui/compile/createShadowLanguageService.ts +197 -0
  424. package/src/lib/ui/compile/createShadowProgram.ts +96 -0
  425. package/src/lib/ui/compile/decodeHtmlEntities.ts +49 -0
  426. package/src/lib/ui/compile/desugarSignals.ts +133 -0
  427. package/src/lib/ui/compile/escapeHtml.ts +15 -0
  428. package/src/lib/ui/compile/generateBuild.ts +638 -0
  429. package/src/lib/ui/compile/generateSSR.ts +380 -0
  430. package/src/lib/ui/compile/groupBindParts.ts +28 -0
  431. package/src/lib/ui/compile/hoistCells.ts +120 -0
  432. package/src/lib/ui/compile/loadShadowTsConfig.ts +31 -0
  433. package/src/lib/ui/compile/lowerDocAccess.ts +202 -0
  434. package/src/lib/ui/compile/nearestProjectRoot.ts +16 -0
  435. package/src/lib/ui/compile/parseTemplate.ts +396 -0
  436. package/src/lib/ui/compile/partitionSlots.ts +36 -0
  437. package/src/lib/ui/compile/prepareNestedScript.ts +42 -0
  438. package/src/lib/ui/compile/remapShadowDiagnostic.ts +30 -0
  439. package/src/lib/ui/compile/renameSignalRefs.ts +85 -0
  440. package/src/lib/ui/compile/resolveAbideImports.ts +29 -0
  441. package/src/lib/ui/compile/scopeCss.ts +115 -0
  442. package/src/lib/ui/compile/shadowNaming.ts +11 -0
  443. package/src/lib/ui/compile/sourceToShadowOffset.ts +24 -0
  444. package/src/lib/ui/compile/staticAttrValue.ts +13 -0
  445. package/src/lib/ui/compile/stripEffects.ts +32 -0
  446. package/src/lib/ui/compile/types/AbideDiagnostic.ts +14 -0
  447. package/src/lib/ui/compile/types/AnalyzedComponent.ts +25 -0
  448. package/src/lib/ui/compile/types/CompiledShadow.ts +15 -0
  449. package/src/lib/ui/compile/types/TemplateAttr.ts +16 -0
  450. package/src/lib/ui/compile/types/TemplateNode.ts +78 -0
  451. package/src/lib/ui/compile/types/TextPart.ts +8 -0
  452. package/src/lib/ui/derived.ts +28 -0
  453. package/src/lib/ui/doc.ts +15 -0
  454. package/src/lib/ui/dom/appendSnippet.ts +34 -0
  455. package/src/lib/ui/dom/appendStatic.ts +27 -0
  456. package/src/lib/ui/dom/appendText.ts +114 -0
  457. package/src/lib/ui/dom/applyResolved.ts +72 -0
  458. package/src/lib/ui/dom/attach.ts +20 -0
  459. package/src/lib/ui/dom/attr.ts +19 -0
  460. package/src/lib/ui/dom/awaitBlock.ts +224 -0
  461. package/src/lib/ui/dom/cloneStatic.ts +52 -0
  462. package/src/lib/ui/dom/each.ts +115 -0
  463. package/src/lib/ui/dom/eachAsync.ts +153 -0
  464. package/src/lib/ui/dom/hydrate.ts +35 -0
  465. package/src/lib/ui/dom/mount.ts +29 -0
  466. package/src/lib/ui/dom/mountChild.ts +33 -0
  467. package/src/lib/ui/dom/on.ts +15 -0
  468. package/src/lib/ui/dom/openChild.ts +22 -0
  469. package/src/lib/ui/dom/openRoot.ts +20 -0
  470. package/src/lib/ui/dom/switchBlock.ts +75 -0
  471. package/src/lib/ui/dom/text.ts +20 -0
  472. package/src/lib/ui/dom/tryBlock.ts +112 -0
  473. package/src/lib/ui/dom/types/EachRow.ts +3 -0
  474. package/src/lib/ui/dom/types/SwitchCase.ts +6 -0
  475. package/src/lib/ui/dom/when.ts +73 -0
  476. package/src/lib/ui/effect.ts +16 -0
  477. package/src/lib/ui/installHotBridge.ts +73 -0
  478. package/src/lib/ui/matchRoute.ts +89 -0
  479. package/src/lib/ui/navigate.ts +17 -0
  480. package/src/lib/ui/probeNavigation.ts +33 -0
  481. package/src/lib/ui/remoteProxy.ts +97 -0
  482. package/src/lib/ui/renderChain.ts +50 -0
  483. package/src/lib/ui/renderToStream.ts +104 -0
  484. package/src/lib/ui/router.ts +286 -0
  485. package/src/lib/ui/runtime/OUTLET_TAG.ts +8 -0
  486. package/src/lib/ui/runtime/OWNER.ts +8 -0
  487. package/src/lib/ui/runtime/REACTIVE_CONTEXT.ts +14 -0
  488. package/src/lib/ui/runtime/RENDER.ts +23 -0
  489. package/src/lib/ui/runtime/RESUME.ts +16 -0
  490. package/src/lib/ui/runtime/applyPatchToTree.ts +41 -0
  491. package/src/lib/ui/runtime/claimChild.ts +10 -0
  492. package/src/lib/ui/runtime/clientPage.ts +16 -0
  493. package/src/lib/ui/runtime/createComputedNode.ts +16 -0
  494. package/src/lib/ui/runtime/createDoc.ts +177 -0
  495. package/src/lib/ui/runtime/createEffectNode.ts +58 -0
  496. package/src/lib/ui/runtime/createSignalNode.ts +16 -0
  497. package/src/lib/ui/runtime/detachLink.ts +21 -0
  498. package/src/lib/ui/runtime/endTracking.ts +24 -0
  499. package/src/lib/ui/runtime/enterRenderPass.ts +12 -0
  500. package/src/lib/ui/runtime/exitRenderPass.ts +7 -0
  501. package/src/lib/ui/runtime/firstOutlet.ts +22 -0
  502. package/src/lib/ui/runtime/flushEffects.ts +17 -0
  503. package/src/lib/ui/runtime/hotInstances.ts +10 -0
  504. package/src/lib/ui/runtime/hotReloadEnabled.ts +8 -0
  505. package/src/lib/ui/runtime/hotReplace.ts +25 -0
  506. package/src/lib/ui/runtime/nextBlockId.ts +11 -0
  507. package/src/lib/ui/runtime/pathExists.ts +23 -0
  508. package/src/lib/ui/runtime/readNode.ts +17 -0
  509. package/src/lib/ui/runtime/registerHotInstance.ts +23 -0
  510. package/src/lib/ui/runtime/runNode.ts +28 -0
  511. package/src/lib/ui/runtime/runtimePath.ts +9 -0
  512. package/src/lib/ui/runtime/scope.ts +24 -0
  513. package/src/lib/ui/runtime/toTeardown.ts +26 -0
  514. package/src/lib/ui/runtime/track.ts +58 -0
  515. package/src/lib/ui/runtime/trigger.ts +44 -0
  516. package/src/lib/ui/runtime/types/Cell.ts +5 -0
  517. package/src/lib/ui/runtime/types/Derived.ts +3 -0
  518. package/src/lib/ui/runtime/types/Doc.ts +19 -0
  519. package/src/lib/ui/runtime/types/EffectResult.ts +10 -0
  520. package/src/lib/ui/runtime/types/HotInstance.ts +14 -0
  521. package/src/lib/ui/runtime/types/NavVerdict.ts +9 -0
  522. package/src/lib/ui/runtime/types/Patch.ts +11 -0
  523. package/src/lib/ui/runtime/types/ReactiveLink.ts +21 -0
  524. package/src/lib/ui/runtime/types/ReactiveNode.ts +25 -0
  525. package/src/lib/ui/runtime/types/Route.ts +8 -0
  526. package/src/lib/ui/runtime/types/RouteLoader.ts +7 -0
  527. package/src/lib/ui/runtime/types/SsrRender.ts +22 -0
  528. package/src/lib/ui/runtime/types/State.ts +3 -0
  529. package/src/lib/ui/runtime/types/Teardown.ts +5 -0
  530. package/src/lib/ui/runtime/types/UiComponent.ts +16 -0
  531. package/src/lib/ui/runtime/types/UiProps.ts +15 -0
  532. package/src/lib/ui/runtime/unlinkDeps.ts +20 -0
  533. package/src/lib/ui/runtime/untrack.ts +20 -0
  534. package/src/lib/ui/runtime/valueAtPath.ts +18 -0
  535. package/src/lib/ui/runtime/writeNode.ts +16 -0
  536. package/src/lib/ui/socketChannel.ts +227 -0
  537. package/src/lib/ui/socketProxy.ts +25 -0
  538. package/src/lib/ui/startClient.ts +58 -0
  539. package/src/lib/ui/state.ts +25 -0
  540. package/src/lib/ui/tail.ts +324 -0
  541. package/src/lib/ui/types/Layouts.ts +9 -0
  542. package/src/lib/ui/types/Pages.ts +8 -0
  543. package/src/preload.ts +19 -0
  544. package/src/scaffold.ts +153 -0
  545. package/src/serverBuildPlugins.ts +19 -0
  546. package/src/serverEntry.ts +95 -0
  547. package/template/bunfig.toml +4 -0
  548. package/template/package.json +18 -0
  549. package/template/src/app.ts +28 -0
  550. package/template/src/bundle/icon.png +0 -0
  551. package/template/src/cli/banner.txt +3 -0
  552. package/template/src/cli/footer.txt +1 -0
  553. package/template/src/server/config.ts +17 -0
  554. package/template/src/server/rpc/getHello.ts +36 -0
  555. package/template/src/ui/Layout.abide +19 -0
  556. package/template/src/ui/app.css +21 -0
  557. package/template/src/ui/app.html +24 -0
  558. package/template/src/ui/pages/about/page.abide +9 -0
  559. package/template/src/ui/pages/page.abide +22 -0
  560. package/template/test/app.test.ts +30 -0
  561. package/template/tsconfig.json +18 -0
  562. package/tsconfig.app.json +17 -0
@@ -0,0 +1,19 @@
1
+ import type { ClientFlags } from '../../../shared/types/ClientFlags.ts'
2
+ import type { StandardSchemaV1 } from '../../../shared/types/StandardSchemaV1.ts'
3
+ import type { Socket } from './Socket.ts'
4
+
5
+ /*
6
+ Per-socket registry record. The Socket itself stays uniform between
7
+ server and client by parking policy state (retained-tail snapshot, client
8
+ publish gate, payload schema, client targeting) here instead of leaking
9
+ into the public Socket shape.
10
+ */
11
+ export type SocketRegistryEntry = {
12
+ socket: Socket<unknown>
13
+ allowClientPublish: boolean
14
+ schema: StandardSchemaV1 | undefined
15
+ clients: ClientFlags
16
+ /* last `count` retained frames (whole tail when omitted) — the read-only
17
+ face shared by the ws sub replay, the HTTP rest() face, and MCP tail */
18
+ snapshotTail(count?: number): unknown[]
19
+ }
@@ -0,0 +1,10 @@
1
+ import type { Socket } from './Socket.ts'
2
+
3
+ /*
4
+ Manifest of socket-name → module loader. Produced by the resolver
5
+ plugin from each `.ts` under src/server/sockets/. Each module has exactly one
6
+ named export, a Socket whose `.name` was stamped in by the bundler
7
+ rewrite. The dispatcher imports a module on first access and caches the
8
+ resolved Socket against its name.
9
+ */
10
+ export type SocketRoutes = Record<string, () => Promise<Record<string, Socket<unknown>>>>
@@ -0,0 +1,24 @@
1
+ /*
2
+ Wire frame the server sends over the multiplexed socket connection.
3
+
4
+ `msg` is keyed by socket name (not sub id) because one publish fans
5
+ out to every client subscribed to the socket via Bun's native
6
+ publish — the client demuxes against every local sub of that socket.
7
+
8
+ `replay` is per-sub and batched: one frame carries the sub's requested
9
+ slice of the retained tail (possibly empty), sent on sub before live
10
+ fan-out reaches it. The batch is the wire's replay/live demarcation —
11
+ a window reader commits its seed atomically at the boundary — and the
12
+ per-sub address keeps one sub's replay out of sibling subs on the same
13
+ socket.
14
+
15
+ `end` and `err` are per-sub because they're subscription-lifecycle
16
+ events; `err.message` is the only thrown-value field forwarded so the
17
+ wire stays JSON-safe and server-side stack traces never reach the
18
+ client.
19
+ */
20
+ export type SocketServerFrame =
21
+ | { type: 'msg'; socket: string; message: unknown }
22
+ | { type: 'replay'; sub: string; messages: unknown[] }
23
+ | { type: 'end'; sub: string }
24
+ | { type: 'err'; sub: string; message: string }
@@ -0,0 +1,54 @@
1
+ /*
2
+ Wraps an AsyncIterable<Frame> in a Response whose body is
3
+ Server-Sent Events (text/event-stream) — each frame becomes one
4
+ `data: <json>\n\n` event. Used inside an rpc handler to expose a
5
+ generator over plain HTTP so EventSource (or `tail(fn.stream(args))`
6
+ on the client) can consume it frame-by-frame.
7
+
8
+ export const orderFeed = GET<Args>((args) =>
9
+ sse(async function* () {
10
+ for await (const order of db.watchOrders(args)) yield order
11
+ }())
12
+ )
13
+
14
+ A 15s keepalive comment (`: keepalive\n\n`) is sent between frames so
15
+ intermediaries (proxies, load balancers) don't drop an idle connection.
16
+ Comments are ignored by EventSource per the spec, so they're invisible to
17
+ consumers.
18
+
19
+ Cancellation flows from the consumer through ReadableStream's `cancel`
20
+ into `iter.return()` so the handler's `for await` exits via its normal
21
+ control path. Errors are emitted as an `event: error` frame carrying only
22
+ the message (full error logged server-side) before the stream closes;
23
+ EventSource surfaces this via its `error` listener and `tail()`
24
+ maps it to the entry's `error` field.
25
+ */
26
+ import { NO_STORE } from '../shared/CACHE_CONTROL_VALUES.ts'
27
+ import { sseErrorFrame } from '../shared/sseErrorFrame.ts'
28
+ import type { TypedResponse } from './rpc/types/TypedResponse.ts'
29
+ import { streamFromIterator } from './runtime/streamFromIterator.ts'
30
+ import { withResponseDefaults } from './runtime/withResponseDefaults.ts'
31
+
32
+ const KEEPALIVE_INTERVAL_MS = 15000
33
+
34
+ // @readme response
35
+ export function sse<Frame>(
36
+ iterable: AsyncIterable<Frame>,
37
+ init?: ResponseInit,
38
+ ): TypedResponse<Frame> {
39
+ const body = streamFromIterator(iterable, {
40
+ encodeFrame: (value) => `data: ${JSON.stringify(value)}\n\n`,
41
+ encodeError: (message) => sseErrorFrame.encode(message),
42
+ keepaliveMs: KEEPALIVE_INTERVAL_MS,
43
+ keepalivePayload: ': keepalive\n\n',
44
+ })
45
+ return new Response(
46
+ body,
47
+ withResponseDefaults(init, {
48
+ 'Content-Type': 'text/event-stream; charset=utf-8',
49
+ 'Cache-Control': NO_STORE,
50
+ 'X-Content-Type-Options': 'nosniff',
51
+ Connection: 'keep-alive',
52
+ }),
53
+ ) as TypedResponse<Frame>
54
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ The package's published npm name. The codegen and the import-name resolver
3
+ match a consuming project's dependency (direct or aliased) against this to
4
+ decide which specifier to emit, so keeping it in one place means a future
5
+ rename touches a single constant.
6
+ */
7
+ export const ABIDE_PACKAGE_NAME = '@abide/abide'
@@ -0,0 +1,9 @@
1
+ import packageJson from '../../../package.json' with { type: 'json' }
2
+
3
+ /*
4
+ The framework's own version, inlined at build time from abide's package.json
5
+ (a compiled binary has no node_modules to read at runtime). Rides the health
6
+ payload's `abide` field — truthy for the "is this a abide server" check,
7
+ informative for skew diagnosis.
8
+ */
9
+ export const ABIDE_VERSION: string = packageJson.version
@@ -0,0 +1,16 @@
1
+ /*
2
+ Cache-Control values used by abide's framework responses. Centralised so
3
+ the framework's policy (no-store on errors and rpc dispatch helpers,
4
+ private/no-cache on SSR HTML, the static-asset policies) lives in one place
5
+ and can't drift between the server core, the asset servers, and the respond
6
+ helpers.
7
+ */
8
+ export const NO_STORE = 'no-store'
9
+ export const SSR_CACHE_CONTROL = 'private, no-cache'
10
+
11
+ // Content-addressed `/_app/` chunks (name carries the hash) — cache forever.
12
+ export const IMMUTABLE_ASSET_CACHE_CONTROL = 'public, max-age=31536000, immutable'
13
+ // Unhashed `/_app/` entries (entry bundle, shell) — must revalidate each time.
14
+ export const REVALIDATE_ASSET_CACHE_CONTROL = 'public, max-age=0, must-revalidate'
15
+ // Files served from public/ at the site root — short shared cache.
16
+ export const PUBLIC_ASSET_CACHE_CONTROL = 'public, max-age=3600'
@@ -0,0 +1,8 @@
1
+ /*
2
+ Brand on the invoker cache() returns; its property value is the wrapped fn,
3
+ so inspection shows what a wrapper wraps. Detection is certain (set by us,
4
+ never heuristic), which is why misuse throws instead of warning: a wrapper
5
+ used as a selector matches nothing (no url/method, no producer id), and a
6
+ re-wrapped wrapper silently downgrades a remote to an anonymous producer.
7
+ */
8
+ export const CACHE_WRAPPED: unique symbol = Symbol('abide.cacheWrapped')
@@ -0,0 +1,7 @@
1
+ /*
2
+ Path of the CLI install endpoint: the bare path returns the platform-detecting
3
+ install script, `${CLI_PATH}/<platform>` the platform tarball. Shared so the
4
+ server mount (createServer) and the script the install endpoint emits
5
+ (installScript) agree on the path.
6
+ */
7
+ export const CLI_PATH = '/__abide/cli'
@@ -0,0 +1,7 @@
1
+ /*
2
+ Path prefix of the dev-only component hot-module endpoint (`/__abide/hot/<moduleId>`).
3
+ The browser imports `<prefix><moduleId>?v=<hash>` to fetch one edited component's
4
+ hot module instead of reloading. Shared so the server route (createServer) and the
5
+ live-reload client (DEV_RELOAD_CLIENT_SCRIPT) agree.
6
+ */
7
+ export const DEV_HOT_PREFIX = '/__abide/hot/'
@@ -0,0 +1,6 @@
1
+ /*
2
+ Path of the dev-only live-reload SSE channel. Shared so the server mount
3
+ (createServer) and the client script injected into dev pages
4
+ (DEV_RELOAD_CLIENT_SCRIPT) agree on the path.
5
+ */
6
+ export const DEV_RELOAD_PATH = '/__abide/dev'
@@ -0,0 +1,7 @@
1
+ /*
2
+ The canonical liveness/health endpoint: the identity payload plus whatever
3
+ the app's optional `health(request)` hook contributes. `/__abide/identity`
4
+ stays as a compatibility alias serving the same payload (older launchers
5
+ probe it; probeAbideServer falls back to it for older servers).
6
+ */
7
+ export const HEALTH_PATH = '/__abide/health'
@@ -0,0 +1,20 @@
1
+ /*
2
+ Thrown by remote-function calls when the server responds with a non-2xx
3
+ status. Carries the raw Response so callers can inspect body, headers, or
4
+ status text — useful for showing user-friendly error UI without having to
5
+ opt every call site into the `.raw()` escape hatch.
6
+ */
7
+ // @readme response
8
+ export class HttpError extends Error {
9
+ readonly status: number
10
+ readonly statusText: string
11
+ readonly response: Response
12
+
13
+ constructor(response: Response) {
14
+ super(`HTTP ${response.status} ${response.statusText || 'error'}`)
15
+ this.name = 'HttpError'
16
+ this.status = response.status
17
+ this.statusText = response.statusText
18
+ this.response = response
19
+ }
20
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ Path of the identity probe answering `{ abide, name, version }` ahead of any
3
+ app middleware. Shared so the server mount (createServer) and the launcher's
4
+ probe (probeAbideServer) agree on the path.
5
+ */
6
+ export const IDENTITY_PATH = '/__abide/identity'
@@ -0,0 +1,7 @@
1
+ /*
2
+ Mount root of the opt-in inspector surface (the `@abide/inspector` package,
3
+ activated by ABIDE_ENABLE_INSPECTOR=true). The UI sits at this exact path; its
4
+ data endpoints (`/surface`, `/events`) live under `${INSPECTOR_PATH}/`. Shared
5
+ so createServer's route gate and the inspector handler agree on the prefix.
6
+ */
7
+ export const INSPECTOR_PATH = '/__abide/inspector'
@@ -0,0 +1,8 @@
1
+ /*
2
+ Request header the client router stamps (value '1') on its SPA navigation probe:
3
+ a bare fetch of the destination that exists only to run app.handle server-side
4
+ (auth, redirect, header gating) without paying for a render. Presence tells the
5
+ page dispatcher to answer 204 once handle() has passed — a redirect or block from
6
+ handle() never reaches that point. Absence is an ordinary document/render request.
7
+ */
8
+ export const NAV_HEADER = 'abide-nav'
@@ -0,0 +1,8 @@
1
+ /*
2
+ Request header a abide client fetch sets (value '1') only when navigator.onLine
3
+ is false, so a handler's online() reflects the calling client's connectivity.
4
+ Presence = offline; absence = online/unknown. In a bundle the client and the
5
+ embedded server share a machine, so this carries exactly the outbound
6
+ reachability a handler reaching external sites needs.
7
+ */
8
+ export const OFFLINE_HEADER = 'abide-offline'
@@ -0,0 +1,8 @@
1
+ /*
2
+ Brand set by createRemoteFunction on both the decoded callable and its raw
3
+ sibling — the exact answer to "is this a abide remote?" where structural
4
+ checks ('url' in fn) would misclassify any user function that happens to
5
+ carry a url property. Read by cache()'s remote/producer discriminator,
6
+ selectorMatcher's identity branch, and the route dispatcher's export scan.
7
+ */
8
+ export const REMOTE_FUNCTION: unique symbol = Symbol('abide.remoteFunction')
@@ -0,0 +1,12 @@
1
+ /*
2
+ Methods whose remote-call cache entries can be replayed on the client from an
3
+ SSR snapshot: the key (method + url + args-in-url) carries everything needed to
4
+ re-issue the request, and re-issuing is safe. Only GET qualifies — it is the
5
+ one safe (read-only) method. DELETE is idempotent but still a write, and
6
+ body-carrying writes (POST/PUT/PATCH) additionally don't round-trip through
7
+ the snapshot; none of them may re-fire unprompted. Shared by snapshot
8
+ serialization and the invalidate-policy guard so both agree on which methods
9
+ are replayable. Deliberately not consulted by the server's ttl: 0 keep —
10
+ within one request, writes coalesce like everything else.
11
+ */
12
+ export const REPLAYABLE_METHODS: ReadonlySet<string> = new Set(['GET'])
@@ -0,0 +1,7 @@
1
+ /*
2
+ Mount path of the framework's socket multiplex: the single ws upgrade point,
3
+ with the per-socket HTTP face under `${SOCKETS_PATH}/<name>`. Shared so the
4
+ server mount (createServer), the browser channel's dial (socketChannel), and
5
+ the REST face advertised to the CLI/MCP (socketOperations) agree on the path.
6
+ */
7
+ export const SOCKETS_PATH = '/__abide/sockets'
@@ -0,0 +1,11 @@
1
+ /*
2
+ Content-Type prefixes abide treats as streaming bodies — SSE for the
3
+ `sse()` helper, JSONL / NDJSON for the `jsonl()` helper. Used by
4
+ decodeResponse to refuse a buffered decode and by streamResponse to
5
+ choose the frame parser.
6
+ */
7
+ export const STREAMING_CONTENT_TYPES = [
8
+ 'text/event-stream',
9
+ 'application/jsonl',
10
+ 'application/x-ndjson',
11
+ ]
@@ -0,0 +1,13 @@
1
+ /*
2
+ Typed transport-loss signal: the multiplexed ws channel went down and tore this
3
+ subscription with it. Distinct from an application error (a server `err` frame)
4
+ because it is recoverable — tail() catches this type to reconnect with the
5
+ last value retained (refreshing), while raw `for await` consumers surface it
6
+ like any other error and keep manual control over reconciliation.
7
+ */
8
+ export class SocketDisconnectedError extends Error {
9
+ constructor() {
10
+ super('socket channel disconnected')
11
+ this.name = 'SocketDisconnectedError'
12
+ }
13
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ Content-Type for the framework's plain-text responses (404, 405, CSRF refusal,
3
+ internal error). Explicit so intermediaries don't sniff the body and browsers
4
+ render it inline — a bodied Response with no Content-Type ships as
5
+ `application/octet-stream`, which the browser downloads instead of displaying.
6
+ */
7
+ export const TEXT_PLAIN = 'text/plain; charset=utf-8'
@@ -0,0 +1,44 @@
1
+ import { ABIDE_PACKAGE_NAME } from './ABIDE_PACKAGE_NAME.ts'
2
+ import { readPackageJson } from './readPackageJson.ts'
3
+
4
+ /*
5
+ Resolves the bare specifier prefix a consuming project imports abide under —
6
+ the name abide is installed as in its package.json. A project may depend on
7
+ abide directly (`abide`) or behind a package alias
8
+ (`"abide": "npm:abide@..."`, or `workspace:abide@*`
9
+ inside this repo). An alias-only install resolves only under the alias key and
10
+ a direct install only under the canonical name, so the generated rpc / socket
11
+ / prompt modules must import under whichever name the project
12
+ declared.
13
+
14
+ Prefers a `abide` alias (the ergonomic surface the docs use) when present, then
15
+ a direct canonical dependency, then any other alias targeting abide. Falls back
16
+ to the canonical name when abide isn't found in package.json — the build can't
17
+ resolve abide at all in that case, and the canonical name yields the clearest
18
+ resolution error.
19
+ */
20
+ export async function abideImportName(cwd: string): Promise<string> {
21
+ const packageJson = (await readPackageJson(cwd)) as
22
+ | { dependencies?: Record<string, string>; devDependencies?: Record<string, string> }
23
+ | undefined
24
+ if (!packageJson) {
25
+ return ABIDE_PACKAGE_NAME
26
+ }
27
+ const dependencies = { ...packageJson.devDependencies, ...packageJson.dependencies }
28
+ /*
29
+ Alias entries whose target is abide — `npm:` for a published install,
30
+ `workspace:` for the in-repo examples. The key is the name the project
31
+ imports under; the version suffix (`@^0.2.0`, `@*`) is optional.
32
+ */
33
+ const aliasPattern = new RegExp(`^(npm|workspace):${ABIDE_PACKAGE_NAME}(@.*)?$`)
34
+ const aliasNames = Object.entries(dependencies)
35
+ .filter(([, specifier]) => aliasPattern.test(specifier))
36
+ .map(([name]) => name)
37
+ if (aliasNames.includes('abide')) {
38
+ return 'abide'
39
+ }
40
+ if (ABIDE_PACKAGE_NAME in dependencies) {
41
+ return ABIDE_PACKAGE_NAME
42
+ }
43
+ return aliasNames[0] ?? ABIDE_PACKAGE_NAME
44
+ }
@@ -0,0 +1,38 @@
1
+ import { createChannelLog } from './createChannelLog.ts'
2
+ import { emitLogRecord } from './emitLogRecord.ts'
3
+ import type { ChannelLog } from './types/ChannelLog.ts'
4
+ import type { FrameworkLog } from './types/FrameworkLog.ts'
5
+
6
+ const ABIDE_CHANNEL = 'abide'
7
+
8
+ /*
9
+ The framework's own voice: the public log shape bound to the always-on
10
+ 'abide' channel, so every framework line — boot messages, build output,
11
+ internal warns/errors, the closing record's sibling diagnostics — reads
12
+ `[abide] …` and json consumers filter channel='abide'. The styling voices
13
+ (info/success/detail) ride the same channel and the same negation gate, so
14
+ DEBUG=-abide silences every voice; diagnostic sub-channels (abide:cache,
15
+ abide:rpc, …) stay DEBUG-gated via .channel().
16
+ */
17
+ const channelVoice = createChannelLog(() => ABIDE_CHANNEL, true)
18
+
19
+ export const abideLog: FrameworkLog = Object.assign(channelVoice, {
20
+ channel(name: string): ChannelLog {
21
+ return createChannelLog(() => name, false)
22
+ },
23
+ info(message: string): void {
24
+ if (channelVoice.enabled()) {
25
+ emitLogRecord({ level: 'info', msg: message, channel: ABIDE_CHANNEL })
26
+ }
27
+ },
28
+ success(message: string): void {
29
+ if (channelVoice.enabled()) {
30
+ emitLogRecord({ level: 'info', msg: message, channel: ABIDE_CHANNEL }, 'success')
31
+ }
32
+ },
33
+ detail(message: string): void {
34
+ if (channelVoice.enabled()) {
35
+ emitLogRecord({ level: 'info', msg: message, channel: ABIDE_CHANNEL }, 'detail')
36
+ }
37
+ },
38
+ })
@@ -0,0 +1,20 @@
1
+ import { cacheStoreSlot } from './cacheStoreSlot.ts'
2
+ import { createCacheStore } from './createCacheStore.ts'
3
+ import type { CacheStore } from './types/CacheStore.ts'
4
+
5
+ /*
6
+ Resolves the active CacheStore. The runtime is registered via
7
+ `setCacheStoreResolver` from the server entry (request-scoped via ALS)
8
+ or the client entry (module-level singleton). If no resolver is registered,
9
+ a single fallback store is created lazily so isolated tests still work.
10
+ */
11
+ export function activeCacheStore(): CacheStore {
12
+ const fromResolver = cacheStoreSlot.resolver?.()
13
+ if (fromResolver) {
14
+ return fromResolver
15
+ }
16
+ if (!cacheStoreSlot.fallback) {
17
+ cacheStoreSlot.fallback = createCacheStore()
18
+ }
19
+ return cacheStoreSlot.fallback
20
+ }
@@ -0,0 +1,25 @@
1
+ import { pageSlot } from './pageSlot.ts'
2
+ import type { PageSnapshot } from './types/PageSnapshot.ts'
3
+
4
+ /*
5
+ Resolves the active page snapshot. The runtime is registered via
6
+ `setPageResolver` from the server entry (request-scoped via ALS) or the
7
+ client entry (module-level singleton). If no resolver is registered, a single
8
+ fallback snapshot is created lazily so isolated tests still work. Mirrors
9
+ activeCacheStore.
10
+ */
11
+ export function activePage(): PageSnapshot {
12
+ const fromResolver = pageSlot.resolver?.()
13
+ if (fromResolver) {
14
+ return fromResolver
15
+ }
16
+ if (!pageSlot.fallback) {
17
+ pageSlot.fallback = {
18
+ route: '',
19
+ params: {},
20
+ url: new URL('http://localhost/'),
21
+ navigating: false,
22
+ }
23
+ }
24
+ return pageSlot.fallback
25
+ }
@@ -0,0 +1,34 @@
1
+ import { homedir } from 'node:os'
2
+ import { join } from 'node:path'
3
+
4
+ /*
5
+ Platform-standard per-user data directory for a bundle, keyed by its program
6
+ name. cwd-independent on purpose: the path derives from `programName`, not the
7
+ process working directory — which the OS `open` command sets to `/`, so anything
8
+ relying on cwd (Bun's `.env` autoload, relative paths) finds nothing inside a
9
+ launched `.app`. This is where a bundle keeps what can't be baked at compile time
10
+ — the user's config, DB, and cache. macOS Application Support, Windows %APPDATA%,
11
+ XDG data home elsewhere. Pure: computes the path, never touches the filesystem.
12
+
13
+ `ABIDE_DATA_DIR` overrides the lot on every platform, used as-is (no programName
14
+ appended) — a cross-platform `XDG_DATA_HOME` that also works on macOS/Windows. Set
15
+ it to point dev at a throwaway dir without touching app code; leave it unset in
16
+ prod for the platform default. A relative value reintroduces cwd-dependence, so a
17
+ launched `.app` (cwd `/`) needs an absolute path. Must come from a layer above the
18
+ data-dir `.env` (shell, CWD `.env`, or binary-dir `.env`) — it can't be read from
19
+ the very file whose location it decides.
20
+ */
21
+ export function appDataDir(programName: string): string {
22
+ const override = process.env.ABIDE_DATA_DIR
23
+ if (override !== undefined && override !== '') {
24
+ return override
25
+ }
26
+ const home = homedir()
27
+ if (process.platform === 'darwin') {
28
+ return join(home, 'Library', 'Application Support', programName)
29
+ }
30
+ if (process.platform === 'win32') {
31
+ return join(process.env.APPDATA ?? join(home, 'AppData', 'Roaming'), programName)
32
+ }
33
+ return join(process.env.XDG_DATA_HOME ?? join(home, '.local', 'share'), programName)
34
+ }
@@ -0,0 +1,10 @@
1
+ /*
2
+ The app's name — the default log channel every unchanneled record carries.
3
+ Set once per process by createServer (package.json name / appInfo) and once
4
+ per page by startClient (the __SSR__ stamp). Undefined until the runtime
5
+ boots; readers fall back to 'app' so isolated tests and pre-boot logging
6
+ still carry a channel.
7
+ */
8
+ export const appNameSlot: { name: string | undefined } = {
9
+ name: undefined,
10
+ }
@@ -0,0 +1,10 @@
1
+ import { baseSlot } from './baseSlot.ts'
2
+
3
+ /*
4
+ The current mount base path ('' at root). Resolved per side: the server
5
+ installs an APP_URL-derived resolver at boot, the client one reading
6
+ window.__SSR__.base. url() reads this to prefix rooted internal paths.
7
+ */
8
+ export function basePath(): string {
9
+ return baseSlot.resolver?.() ?? baseSlot.fallback ?? ''
10
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ Derives the mount base path from APP_URL. APP_URL carries both the app's
3
+ public origin (for absolute URLs) and, via its pathname, where the app is
4
+ mounted — `https://foo.com/v2` → `/v2`. Returns the pathname with any
5
+ trailing slash stripped; root (`/`), unset, or unparseable collapses to ''
6
+ (root mount, the zero-config default). A bare path value with no origin is
7
+ tolerated so `.env` can carry `APP_URL=/v2`.
8
+ */
9
+ export function basePathFromAppUrl(appUrl: string | undefined): string {
10
+ if (!appUrl) {
11
+ return ''
12
+ }
13
+ let pathname: string
14
+ try {
15
+ pathname = new URL(appUrl).pathname
16
+ } catch {
17
+ pathname = appUrl.startsWith('/') ? appUrl : ''
18
+ }
19
+ return pathname.replace(/\/+$/, '')
20
+ }
@@ -0,0 +1,14 @@
1
+ /*
2
+ Internal slot the runtime entries register their mount-base resolver into.
3
+ The server entry installs an APP_URL-derived resolver at boot; the client
4
+ entry installs one reading window.__SSR__.base. `fallback` is a single value
5
+ used only when no resolver is registered — lets isolated tests set a base
6
+ without spinning up the runtime. Mirrors pageSlot / cacheStoreSlot.
7
+ */
8
+ export const baseSlot: {
9
+ resolver: (() => string) | undefined
10
+ fallback: string | undefined
11
+ } = {
12
+ resolver: undefined,
13
+ fallback: undefined,
14
+ }
@@ -0,0 +1,12 @@
1
+ import { dirname } from 'node:path'
2
+ import { bundleLayout } from './bundleLayout.ts'
3
+
4
+ /*
5
+ The bundle's shipped `.env` (its default config layer), resolved from the
6
+ running binary's directory via bundleLayout — beside the binary in the flat
7
+ layout, under `Contents/Resources` in a macOS `.app`. One statement of the
8
+ location for the boot loader, the config form, and the embedded-port resolver.
9
+ */
10
+ export function binaryDirEnvPath(): string {
11
+ return bundleLayout(dirname(process.execPath)).envPath
12
+ }
@@ -0,0 +1,10 @@
1
+ import type { ClientFlags } from './types/ClientFlags.ts'
2
+
3
+ /*
4
+ Client surface flags for a browser-emitted RPC/socket stub. The bundler only
5
+ emits the browser proxy when clients.browser is true, so browser is always true
6
+ here; mcp/cli are server-only discovery state with no meaning in the browser
7
+ bundle, defaulted false so the public RemoteFunction/Socket shape matches the
8
+ server side. Single source shared by remoteProxy and socketProxy.
9
+ */
10
+ export const browserClientFlags: ClientFlags = { browser: true, mcp: false, cli: false }
@@ -0,0 +1,39 @@
1
+ import { decodeResponse } from './decodeResponse.ts'
2
+ import type { RpcInvoker } from './types/RpcInvoker.ts'
3
+
4
+ /*
5
+ Builds the name→callable proxy every RPC client surface shares (the CLI client,
6
+ the test harness). The caller supplies `resolveSend`, the one part that differs:
7
+ it maps a command name to the closure that issues that command's wire call, or
8
+ undefined for an unknown name. This module owns the invariant — a plain call
9
+ decodes the body (decodeResponse throws HttpError on non-2xx), `.raw` returns the
10
+ untouched Response — so the two surfaces can't drift from each other or from the
11
+ remote-function path they mirror.
12
+
13
+ Each name resolves once: the per-name invoker (or its absence) is memoised, since
14
+ the underlying registry/manifest is fixed for a client's lifetime, so repeated
15
+ `client.foo` accesses skip both the resolve and a fresh closure allocation.
16
+ */
17
+ export function buildRpcProxy<Api extends object>(
18
+ resolveSend: (name: string) => ((args?: unknown) => Promise<Response>) | undefined,
19
+ ): Api {
20
+ const invokerCache = new Map<string, RpcInvoker | undefined>()
21
+ return new Proxy({} as Api, {
22
+ get(_target, prop): RpcInvoker | undefined {
23
+ if (typeof prop !== 'string') {
24
+ return undefined
25
+ }
26
+ // Caches undefined too, so an unknown name resolves once, not per access.
27
+ return invokerCache.getOrInsertComputed(prop, () => {
28
+ const send = resolveSend(prop)
29
+ if (!send) {
30
+ return undefined
31
+ }
32
+ const invoker = (async (args?: unknown) =>
33
+ decodeResponse(await send(args))) as RpcInvoker
34
+ invoker.raw = (args?: unknown) => send(args)
35
+ return invoker
36
+ })
37
+ },
38
+ })
39
+ }