@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,81 @@
1
+ // @ts-expect-error virtual module resolved by abideResolverPlugin
2
+ import { rpc } from './_virtual/rpc.ts'
3
+ // @ts-expect-error virtual module resolved by abideResolverPlugin
4
+ import { sockets } from './_virtual/sockets.ts'
5
+ import type { CliManifestEntry } from './lib/cli/types/CliManifestEntry.ts'
6
+ import { verbRegistry } from './lib/server/rpc/verbRegistry.ts'
7
+ import { socketOperations } from './lib/server/sockets/socketOperations.ts'
8
+ import { socketRegistry } from './lib/server/sockets/socketRegistry.ts'
9
+ import { commandNameForUrl } from './lib/shared/commandNameForUrl.ts'
10
+ import { jsonSchemaForSchema } from './lib/shared/jsonSchemaForSchema.ts'
11
+
12
+ /*
13
+ One-shot script that imports every rpc + socket module so defineVerb /
14
+ defineSocket populate the process-wide registries, then prints the CLI
15
+ manifest to stdout as JSON. Used by buildCli to bake the manifest into
16
+ the standalone binary at build time without resorting to static source
17
+ parsing (which can't see toJsonSchema()/toJSONSchema() at compile time).
18
+ */
19
+ await Promise.all([
20
+ ...Object.values(rpc).map((loader) => (loader as () => Promise<unknown>)()),
21
+ ...Object.values(sockets).map((loader) => (loader as () => Promise<unknown>)()),
22
+ ])
23
+
24
+ const manifest: Record<string, CliManifestEntry> = {}
25
+
26
+ for (const entry of verbRegistry.values()) {
27
+ if (!entry.clients.cli) {
28
+ continue
29
+ }
30
+ manifest[commandNameForUrl(entry.remote.url)] = {
31
+ method: entry.remote.method,
32
+ url: entry.remote.url,
33
+ jsonSchema: jsonSchemaForSchema(entry.inputSchema),
34
+ }
35
+ }
36
+
37
+ /*
38
+ Sockets advertised to the CLI become commands against the socket's HTTP
39
+ face (see socketOperations): `<base>-tail` streams live (GET +
40
+ text/event-stream, with an optional --tail N to seed from the retained
41
+ tail first) and, when clientPublish is set, `<base>-publish` sends the args bag
42
+ as a message (POST).
43
+ */
44
+ for (const entry of socketRegistry.values()) {
45
+ if (!entry.clients.cli) {
46
+ continue
47
+ }
48
+ for (const operation of socketOperations(entry)) {
49
+ if (operation.kind === 'tail') {
50
+ manifest[operation.name] = {
51
+ method: operation.method,
52
+ url: operation.restUrl,
53
+ accept: 'text/event-stream',
54
+ jsonSchema: {
55
+ type: 'object',
56
+ description: `tail the "${operation.socketName}" socket`,
57
+ properties: {
58
+ tail: {
59
+ type: 'number',
60
+ description: 'replay last N messages before tailing live',
61
+ },
62
+ },
63
+ },
64
+ }
65
+ continue
66
+ }
67
+ const payloadSchema = jsonSchemaForSchema(entry.schema)
68
+ manifest[operation.name] = {
69
+ method: operation.method,
70
+ url: operation.restUrl,
71
+ jsonSchema: {
72
+ ...payloadSchema,
73
+ description:
74
+ (payloadSchema.description as string | undefined) ??
75
+ `publish a message to the "${operation.socketName}" socket`,
76
+ },
77
+ }
78
+ }
79
+ }
80
+
81
+ process.stdout.write(JSON.stringify(manifest))
@@ -0,0 +1,12 @@
1
+ import type { BundleMenuItem } from './BundleMenuItem.ts'
2
+
3
+ /*
4
+ A top-level bundle menu, inserted into the macOS menu bar between the standard
5
+ Edit and Window menus. `label` titles the menu; `items` are its entries top to
6
+ bottom.
7
+ */
8
+ // @readme bundle
9
+ export type BundleMenu = {
10
+ label: string
11
+ items: BundleMenuItem[]
12
+ }
@@ -0,0 +1,25 @@
1
+ /*
2
+ A single entry in a bundle menu. Serializable data — the native shim builds the
3
+ matching NSMenuItem. Either a divider or a clickable item that dispatches a
4
+ `abide:menu` CustomEvent into the page (detail `{ name }`); the app's own code
5
+ handles it:
6
+
7
+ window.addEventListener('abide:menu', (event) => {
8
+ if (event.detail.name === 'sync') syncNow()
9
+ })
10
+
11
+ Emitting an event (rather than calling a verb directly) is what lets a menu
12
+ drive parameterised work: a click carries no arguments, so the app computes
13
+ them and makes the call itself. `shortcut` is the key for the Cmd-based
14
+ equivalent (e.g. `'r'` → Cmd-R).
15
+
16
+ A `navigate` item moves the window instead of talking to the page: clicking it
17
+ calls `webview_navigate` with the given URL (the native side, on the UI thread).
18
+ That's how the built-in Server menu drives the connect screen — `emit` reaches
19
+ the loaded page, `navigate` repoints the window itself.
20
+ */
21
+ // @readme bundle
22
+ export type BundleMenuItem =
23
+ | { separator: true }
24
+ | { label: string; shortcut?: string; emit: string }
25
+ | { label: string; shortcut?: string; navigate: string }
@@ -0,0 +1,37 @@
1
+ import type { StandardSchemaV1 } from '../shared/types/StandardSchemaV1.ts'
2
+ import type { BundleMenu } from './BundleMenu.ts'
3
+
4
+ /*
5
+ User-authored bundle window configuration, default-exported from an
6
+ optional `src/bundle/window.ts`. Baked into the launcher at build time
7
+ (via the `abide:bundle-window` virtual) and read directly in dev. Every
8
+ field is optional — the launcher falls back to the program name for the
9
+ title and to openWebview's defaults for size.
10
+
11
+ The standard App/Edit/Window menus (Quit, copy/paste, minimize/close) plus the
12
+ built-in File menu (Start server / Connect / Disconnect) are always installed.
13
+ `menu` adds custom top-level menus between the Edit and Window menus; their items
14
+ emit `abide:menu` events the app handles. See BundleMenuItem.
15
+ */
16
+ // @readme bundle
17
+ export type BundleWindow = {
18
+ title?: string
19
+ width?: number
20
+ height?: number
21
+ menu?: BundleMenu[]
22
+ /*
23
+ Overrides the bundle setup form's schema. By default the form is derived from
24
+ src/server/config.ts's env schema, so one declaration drives both boot
25
+ validation and the form — set this only when the bundle form should differ
26
+ from the env schema (it replaces, not merges; compose with the env schema
27
+ yourself via its `.extend(...)` if you want both).
28
+
29
+ A Standard Schema (the same kind abide accepts for RPC/MCP). Its JSON Schema
30
+ drives the connect screen's first-run form, shown as a modal when Start is
31
+ clicked with a required key still unset; the user's answers persist to the
32
+ data-dir `.env` the server loads at boot. Each property maps to one env var of
33
+ the same name; `title` is the field label, `description` the hint,
34
+ `format: 'password'` masks the input, and `default` pre-fills it.
35
+ */
36
+ config?: StandardSchemaV1
37
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ Revision of abide's own contribution to the compiled webview library — the
3
+ native shim sources linked in beside the vendored header (e.g. abideMenu.mm)
4
+ and the flags buildWebviewLib compiles them with. It participates in the build
5
+ cache key alongside the upstream version, so changing abide's native build
6
+ selects a fresh cache path and bypasses any library built before the change.
7
+ Bump this whenever the shim sources or their compile invocation change.
8
+ */
9
+ export const WEBVIEW_BUILD_REVISION = 9
@@ -0,0 +1,7 @@
1
+ /*
2
+ Upstream `webview/webview` release the vendored `native/webview.h` is taken
3
+ from (https://github.com/webview/webview, MIT). Used to namespace the build
4
+ cache so bumping the header naturally bypasses any previously built library.
5
+ Bump this whenever `native/webview.h` is re-vendored.
6
+ */
7
+ export const WEBVIEW_VERSION = '0.12.0'
@@ -0,0 +1,29 @@
1
+ import { dlopen, FFIType } from 'bun:ffi'
2
+
3
+ /*
4
+ Binds abide_set_connected — the native flag the macOS Server menu's
5
+ validateMenuItem: reads to enable/disable Start/Disconnect. The symbol is
6
+ compiled only into the macOS lib (the Cocoa menu shim), so a failed lookup
7
+ degrades to a no-op setter rather than throwing on Linux/Windows.
8
+
9
+ The flag is a process-global, which is what lets the bundle's control server set
10
+ it from off the main thread: that server runs in a Worker because `webview_run`
11
+ blocks the main thread's JS event loop, yet the main-thread menu still reads the
12
+ same value through the shared dylib image. The returned close releases the handle.
13
+ */
14
+ export function bindConnectedFlag(libPath: string): {
15
+ setConnected: (connected: boolean) => void
16
+ close: () => void
17
+ } {
18
+ try {
19
+ const lib = dlopen(libPath, {
20
+ abide_set_connected: { args: [FFIType.i32], returns: FFIType.void },
21
+ })
22
+ return {
23
+ setConnected: (connected) => lib.symbols.abide_set_connected(connected ? 1 : 0),
24
+ close: () => lib.close(),
25
+ }
26
+ } catch {
27
+ return { setConnected: () => {}, close: () => {} }
28
+ }
29
+ }
@@ -0,0 +1,34 @@
1
+ import { dlopen, FFIType, type Pointer } from 'bun:ffi'
2
+
3
+ /*
4
+ Binds abide_request_navigate — points the live webview window at a URL from any
5
+ thread by hopping onto the UI thread via webview_dispatch. The launcher's control
6
+ server runs in a Worker (off the main thread that webview_run blocks), so when it
7
+ detects the connected server has died it uses this to bounce the window back to the
8
+ connect screen. macOS-only symbol (the Cocoa shim), so a failed lookup degrades to
9
+ a no-op — elsewhere the worker can still correct the menu flag, just not the window.
10
+
11
+ `handle` is the webview pointer created on the main thread, forwarded to the worker
12
+ as a number; bun:ffi accepts it for a ptr argument from either thread because the
13
+ pointer addresses the same process heap.
14
+ */
15
+ export function bindRequestNavigate(libPath: string): {
16
+ requestNavigate: (handle: number, url: string) => void
17
+ close: () => void
18
+ } {
19
+ try {
20
+ const lib = dlopen(libPath, {
21
+ abide_request_navigate: { args: [FFIType.ptr, FFIType.ptr], returns: FFIType.void },
22
+ })
23
+ return {
24
+ requestNavigate: (handle, url) =>
25
+ lib.symbols.abide_request_navigate(
26
+ handle as Pointer,
27
+ new TextEncoder().encode(`${url}\0`),
28
+ ),
29
+ close: () => lib.close(),
30
+ }
31
+ } catch {
32
+ return { requestNavigate: () => {}, close: () => {} }
33
+ }
34
+ }
@@ -0,0 +1,111 @@
1
+ import { dirname } from 'node:path'
2
+ import { abideLog } from '../shared/abideLog.ts'
3
+ import { WEBVIEW_VERSION } from './WEBVIEW_VERSION.ts'
4
+ import { webviewCachePath } from './webviewCachePath.ts'
5
+
6
+ // Vendored upstream amalgamation; the host compiler turns it into a lib.
7
+ const HEADER = new URL('./native/webview.h', import.meta.url).pathname
8
+
9
+ // abide's own native shim, linked into the same dylib on macOS to add the
10
+ // standard application menu bar the upstream webview omits.
11
+ const MAC_MENU_SOURCE = new URL('./native/abideMenu.mm', import.meta.url).pathname
12
+
13
+ /*
14
+ Linux GTK/WebKit pkg-config module sets, newest first. The vendored header
15
+ auto-selects the GTK4 or GTK3 backend from GTK_MAJOR_VERSION in the include
16
+ path, so supplying the right cflags/libs is all that's needed — no backend
17
+ macro. The first set whose packages are installed wins.
18
+ */
19
+ const LINUX_PKG_SETS = [
20
+ ['gtk4', 'webkitgtk-6.0'],
21
+ ['gtk+-3.0', 'webkit2gtk-4.1'],
22
+ ['gtk+-3.0', 'webkit2gtk-4.0'],
23
+ ]
24
+
25
+ /*
26
+ Compiles the vendored webview header into a native shared library for the
27
+ host platform and caches it (webviewCachePath), so `abide bundle` needs
28
+ no prebuilt binary and no third-party webview package — just
29
+ the platform's C++ toolchain. Returns the cached path. Throws actionable
30
+ guidance when the toolchain or native webview dev packages are missing,
31
+ rather than letting the compiler fail opaquely.
32
+ */
33
+ export async function buildWebviewLib(): Promise<string> {
34
+ const outfile = webviewCachePath()
35
+ await Bun.$`mkdir -p ${dirname(outfile)}`.quiet()
36
+ abideLog.info(`building webview ${WEBVIEW_VERSION} for ${process.platform}-${process.arch}…`)
37
+
38
+ if (process.platform === 'darwin') {
39
+ await compileDarwin(outfile)
40
+ } else if (process.platform === 'linux') {
41
+ await compileLinux(outfile)
42
+ } else {
43
+ /*
44
+ Windows needs MSVC + the WebView2 SDK header (WebView2.h), which
45
+ isn't a turnkey shell invocation. Until that build path lands,
46
+ point Windows users at the explicit-path escape hatch.
47
+ */
48
+ throw new Error(
49
+ `[abide] building the webview library on ${process.platform} isn't supported yet. ` +
50
+ 'Set ABIDE_WEBVIEW_LIB to a prebuilt webview library to continue.',
51
+ )
52
+ }
53
+
54
+ abideLog.success(`built webview library: ${outfile}`)
55
+ return outfile
56
+ }
57
+
58
+ // macOS: clang against the WebKit + Cocoa frameworks (always present with the
59
+ // Command Line Tools), linking abide's Objective-C++ menu shim into the same
60
+ // dylib. The `-x` flags switch the input language per file: the vendored
61
+ // header compiles as C++ (it uses the C objc runtime, not objc syntax), the
62
+ // shim as Objective-C++. Maps a missing compiler to the install hint.
63
+ async function compileDarwin(outfile: string): Promise<void> {
64
+ try {
65
+ await Bun.$`clang++ -std=c++17 -DWEBVIEW_BUILD_SHARED -fvisibility=hidden -shared -framework WebKit -framework Cocoa -x c++ ${HEADER} -x objective-c++ ${MAC_MENU_SOURCE} -o ${outfile}`.quiet()
66
+ } catch (error) {
67
+ throw new Error(
68
+ '[abide] failed to compile the webview library. Install the Xcode Command ' +
69
+ 'Line Tools with `xcode-select --install` and try again.\n' +
70
+ describeShellError(error),
71
+ )
72
+ }
73
+ }
74
+
75
+ // Linux: detect an installed GTK/WebKit set via pkg-config, then compile a
76
+ // position-independent shared object. Maps missing packages to install hints.
77
+ async function compileLinux(outfile: string): Promise<void> {
78
+ const flags = await linuxPkgFlags()
79
+ try {
80
+ await Bun.$`c++ -std=c++17 -DWEBVIEW_BUILD_SHARED -fvisibility=hidden -fPIC -shared -x c++ ${HEADER} ${flags} -o ${outfile}`.quiet()
81
+ } catch (error) {
82
+ throw new Error(
83
+ '[abide] failed to compile the webview library. Ensure a C++ compiler ' +
84
+ '(e.g. `build-essential`) is installed.\n' +
85
+ describeShellError(error),
86
+ )
87
+ }
88
+ }
89
+
90
+ // Returns combined cflags + libs for the first available GTK/WebKit set, or
91
+ // throws with the package names to install when none resolve.
92
+ async function linuxPkgFlags(): Promise<string[]> {
93
+ for (const modules of LINUX_PKG_SETS) {
94
+ const probe = await Bun.$`pkg-config --exists ${modules}`.nothrow().quiet()
95
+ if (probe.exitCode === 0) {
96
+ const flags = await Bun.$`pkg-config --cflags --libs ${modules}`.quiet().text()
97
+ return flags.trim().split(/\s+/)
98
+ }
99
+ }
100
+ throw new Error(
101
+ '[abide] no GTK/WebKit development packages found. Install one set, e.g. ' +
102
+ '`libgtk-4-dev libwebkitgtk-6.0-dev` or `libgtk-3-dev libwebkit2gtk-4.1-dev`, ' +
103
+ 'or set ABIDE_WEBVIEW_LIB to a prebuilt webview library.',
104
+ )
105
+ }
106
+
107
+ // Surfaces the compiler's own stderr when a Bun shell command throws.
108
+ function describeShellError(error: unknown): string {
109
+ const stderr = (error as { stderr?: Uint8Array }).stderr
110
+ return stderr ? new TextDecoder().decode(stderr) : String(error)
111
+ }
@@ -0,0 +1,35 @@
1
+ declare global {
2
+ interface Window {
3
+ // Set by the native webview's init script (openWebview) on every document
4
+ // it loads — local or remote. Absent in a plain browser tab.
5
+ __ABIDE_BUNDLE__?: boolean
6
+ }
7
+ }
8
+
9
+ /*
10
+ True when this code runs inside the abide desktop bundle rather than a plain web
11
+ app in a browser. Isomorphic: one name, same meaning on both sides — "am I part of
12
+ the bundle" — though each side detects it differently.
13
+
14
+ Client: the native webview runs an init script on every document it loads
15
+ (openWebview's webview_init), so the flag is present whether the page came from the
16
+ bundle's own embedded server or a *remote* one. A plain browser tab never runs that
17
+ script — even when it hits the embedded localhost server — so it reads false there.
18
+ This is the "in a webview" signal, robust to local-or-remote.
19
+
20
+ Server: the launcher sets ABIDE_PARENT_PID when it spawns the embedded server (see
21
+ spawnEmbeddedServer), so its presence marks "I am the bundle's embedded server
22
+ process." A remote server is never part of a bundle, so it reads false — matching
23
+ the client view that a remote page's *data source* is outside the bundle even while
24
+ its *rendering context* (the webview) is inside it.
25
+
26
+ Distinct from runningAsStandaloneBinary(), which is also true for a plain compiled
27
+ (install-tarball) server binary — still a web app, not a bundle.
28
+ */
29
+ // @readme bundle
30
+ export function bundled(): boolean {
31
+ if (typeof window === 'undefined') {
32
+ return Boolean(Bun.env.ABIDE_PARENT_PID)
33
+ }
34
+ return window.__ABIDE_BUNDLE__ === true
35
+ }
@@ -0,0 +1,236 @@
1
+ <script>
2
+ /*
3
+ Default bundle connect screen (abide-ui). The launcher serves this (logo baked in
4
+ at build time, app title injected at runtime) instead of a blank window; override
5
+ it by dropping a `src/bundle/disconnected.abide`. It connects to a remote server
6
+ by URL and boots the embedded server, talking to the launcher's in-process control
7
+ server: POST /connect and POST /start each reply with a `{ redirect }` to follow.
8
+ */
9
+ const LAST_URL_KEY = 'abide:last-server-url'
10
+
11
+ const heading = globalThis.__ABIDE_TITLE__ ?? 'abide app'
12
+ const logo = globalThis.__ABIDE_LOGO__
13
+ const placeholder = 'https://example.com'
14
+
15
+ let url = state(localStorage.getItem(LAST_URL_KEY) ?? '')
16
+ let error = state('')
17
+
18
+ const launchAction = new URLSearchParams(location.search).get('action')
19
+
20
+ /* Two phases so the screen never flashes before a redirect. */
21
+ let phase = state(launchAction === 'start' ? 'splash' : 'connect')
22
+
23
+ let configFields = state([])
24
+ let configValues = state({})
25
+ let showConfig = state(false)
26
+ let savingConfig = state(false)
27
+
28
+ /* Interpret the boot intent once on load. */
29
+ effect(() => {
30
+ if (launchAction === 'start') {
31
+ void start()
32
+ return
33
+ }
34
+ if (launchAction === 'lost') {
35
+ error = 'The server stopped responding.'
36
+ return
37
+ }
38
+ if (launchAction === 'disconnect') {
39
+ void fetch('/__abide/disconnect').catch(() => {})
40
+ }
41
+ })
42
+
43
+ async function connect() {
44
+ const cleaned = url.trim()
45
+ if (!cleaned) {
46
+ return
47
+ }
48
+ await postAndFollow('/connect', { url: cleaned }, 'Could not connect', () => {
49
+ localStorage.setItem(LAST_URL_KEY, cleaned)
50
+ })
51
+ }
52
+
53
+ async function postAndFollow(path, body, failure, onSuccess) {
54
+ error = ''
55
+ phase = 'splash'
56
+ try {
57
+ const response = await fetch(path, {
58
+ method: 'POST',
59
+ ...(body === undefined
60
+ ? {}
61
+ : { headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }),
62
+ })
63
+ if (!response.ok) {
64
+ const reply = await response.json()
65
+ throw new Error(reply.error ?? `${path.slice(1)} failed (${response.status})`)
66
+ }
67
+ const { redirect } = await response.json()
68
+ onSuccess?.()
69
+ location.href = redirect
70
+ } catch (cause) {
71
+ error = `${failure}: ${String(cause)}`
72
+ phase = 'connect'
73
+ }
74
+ }
75
+
76
+ async function start() {
77
+ error = ''
78
+ const config = await loadConfig().catch(() => undefined)
79
+ if (config) {
80
+ configFields = config.fields
81
+ configValues = { ...config.values }
82
+ phase = 'connect'
83
+ showConfig = true
84
+ return
85
+ }
86
+ await boot()
87
+ }
88
+
89
+ async function boot() {
90
+ await postAndFollow('/start', undefined, 'Could not start the server')
91
+ }
92
+
93
+ async function loadConfig() {
94
+ const response = await fetch('/__abide/config')
95
+ const { schema, values } = await response.json()
96
+ if (!schema) {
97
+ return undefined
98
+ }
99
+ return { fields: fieldsFromSchema(schema), values: values ?? {} }
100
+ }
101
+
102
+ function fieldsFromSchema(schema) {
103
+ const properties = schema.properties ?? {}
104
+ const required = new Set(schema.required ?? [])
105
+ return Object.entries(properties).map(([key, property]) => ({
106
+ key,
107
+ label: property.title ?? key,
108
+ description: property.description,
109
+ inputType: inputType(property),
110
+ required: required.has(key),
111
+ }))
112
+ }
113
+
114
+ function inputType(property) {
115
+ if (property.type === 'boolean') {
116
+ return 'checkbox'
117
+ }
118
+ if (property.type === 'number' || property.type === 'integer') {
119
+ return 'number'
120
+ }
121
+ if (property.format === 'password') {
122
+ return 'password'
123
+ }
124
+ return 'text'
125
+ }
126
+
127
+ async function saveConfig() {
128
+ error = ''
129
+ savingConfig = true
130
+ try {
131
+ const response = await fetch('/__abide/config', {
132
+ method: 'POST',
133
+ headers: { 'content-type': 'application/json' },
134
+ body: JSON.stringify({ values: configValues }),
135
+ })
136
+ if (!response.ok) {
137
+ throw new Error(`save failed (${response.status})`)
138
+ }
139
+ showConfig = false
140
+ savingConfig = false
141
+ await boot()
142
+ } catch (cause) {
143
+ error = `Could not save settings: ${String(cause)}`
144
+ savingConfig = false
145
+ }
146
+ }
147
+ </script>
148
+
149
+ <template if={phase === 'splash'}>
150
+ <div class="flex min-h-screen items-center justify-center bg-gray-50 dark:bg-gray-950">
151
+ <template if={logo}>
152
+ <img src={logo} alt="" class="h-16 w-16 rounded-xl object-contain opacity-90">
153
+ </template>
154
+ </div>
155
+ <template else>
156
+ <main class="flex min-h-screen items-center justify-center bg-gray-50 p-6 text-gray-900 dark:bg-gray-950 dark:text-gray-100">
157
+ <div class="w-full max-w-sm rounded-2xl bg-white p-8 shadow-sm ring-1 ring-gray-200 dark:bg-gray-900 dark:ring-gray-800">
158
+ <template if={logo}>
159
+ <img src={logo} alt="" class="mx-auto mb-5 h-16 w-16 rounded-xl object-contain">
160
+ </template>
161
+ <h1 class="mb-6 text-center text-xl font-semibold tracking-tight">{heading}</h1>
162
+
163
+ <form class="flex flex-col gap-3" onsubmit={(event) => { event.preventDefault(); void connect() }}>
164
+ <input type="url" bind:value={url} placeholder={placeholder} autocomplete="url"
165
+ class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm outline-none focus:border-gray-900 focus:ring-1 focus:ring-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:focus:border-gray-100 dark:focus:ring-gray-100">
166
+ <button type="submit"
167
+ class="w-full rounded-lg bg-gray-900 px-3 py-2 text-sm font-medium text-white hover:bg-gray-700 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300">
168
+ Connect
169
+ </button>
170
+ </form>
171
+
172
+ <div class="my-5 flex items-center gap-3 text-xs text-gray-400 dark:text-gray-500">
173
+ <span class="h-px flex-1 bg-gray-200 dark:bg-gray-800"></span>
174
+ or
175
+ <span class="h-px flex-1 bg-gray-200 dark:bg-gray-800"></span>
176
+ </div>
177
+
178
+ <button type="button" onclick={() => void start()}
179
+ class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm font-medium hover:bg-gray-50 dark:border-gray-700 dark:hover:bg-gray-800">
180
+ Start server
181
+ </button>
182
+
183
+ <template if={error}>
184
+ <p class="mt-4 text-center text-sm text-red-600 dark:text-red-400">{error}</p>
185
+ </template>
186
+
187
+ <p class="mt-8 text-center text-xs text-gray-400 dark:text-gray-500">
188
+ made with
189
+ <a href="https://github.com/briancray/abide" class="underline hover:text-gray-600 dark:hover:text-gray-300">abide</a>
190
+ </p>
191
+ </div>
192
+ </main>
193
+ </template>
194
+ </template>
195
+
196
+ <template if={showConfig}>
197
+ <div class="fixed inset-0 z-10 flex items-center justify-center bg-black/40 p-6 text-gray-900 dark:text-gray-100">
198
+ <div class="w-full max-w-sm rounded-2xl bg-white p-8 shadow-lg ring-1 ring-gray-200 dark:bg-gray-900 dark:ring-gray-800">
199
+ <h2 class="mb-5 text-lg font-semibold tracking-tight">Set up {heading}</h2>
200
+
201
+ <form class="flex flex-col gap-4" onsubmit={(event) => { event.preventDefault(); void saveConfig() }}>
202
+ <template each={configFields} as="field" key="field.key">
203
+ <label class="flex flex-col gap-1 text-sm">
204
+ <span class="font-medium">{field.label}</span>
205
+ <template if={field.inputType === 'checkbox'}>
206
+ <input type="checkbox" onchange={(event) => { configValues[field.key] = event.currentTarget.checked ? 'true' : 'false' }}
207
+ class="mt-1 size-4 self-start rounded border-gray-300 dark:border-gray-700">
208
+ <template else>
209
+ <input type={field.inputType} value={configValues[field.key]} oninput={(event) => { configValues[field.key] = event.currentTarget.value }}
210
+ class="w-full rounded-lg border border-gray-300 px-3 py-2 text-sm outline-none focus:border-gray-900 focus:ring-1 focus:ring-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:focus:border-gray-100 dark:focus:ring-gray-100">
211
+ </template>
212
+ </template>
213
+ <template if={field.description}>
214
+ <span class="text-xs text-gray-400 dark:text-gray-500">{field.description}</span>
215
+ </template>
216
+ </label>
217
+ </template>
218
+
219
+ <div class="mt-1 flex gap-3">
220
+ <button type="button" onclick={() => { showConfig = false }}
221
+ class="flex-1 rounded-lg border border-gray-300 px-3 py-2 text-sm font-medium hover:bg-gray-50 dark:border-gray-700 dark:hover:bg-gray-800">
222
+ Cancel
223
+ </button>
224
+ <button type="submit"
225
+ class="flex-1 rounded-lg bg-gray-900 px-3 py-2 text-sm font-medium text-white hover:bg-gray-700 disabled:opacity-60 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300">
226
+ Save &amp; start
227
+ </button>
228
+ </div>
229
+ </form>
230
+
231
+ <template if={error}>
232
+ <p class="mt-4 text-center text-sm text-red-600 dark:text-red-400">{error}</p>
233
+ </template>
234
+ </div>
235
+ </div>
236
+ </template>
@@ -0,0 +1,9 @@
1
+ /*
2
+ Tailwind entry for the bundle connect screen. `@import "tailwindcss"` pulls the
3
+ engine in; the explicit `@source` guarantees the default component is scanned for
4
+ utility classes even if automatic source detection misses it. bun-plugin-tailwind
5
+ compiles this at build time; buildDisconnected inlines the result into the served
6
+ HTML so the screen needs zero external requests.
7
+ */
8
+ @import 'tailwindcss';
9
+ @source './disconnected.abide';
@@ -0,0 +1,20 @@
1
+ import { buildWebviewLib } from './buildWebviewLib.ts'
2
+ import { resolveWebviewLib } from './resolveWebviewLib.ts'
3
+
4
+ /*
5
+ Build-time guarantee that a webview library exists, returning its path.
6
+ Tries plain resolution first (an explicit ABIDE_WEBVIEW_LIB, a bundle-local
7
+ copy, or a previously built cache); on a miss it compiles the vendored
8
+ header for the host (buildWebviewLib) and caches the result.
9
+
10
+ Used by `abide bundle` (bundleApp), which runs under bun on a developer's
11
+ machine — never by the compiled launcher, which only ever resolves the copy
12
+ shipped beside it and must not invoke a compiler on an end user's machine.
13
+ */
14
+ export async function ensureWebviewLib(cwd: string = process.cwd()): Promise<string> {
15
+ try {
16
+ return await resolveWebviewLib(cwd)
17
+ } catch {
18
+ return await buildWebviewLib()
19
+ }
20
+ }