@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.
- package/CHANGELOG.md +607 -0
- package/LICENSE +21 -0
- package/README.md +154 -0
- package/bin/abide.ts +212 -0
- package/package.json +155 -0
- package/src/abideLsp.ts +211 -0
- package/src/abideModules.d.ts +8 -0
- package/src/abideResolverPlugin.ts +923 -0
- package/src/appEntry.ts +151 -0
- package/src/assets/app.html +12 -0
- package/src/build.ts +143 -0
- package/src/buildCli.ts +127 -0
- package/src/buildDisconnected.ts +118 -0
- package/src/bundleApp.ts +147 -0
- package/src/bundleDisconnectedEntry.ts +14 -0
- package/src/checkAbide.ts +77 -0
- package/src/cliEntry.ts +25 -0
- package/src/clientBuildPlugins.ts +33 -0
- package/src/clientEntry.ts +17 -0
- package/src/compile.ts +63 -0
- package/src/controlServerWorker.ts +426 -0
- package/src/devEntry.ts +250 -0
- package/src/discoveryEntry.ts +81 -0
- package/src/lib/bundle/BundleMenu.ts +12 -0
- package/src/lib/bundle/BundleMenuItem.ts +25 -0
- package/src/lib/bundle/BundleWindow.ts +37 -0
- package/src/lib/bundle/WEBVIEW_BUILD_REVISION.ts +9 -0
- package/src/lib/bundle/WEBVIEW_VERSION.ts +7 -0
- package/src/lib/bundle/bindConnectedFlag.ts +29 -0
- package/src/lib/bundle/bindRequestNavigate.ts +34 -0
- package/src/lib/bundle/buildWebviewLib.ts +111 -0
- package/src/lib/bundle/bundled.ts +35 -0
- package/src/lib/bundle/disconnected.abide +236 -0
- package/src/lib/bundle/disconnected.css +9 -0
- package/src/lib/bundle/ensureWebviewLib.ts +20 -0
- package/src/lib/bundle/exitWithParent.ts +28 -0
- package/src/lib/bundle/infoPlist.ts +46 -0
- package/src/lib/bundle/installDownloads.ts +24 -0
- package/src/lib/bundle/installMacMenu.ts +39 -0
- package/src/lib/bundle/listenLocalControlServer.ts +19 -0
- package/src/lib/bundle/native/abideMenu.mm +422 -0
- package/src/lib/bundle/native/webview.h +4557 -0
- package/src/lib/bundle/onMenu.ts +42 -0
- package/src/lib/bundle/openWebview.ts +104 -0
- package/src/lib/bundle/pngToIcns.ts +47 -0
- package/src/lib/bundle/probeAbideServer.ts +57 -0
- package/src/lib/bundle/resolveServerBinary.ts +12 -0
- package/src/lib/bundle/resolveWebviewLib.ts +53 -0
- package/src/lib/bundle/serverBinaryFilename.ts +8 -0
- package/src/lib/bundle/signMacApp.ts +37 -0
- package/src/lib/bundle/spawnEmbeddedServer.ts +64 -0
- package/src/lib/bundle/stableLocalPort.ts +19 -0
- package/src/lib/bundle/waitForServer.ts +23 -0
- package/src/lib/bundle/webviewCachePath.ts +23 -0
- package/src/lib/bundle/webviewLibName.ts +11 -0
- package/src/lib/cli/connectToServer.ts +23 -0
- package/src/lib/cli/createClient.ts +108 -0
- package/src/lib/cli/dispatchCommand.ts +71 -0
- package/src/lib/cli/loadEnvFromBinaryDir.ts +15 -0
- package/src/lib/cli/parseArgvForRpc.ts +100 -0
- package/src/lib/cli/printHelp.ts +119 -0
- package/src/lib/cli/printSessionHelp.ts +27 -0
- package/src/lib/cli/printSessionStatus.ts +21 -0
- package/src/lib/cli/printTrimmed.ts +8 -0
- package/src/lib/cli/printValue.ts +10 -0
- package/src/lib/cli/resolveCliTarget.ts +48 -0
- package/src/lib/cli/runCli.ts +176 -0
- package/src/lib/cli/runSession.ts +108 -0
- package/src/lib/cli/startLocalInstance.ts +14 -0
- package/src/lib/cli/tokenizeLine.ts +51 -0
- package/src/lib/cli/types/CliManifest.ts +9 -0
- package/src/lib/cli/types/CliManifestEntry.ts +17 -0
- package/src/lib/cli/types/CliTarget.ts +13 -0
- package/src/lib/mcp/annotationsForMethod.ts +29 -0
- package/src/lib/mcp/createMcpResourceServer.ts +102 -0
- package/src/lib/mcp/createMcpServer.ts +48 -0
- package/src/lib/mcp/dispatchMcpRequest.ts +138 -0
- package/src/lib/mcp/mcpResourceServerSlot.ts +18 -0
- package/src/lib/mcp/mcpSurface.ts +295 -0
- package/src/lib/mcp/toolResultFromResponse.ts +66 -0
- package/src/lib/mcp/types/JsonRpcRequest.ts +12 -0
- package/src/lib/mcp/types/JsonRpcResponse.ts +20 -0
- package/src/lib/mcp/types/McpResourceContents.ts +10 -0
- package/src/lib/mcp/types/McpResourceDescriptor.ts +6 -0
- package/src/lib/mcp/types/McpResourceServer.ts +12 -0
- package/src/lib/mcp/types/McpServer.ts +9 -0
- package/src/lib/mcp/types/McpServerOptions.ts +16 -0
- package/src/lib/server/AppModule.ts +47 -0
- package/src/lib/server/DELETE.ts +10 -0
- package/src/lib/server/GET.ts +10 -0
- package/src/lib/server/HEAD.ts +10 -0
- package/src/lib/server/PATCH.ts +10 -0
- package/src/lib/server/POST.ts +10 -0
- package/src/lib/server/PUT.ts +10 -0
- package/src/lib/server/agent.ts +86 -0
- package/src/lib/server/appDataDir.ts +16 -0
- package/src/lib/server/cli/buildEnvContent.ts +19 -0
- package/src/lib/server/cli/createTarGz.ts +77 -0
- package/src/lib/server/cli/handleCliDownload.ts +150 -0
- package/src/lib/server/cli/handleCliInstall.ts +37 -0
- package/src/lib/server/cli/installScript.ts +31 -0
- package/src/lib/server/cli/maxSourceMtime.ts +26 -0
- package/src/lib/server/cookies.ts +30 -0
- package/src/lib/server/env.ts +51 -0
- package/src/lib/server/error.ts +73 -0
- package/src/lib/server/json.ts +42 -0
- package/src/lib/server/jsonl.ts +47 -0
- package/src/lib/server/prompts/definePrompt.ts +21 -0
- package/src/lib/server/prompts/promptRegistry.ts +9 -0
- package/src/lib/server/prompts/registerPrompt.ts +6 -0
- package/src/lib/server/prompts/renderPromptTemplate.ts +17 -0
- package/src/lib/server/prompts/types/Prompt.ts +13 -0
- package/src/lib/server/prompts/types/PromptOptions.ts +12 -0
- package/src/lib/server/prompts/types/PromptRegistryEntry.ts +13 -0
- package/src/lib/server/prompts/types/PromptRoutes.ts +10 -0
- package/src/lib/server/reachable.ts +45 -0
- package/src/lib/server/redirect.ts +43 -0
- package/src/lib/server/request.ts +19 -0
- package/src/lib/server/rpc/defineVerb.ts +210 -0
- package/src/lib/server/rpc/dispatchVerbInProcess.ts +46 -0
- package/src/lib/server/rpc/findVerbByCommandName.ts +18 -0
- package/src/lib/server/rpc/parseArgs.ts +127 -0
- package/src/lib/server/rpc/readBodyWithinLimit.ts +44 -0
- package/src/lib/server/rpc/registerVerb.ts +6 -0
- package/src/lib/server/rpc/runWithVerbTimeout.ts +49 -0
- package/src/lib/server/rpc/types/RemoteHandler.ts +27 -0
- package/src/lib/server/rpc/types/RemoteRoutes.ts +13 -0
- package/src/lib/server/rpc/types/TypedResponse.ts +18 -0
- package/src/lib/server/rpc/types/VerbHelper.ts +87 -0
- package/src/lib/server/rpc/types/VerbRegistryEntry.ts +35 -0
- package/src/lib/server/rpc/unprocessed.ts +14 -0
- package/src/lib/server/rpc/verbRegistry.ts +11 -0
- package/src/lib/server/runtime/DEFAULT_PORT.ts +6 -0
- package/src/lib/server/runtime/DEV_READY_MESSAGE.ts +6 -0
- package/src/lib/server/runtime/DEV_REBUILD_MESSAGE.ts +4 -0
- package/src/lib/server/runtime/DEV_RELOAD_CLIENT_SCRIPT.ts +107 -0
- package/src/lib/server/runtime/SSR_SWAP_SCRIPT.ts +16 -0
- package/src/lib/server/runtime/acceptsGzip.ts +24 -0
- package/src/lib/server/runtime/buildCacheSnapshot.ts +61 -0
- package/src/lib/server/runtime/buildHealthPayload.ts +34 -0
- package/src/lib/server/runtime/buildInspectorSurface.ts +37 -0
- package/src/lib/server/runtime/buildOpenApiSpec.ts +106 -0
- package/src/lib/server/runtime/cacheControlForAsset.ts +22 -0
- package/src/lib/server/runtime/containsTraversal.ts +37 -0
- package/src/lib/server/runtime/createAppAssetServer.ts +76 -0
- package/src/lib/server/runtime/createAssetHeaderCache.ts +31 -0
- package/src/lib/server/runtime/createPublicAssetServer.ts +67 -0
- package/src/lib/server/runtime/createReachable.ts +109 -0
- package/src/lib/server/runtime/createRouteDispatcher.ts +127 -0
- package/src/lib/server/runtime/createServer.ts +674 -0
- package/src/lib/server/runtime/createUiPageRenderer.ts +181 -0
- package/src/lib/server/runtime/crossOriginForbidden.ts +17 -0
- package/src/lib/server/runtime/crossOriginGate.ts +29 -0
- package/src/lib/server/runtime/devClientFingerprint.ts +117 -0
- package/src/lib/server/runtime/devHotModuleResponse.ts +40 -0
- package/src/lib/server/runtime/devReloadResponse.ts +41 -0
- package/src/lib/server/runtime/disableIdleTimeoutForStream.ts +27 -0
- package/src/lib/server/runtime/envSchemaStore.ts +15 -0
- package/src/lib/server/runtime/findOpenPort.ts +21 -0
- package/src/lib/server/runtime/getActiveServer.ts +6 -0
- package/src/lib/server/runtime/globToPathSet.ts +29 -0
- package/src/lib/server/runtime/gzipResponse.ts +46 -0
- package/src/lib/server/runtime/inProcessServer.ts +20 -0
- package/src/lib/server/runtime/internalErrorResponse.ts +25 -0
- package/src/lib/server/runtime/isCrossOriginRequest.ts +23 -0
- package/src/lib/server/runtime/listenOnOpenPort.ts +36 -0
- package/src/lib/server/runtime/logExposedSurfaces.ts +156 -0
- package/src/lib/server/runtime/maybeMountInspector.ts +97 -0
- package/src/lib/server/runtime/mimeForExtension.ts +14 -0
- package/src/lib/server/runtime/pageUrlFromStore.ts +15 -0
- package/src/lib/server/runtime/parseIdleTimeout.ts +10 -0
- package/src/lib/server/runtime/parsePort.ts +11 -0
- package/src/lib/server/runtime/registryManifests.ts +66 -0
- package/src/lib/server/runtime/requestContext.ts +5 -0
- package/src/lib/server/runtime/resolvePageSnapshot.ts +25 -0
- package/src/lib/server/runtime/respondWithEmbeddedAsset.ts +18 -0
- package/src/lib/server/runtime/runWithRequestScope.ts +150 -0
- package/src/lib/server/runtime/safeJsonForScript.ts +17 -0
- package/src/lib/server/runtime/serializeCacheSnapshot.ts +45 -0
- package/src/lib/server/runtime/serverSlot.ts +13 -0
- package/src/lib/server/runtime/setActiveServer.ts +6 -0
- package/src/lib/server/runtime/snapshotEntryFromCache.ts +83 -0
- package/src/lib/server/runtime/streamCacheResolutions.ts +37 -0
- package/src/lib/server/runtime/streamFromIterator.ts +86 -0
- package/src/lib/server/runtime/types/Assets.ts +6 -0
- package/src/lib/server/runtime/types/DevReloadStamp.ts +18 -0
- package/src/lib/server/runtime/types/InspectorCacheEntry.ts +24 -0
- package/src/lib/server/runtime/types/InspectorCacheSnapshot.ts +11 -0
- package/src/lib/server/runtime/types/InspectorContext.ts +30 -0
- package/src/lib/server/runtime/types/InspectorSocket.ts +17 -0
- package/src/lib/server/runtime/types/InspectorSurface.ts +13 -0
- package/src/lib/server/runtime/types/InspectorVerb.ts +27 -0
- package/src/lib/server/runtime/types/RequestStore.ts +55 -0
- package/src/lib/server/runtime/warnUnguardedMcp.ts +32 -0
- package/src/lib/server/runtime/withResponseDefaults.ts +24 -0
- package/src/lib/server/server.ts +33 -0
- package/src/lib/server/socket.ts +32 -0
- package/src/lib/server/sockets/createSocketDispatcher.ts +337 -0
- package/src/lib/server/sockets/defineSocket.ts +179 -0
- package/src/lib/server/sockets/lookupSocket.ts +6 -0
- package/src/lib/server/sockets/registerSocket.ts +6 -0
- package/src/lib/server/sockets/socketOperations.ts +36 -0
- package/src/lib/server/sockets/socketRegistry.ts +9 -0
- package/src/lib/server/sockets/types/Socket.ts +23 -0
- package/src/lib/server/sockets/types/SocketClientFrame.ts +19 -0
- package/src/lib/server/sockets/types/SocketOperation.ts +22 -0
- package/src/lib/server/sockets/types/SocketOptions.ts +26 -0
- package/src/lib/server/sockets/types/SocketRegistryEntry.ts +19 -0
- package/src/lib/server/sockets/types/SocketRoutes.ts +10 -0
- package/src/lib/server/sockets/types/SocketServerFrame.ts +24 -0
- package/src/lib/server/sse.ts +54 -0
- package/src/lib/shared/ABIDE_PACKAGE_NAME.ts +7 -0
- package/src/lib/shared/ABIDE_VERSION.ts +9 -0
- package/src/lib/shared/CACHE_CONTROL_VALUES.ts +16 -0
- package/src/lib/shared/CACHE_WRAPPED.ts +8 -0
- package/src/lib/shared/CLI_PATH.ts +7 -0
- package/src/lib/shared/DEV_HOT_PREFIX.ts +7 -0
- package/src/lib/shared/DEV_RELOAD_PATH.ts +6 -0
- package/src/lib/shared/HEALTH_PATH.ts +7 -0
- package/src/lib/shared/HttpError.ts +20 -0
- package/src/lib/shared/IDENTITY_PATH.ts +6 -0
- package/src/lib/shared/INSPECTOR_PATH.ts +7 -0
- package/src/lib/shared/NAV_HEADER.ts +8 -0
- package/src/lib/shared/OFFLINE_HEADER.ts +8 -0
- package/src/lib/shared/REMOTE_FUNCTION.ts +8 -0
- package/src/lib/shared/REPLAYABLE_METHODS.ts +12 -0
- package/src/lib/shared/SOCKETS_PATH.ts +7 -0
- package/src/lib/shared/STREAMING_CONTENT_TYPES.ts +11 -0
- package/src/lib/shared/SocketDisconnectedError.ts +13 -0
- package/src/lib/shared/TEXT_PLAIN.ts +7 -0
- package/src/lib/shared/abideImportName.ts +44 -0
- package/src/lib/shared/abideLog.ts +38 -0
- package/src/lib/shared/activeCacheStore.ts +20 -0
- package/src/lib/shared/activePage.ts +25 -0
- package/src/lib/shared/appDataDir.ts +34 -0
- package/src/lib/shared/appNameSlot.ts +10 -0
- package/src/lib/shared/basePath.ts +10 -0
- package/src/lib/shared/basePathFromAppUrl.ts +20 -0
- package/src/lib/shared/baseSlot.ts +14 -0
- package/src/lib/shared/binaryDirEnvPath.ts +12 -0
- package/src/lib/shared/browserClientFlags.ts +10 -0
- package/src/lib/shared/buildRpcProxy.ts +39 -0
- package/src/lib/shared/buildRpcRequest.ts +70 -0
- package/src/lib/shared/buildSocketOverChannel.ts +58 -0
- package/src/lib/shared/bundleLayout.ts +36 -0
- package/src/lib/shared/cache.ts +951 -0
- package/src/lib/shared/cacheEntryFromSnapshot.ts +59 -0
- package/src/lib/shared/cacheStoreSlot.ts +16 -0
- package/src/lib/shared/cacheStores.ts +10 -0
- package/src/lib/shared/canonicalJson.ts +63 -0
- package/src/lib/shared/carriesBodyArgs.ts +13 -0
- package/src/lib/shared/clearLastConnection.ts +7 -0
- package/src/lib/shared/commandNameForUrl.ts +17 -0
- package/src/lib/shared/createCacheStore.ts +104 -0
- package/src/lib/shared/createChannelLog.ts +122 -0
- package/src/lib/shared/createLifecycleChannel.ts +56 -0
- package/src/lib/shared/createLivenessWatch.ts +118 -0
- package/src/lib/shared/createPushIterator.ts +127 -0
- package/src/lib/shared/createRemoteFunction.ts +122 -0
- package/src/lib/shared/createSubscriber.ts +55 -0
- package/src/lib/shared/createTraceContext.ts +21 -0
- package/src/lib/shared/dataDirEnvPath.ts +12 -0
- package/src/lib/shared/decodeResponse.ts +47 -0
- package/src/lib/shared/detectTarget.ts +27 -0
- package/src/lib/shared/detectVerbMethod.ts +17 -0
- package/src/lib/shared/emitLogRecord.ts +190 -0
- package/src/lib/shared/exeSuffix.ts +9 -0
- package/src/lib/shared/exitOnBuildFailure.ts +17 -0
- package/src/lib/shared/extraForwardHeaders.ts +16 -0
- package/src/lib/shared/fileStem.ts +9 -0
- package/src/lib/shared/findExportCallSite.ts +476 -0
- package/src/lib/shared/formatTraceparent.ts +6 -0
- package/src/lib/shared/forwardHeaders.ts +44 -0
- package/src/lib/shared/getRemoteMeta.ts +5 -0
- package/src/lib/shared/globalCacheStore.ts +15 -0
- package/src/lib/shared/globalCacheStoreSlot.ts +14 -0
- package/src/lib/shared/health.ts +179 -0
- package/src/lib/shared/healthReadSlot.ts +11 -0
- package/src/lib/shared/healthSeedSlot.ts +12 -0
- package/src/lib/shared/html.ts +38 -0
- package/src/lib/shared/importNamesToStrip.ts +13 -0
- package/src/lib/shared/invalidateEvent.ts +11 -0
- package/src/lib/shared/invalidateTripwire.ts +40 -0
- package/src/lib/shared/isAbideHealthPayload.ts +11 -0
- package/src/lib/shared/isCompileTarget.ts +15 -0
- package/src/lib/shared/isDebugEnabled.ts +26 -0
- package/src/lib/shared/isDebugNegated.ts +19 -0
- package/src/lib/shared/isModuleNotFound.ts +16 -0
- package/src/lib/shared/isReadOnlyMethod.ts +14 -0
- package/src/lib/shared/isReplayableMethod.ts +7 -0
- package/src/lib/shared/isStreamingResponse.ts +11 -0
- package/src/lib/shared/isSubscribable.ts +15 -0
- package/src/lib/shared/jsonSchemaForPromptArguments.ts +29 -0
- package/src/lib/shared/jsonSchemaForSchema.ts +39 -0
- package/src/lib/shared/jsonlErrorFrame.ts +24 -0
- package/src/lib/shared/keyForRemoteCall.ts +29 -0
- package/src/lib/shared/keyMatchesPrefix.ts +9 -0
- package/src/lib/shared/lastConnectionPath.ts +7 -0
- package/src/lib/shared/layoutChainForRoute.ts +22 -0
- package/src/lib/shared/loadEnvFile.ts +17 -0
- package/src/lib/shared/loadEnvFromDataDir.ts +14 -0
- package/src/lib/shared/log.ts +24 -0
- package/src/lib/shared/logClosingRecord.ts +28 -0
- package/src/lib/shared/logTapSlot.ts +13 -0
- package/src/lib/shared/manifestModule.ts +39 -0
- package/src/lib/shared/matchesDebugPattern.ts +16 -0
- package/src/lib/shared/memoizeByKey.ts +32 -0
- package/src/lib/shared/normalizeTarget.ts +10 -0
- package/src/lib/shared/online.ts +51 -0
- package/src/lib/shared/page.ts +30 -0
- package/src/lib/shared/pageSlot.ts +17 -0
- package/src/lib/shared/pageUrlForFile.ts +14 -0
- package/src/lib/shared/parseBoundedEnvInt.ts +20 -0
- package/src/lib/shared/parseDebugPatterns.ts +21 -0
- package/src/lib/shared/parseEnv.ts +30 -0
- package/src/lib/shared/parsePromptMarkdown.ts +35 -0
- package/src/lib/shared/parseRouteSegments.ts +22 -0
- package/src/lib/shared/parseTraceparent.ts +26 -0
- package/src/lib/shared/pending.ts +30 -0
- package/src/lib/shared/prepareRpcModule.ts +59 -0
- package/src/lib/shared/prepareSocketModule.ts +49 -0
- package/src/lib/shared/probeRegistries.ts +68 -0
- package/src/lib/shared/producerKey.ts +32 -0
- package/src/lib/shared/programNameForPackage.ts +14 -0
- package/src/lib/shared/promptNameForFile.ts +10 -0
- package/src/lib/shared/queryStringFromArgs.ts +27 -0
- package/src/lib/shared/randomHexId.ts +14 -0
- package/src/lib/shared/readEnvFile.ts +15 -0
- package/src/lib/shared/readLastConnection.ts +18 -0
- package/src/lib/shared/readPackageJson.ts +9 -0
- package/src/lib/shared/recordRemoteMeta.ts +5 -0
- package/src/lib/shared/refreshing.ts +31 -0
- package/src/lib/shared/remoteMetaStore.ts +16 -0
- package/src/lib/shared/requestScopeSlot.ts +15 -0
- package/src/lib/shared/resolveClientFlags.ts +20 -0
- package/src/lib/shared/responseErrorText.ts +9 -0
- package/src/lib/shared/rpcTimeoutSlot.ts +9 -0
- package/src/lib/shared/rpcUrlForFile.ts +19 -0
- package/src/lib/shared/runningAsStandaloneBinary.ts +13 -0
- package/src/lib/shared/selectorMatcher.ts +68 -0
- package/src/lib/shared/selectorPrefix.ts +39 -0
- package/src/lib/shared/serializeEnv.ts +18 -0
- package/src/lib/shared/setAppName.ts +5 -0
- package/src/lib/shared/setBaseResolver.ts +6 -0
- package/src/lib/shared/setCacheStoreResolver.ts +6 -0
- package/src/lib/shared/setGlobalCacheStoreResolver.ts +6 -0
- package/src/lib/shared/setPageResolver.ts +7 -0
- package/src/lib/shared/setRequestScopeResolver.ts +6 -0
- package/src/lib/shared/snippet.ts +25 -0
- package/src/lib/shared/socketNameForFile.ts +11 -0
- package/src/lib/shared/socketTapSlot.ts +12 -0
- package/src/lib/shared/sseErrorFrame.ts +29 -0
- package/src/lib/shared/streamResponse.ts +169 -0
- package/src/lib/shared/stripImport.ts +27 -0
- package/src/lib/shared/subscribableFromResponse.ts +51 -0
- package/src/lib/shared/tailProbeSlot.ts +16 -0
- package/src/lib/shared/toBunRoutePattern.ts +28 -0
- package/src/lib/shared/toScopeSet.ts +4 -0
- package/src/lib/shared/trace.ts +16 -0
- package/src/lib/shared/types/CacheEntry.ts +84 -0
- package/src/lib/shared/types/CacheInvalidation.ts +9 -0
- package/src/lib/shared/types/CacheOnContext.ts +25 -0
- package/src/lib/shared/types/CacheOptions.ts +39 -0
- package/src/lib/shared/types/CacheSelector.ts +17 -0
- package/src/lib/shared/types/CacheSnapshot.ts +16 -0
- package/src/lib/shared/types/CacheSnapshotEntry.ts +17 -0
- package/src/lib/shared/types/CacheStats.ts +13 -0
- package/src/lib/shared/types/CacheStore.ts +39 -0
- package/src/lib/shared/types/ChannelLog.ts +13 -0
- package/src/lib/shared/types/ClientFlags.ts +11 -0
- package/src/lib/shared/types/CompileTarget.ts +6 -0
- package/src/lib/shared/types/FrameworkLog.ts +13 -0
- package/src/lib/shared/types/HttpVerb.ts +1 -0
- package/src/lib/shared/types/LastConnection.ts +9 -0
- package/src/lib/shared/types/Log.ts +13 -0
- package/src/lib/shared/types/LogRecord.ts +42 -0
- package/src/lib/shared/types/LogVoice.ts +7 -0
- package/src/lib/shared/types/PageSnapshot.ts +14 -0
- package/src/lib/shared/types/PromptArgument.ts +12 -0
- package/src/lib/shared/types/RawRemoteFunction.ts +14 -0
- package/src/lib/shared/types/RemoteCallable.ts +12 -0
- package/src/lib/shared/types/RemoteFunction.ts +47 -0
- package/src/lib/shared/types/ReplayableMethod.ts +7 -0
- package/src/lib/shared/types/RequestScopeInfo.ts +16 -0
- package/src/lib/shared/types/RpcInvoker.ts +6 -0
- package/src/lib/shared/types/SocketChannel.ts +17 -0
- package/src/lib/shared/types/SocketSubCallbacks.ts +13 -0
- package/src/lib/shared/types/StandardSchemaV1.ts +56 -0
- package/src/lib/shared/types/StreamedResolution.ts +10 -0
- package/src/lib/shared/types/Subscribable.ts +26 -0
- package/src/lib/shared/types/TailHooks.ts +12 -0
- package/src/lib/shared/types/TailOptions.ts +10 -0
- package/src/lib/shared/types/TraceContext.ts +17 -0
- package/src/lib/shared/url.ts +118 -0
- package/src/lib/shared/withBase.ts +11 -0
- package/src/lib/shared/withBaseUrl.ts +17 -0
- package/src/lib/shared/withJsonSchema.ts +21 -0
- package/src/lib/shared/writeDts.ts +12 -0
- package/src/lib/shared/writeHealthDts.ts +36 -0
- package/src/lib/shared/writeLastConnection.ts +13 -0
- package/src/lib/shared/writePublicAssetsDts.ts +31 -0
- package/src/lib/shared/writeRoutesDts.ts +73 -0
- package/src/lib/shared/writeRpcDts.ts +49 -0
- package/src/lib/shared/writeTestRpcDts.ts +45 -0
- package/src/lib/shared/writeTestSocketsDts.ts +34 -0
- package/src/lib/test/assertAgentFrameConformance.ts +73 -0
- package/src/lib/test/createScriptedSurface.ts +45 -0
- package/src/lib/test/createTestApp.ts +203 -0
- package/src/lib/test/createTestSocketChannel.ts +142 -0
- package/src/lib/ui/README.md +86 -0
- package/src/lib/ui/compile/SSR_ESCAPE.ts +25 -0
- package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +36 -0
- package/src/lib/ui/compile/VOID_TAGS.ts +21 -0
- package/src/lib/ui/compile/abideUiPlugin.ts +65 -0
- package/src/lib/ui/compile/analyzeComponent.ts +117 -0
- package/src/lib/ui/compile/assetModulesFile.ts +32 -0
- package/src/lib/ui/compile/branchElements.ts +50 -0
- package/src/lib/ui/compile/collectAbideDiagnostics.ts +59 -0
- package/src/lib/ui/compile/compileComponent.ts +20 -0
- package/src/lib/ui/compile/compileModule.ts +116 -0
- package/src/lib/ui/compile/compileSSR.ts +36 -0
- package/src/lib/ui/compile/compileShadow.ts +352 -0
- package/src/lib/ui/compile/createShadowLanguageService.ts +197 -0
- package/src/lib/ui/compile/createShadowProgram.ts +96 -0
- package/src/lib/ui/compile/decodeHtmlEntities.ts +49 -0
- package/src/lib/ui/compile/desugarSignals.ts +133 -0
- package/src/lib/ui/compile/escapeHtml.ts +15 -0
- package/src/lib/ui/compile/generateBuild.ts +638 -0
- package/src/lib/ui/compile/generateSSR.ts +380 -0
- package/src/lib/ui/compile/groupBindParts.ts +28 -0
- package/src/lib/ui/compile/hoistCells.ts +120 -0
- package/src/lib/ui/compile/loadShadowTsConfig.ts +31 -0
- package/src/lib/ui/compile/lowerDocAccess.ts +202 -0
- package/src/lib/ui/compile/nearestProjectRoot.ts +16 -0
- package/src/lib/ui/compile/parseTemplate.ts +396 -0
- package/src/lib/ui/compile/partitionSlots.ts +36 -0
- package/src/lib/ui/compile/prepareNestedScript.ts +42 -0
- package/src/lib/ui/compile/remapShadowDiagnostic.ts +30 -0
- package/src/lib/ui/compile/renameSignalRefs.ts +85 -0
- package/src/lib/ui/compile/resolveAbideImports.ts +29 -0
- package/src/lib/ui/compile/scopeCss.ts +115 -0
- package/src/lib/ui/compile/shadowNaming.ts +11 -0
- package/src/lib/ui/compile/sourceToShadowOffset.ts +24 -0
- package/src/lib/ui/compile/staticAttrValue.ts +13 -0
- package/src/lib/ui/compile/stripEffects.ts +32 -0
- package/src/lib/ui/compile/types/AbideDiagnostic.ts +14 -0
- package/src/lib/ui/compile/types/AnalyzedComponent.ts +25 -0
- package/src/lib/ui/compile/types/CompiledShadow.ts +15 -0
- package/src/lib/ui/compile/types/TemplateAttr.ts +16 -0
- package/src/lib/ui/compile/types/TemplateNode.ts +78 -0
- package/src/lib/ui/compile/types/TextPart.ts +8 -0
- package/src/lib/ui/derived.ts +28 -0
- package/src/lib/ui/doc.ts +15 -0
- package/src/lib/ui/dom/appendSnippet.ts +34 -0
- package/src/lib/ui/dom/appendStatic.ts +27 -0
- package/src/lib/ui/dom/appendText.ts +114 -0
- package/src/lib/ui/dom/applyResolved.ts +72 -0
- package/src/lib/ui/dom/attach.ts +20 -0
- package/src/lib/ui/dom/attr.ts +19 -0
- package/src/lib/ui/dom/awaitBlock.ts +224 -0
- package/src/lib/ui/dom/cloneStatic.ts +52 -0
- package/src/lib/ui/dom/each.ts +115 -0
- package/src/lib/ui/dom/eachAsync.ts +153 -0
- package/src/lib/ui/dom/hydrate.ts +35 -0
- package/src/lib/ui/dom/mount.ts +29 -0
- package/src/lib/ui/dom/mountChild.ts +33 -0
- package/src/lib/ui/dom/on.ts +15 -0
- package/src/lib/ui/dom/openChild.ts +22 -0
- package/src/lib/ui/dom/openRoot.ts +20 -0
- package/src/lib/ui/dom/switchBlock.ts +75 -0
- package/src/lib/ui/dom/text.ts +20 -0
- package/src/lib/ui/dom/tryBlock.ts +112 -0
- package/src/lib/ui/dom/types/EachRow.ts +3 -0
- package/src/lib/ui/dom/types/SwitchCase.ts +6 -0
- package/src/lib/ui/dom/when.ts +73 -0
- package/src/lib/ui/effect.ts +16 -0
- package/src/lib/ui/installHotBridge.ts +73 -0
- package/src/lib/ui/matchRoute.ts +89 -0
- package/src/lib/ui/navigate.ts +17 -0
- package/src/lib/ui/probeNavigation.ts +33 -0
- package/src/lib/ui/remoteProxy.ts +97 -0
- package/src/lib/ui/renderChain.ts +50 -0
- package/src/lib/ui/renderToStream.ts +104 -0
- package/src/lib/ui/router.ts +286 -0
- package/src/lib/ui/runtime/OUTLET_TAG.ts +8 -0
- package/src/lib/ui/runtime/OWNER.ts +8 -0
- package/src/lib/ui/runtime/REACTIVE_CONTEXT.ts +14 -0
- package/src/lib/ui/runtime/RENDER.ts +23 -0
- package/src/lib/ui/runtime/RESUME.ts +16 -0
- package/src/lib/ui/runtime/applyPatchToTree.ts +41 -0
- package/src/lib/ui/runtime/claimChild.ts +10 -0
- package/src/lib/ui/runtime/clientPage.ts +16 -0
- package/src/lib/ui/runtime/createComputedNode.ts +16 -0
- package/src/lib/ui/runtime/createDoc.ts +177 -0
- package/src/lib/ui/runtime/createEffectNode.ts +58 -0
- package/src/lib/ui/runtime/createSignalNode.ts +16 -0
- package/src/lib/ui/runtime/detachLink.ts +21 -0
- package/src/lib/ui/runtime/endTracking.ts +24 -0
- package/src/lib/ui/runtime/enterRenderPass.ts +12 -0
- package/src/lib/ui/runtime/exitRenderPass.ts +7 -0
- package/src/lib/ui/runtime/firstOutlet.ts +22 -0
- package/src/lib/ui/runtime/flushEffects.ts +17 -0
- package/src/lib/ui/runtime/hotInstances.ts +10 -0
- package/src/lib/ui/runtime/hotReloadEnabled.ts +8 -0
- package/src/lib/ui/runtime/hotReplace.ts +25 -0
- package/src/lib/ui/runtime/nextBlockId.ts +11 -0
- package/src/lib/ui/runtime/pathExists.ts +23 -0
- package/src/lib/ui/runtime/readNode.ts +17 -0
- package/src/lib/ui/runtime/registerHotInstance.ts +23 -0
- package/src/lib/ui/runtime/runNode.ts +28 -0
- package/src/lib/ui/runtime/runtimePath.ts +9 -0
- package/src/lib/ui/runtime/scope.ts +24 -0
- package/src/lib/ui/runtime/toTeardown.ts +26 -0
- package/src/lib/ui/runtime/track.ts +58 -0
- package/src/lib/ui/runtime/trigger.ts +44 -0
- package/src/lib/ui/runtime/types/Cell.ts +5 -0
- package/src/lib/ui/runtime/types/Derived.ts +3 -0
- package/src/lib/ui/runtime/types/Doc.ts +19 -0
- package/src/lib/ui/runtime/types/EffectResult.ts +10 -0
- package/src/lib/ui/runtime/types/HotInstance.ts +14 -0
- package/src/lib/ui/runtime/types/NavVerdict.ts +9 -0
- package/src/lib/ui/runtime/types/Patch.ts +11 -0
- package/src/lib/ui/runtime/types/ReactiveLink.ts +21 -0
- package/src/lib/ui/runtime/types/ReactiveNode.ts +25 -0
- package/src/lib/ui/runtime/types/Route.ts +8 -0
- package/src/lib/ui/runtime/types/RouteLoader.ts +7 -0
- package/src/lib/ui/runtime/types/SsrRender.ts +22 -0
- package/src/lib/ui/runtime/types/State.ts +3 -0
- package/src/lib/ui/runtime/types/Teardown.ts +5 -0
- package/src/lib/ui/runtime/types/UiComponent.ts +16 -0
- package/src/lib/ui/runtime/types/UiProps.ts +15 -0
- package/src/lib/ui/runtime/unlinkDeps.ts +20 -0
- package/src/lib/ui/runtime/untrack.ts +20 -0
- package/src/lib/ui/runtime/valueAtPath.ts +18 -0
- package/src/lib/ui/runtime/writeNode.ts +16 -0
- package/src/lib/ui/socketChannel.ts +227 -0
- package/src/lib/ui/socketProxy.ts +25 -0
- package/src/lib/ui/startClient.ts +58 -0
- package/src/lib/ui/state.ts +25 -0
- package/src/lib/ui/tail.ts +324 -0
- package/src/lib/ui/types/Layouts.ts +9 -0
- package/src/lib/ui/types/Pages.ts +8 -0
- package/src/preload.ts +19 -0
- package/src/scaffold.ts +153 -0
- package/src/serverBuildPlugins.ts +19 -0
- package/src/serverEntry.ts +95 -0
- package/template/bunfig.toml +4 -0
- package/template/package.json +18 -0
- package/template/src/app.ts +28 -0
- package/template/src/bundle/icon.png +0 -0
- package/template/src/cli/banner.txt +3 -0
- package/template/src/cli/footer.txt +1 -0
- package/template/src/server/config.ts +17 -0
- package/template/src/server/rpc/getHello.ts +36 -0
- package/template/src/ui/Layout.abide +19 -0
- package/template/src/ui/app.css +21 -0
- package/template/src/ui/app.html +24 -0
- package/template/src/ui/pages/about/page.abide +9 -0
- package/template/src/ui/pages/page.abide +22 -0
- package/template/test/app.test.ts +30 -0
- package/template/tsconfig.json +18 -0
- package/tsconfig.app.json +17 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChannelLog } from './ChannelLog.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
The public logger: a ChannelLog on the app's own always-on channel (named
|
|
5
|
+
after the app, so every record carries who spoke), plus the factory for
|
|
6
|
+
DEBUG-gated diagnostic channels. Framework voices live on the internal
|
|
7
|
+
abideLog; the closing request record is emitted via internal
|
|
8
|
+
logClosingRecord — neither is part of this surface.
|
|
9
|
+
*/
|
|
10
|
+
export type Log = ChannelLog & {
|
|
11
|
+
/* Diagnostic channel: same shape, tagged with `name`, emits only when DEBUG matches. */
|
|
12
|
+
channel(name: string): ChannelLog
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
One log event, built once per emission and rendered by either formatter
|
|
3
|
+
(tab-separated tsv line or ABIDE_LOG_FORMAT=json). The json rendering of these
|
|
4
|
+
keys is a documented contract — ingestion pipelines (Splunk, Loki) extract
|
|
5
|
+
fields by these names, so renames are breaking changes. Absent context is
|
|
6
|
+
omitted, never null: trace/elapsedMs/method/path exist only inside a request
|
|
7
|
+
scope, status/durationMs only on closing request records, name/spanId only on
|
|
8
|
+
log.trace operation records, stack only when an Error was captured.
|
|
9
|
+
*/
|
|
10
|
+
export type LogRecord = {
|
|
11
|
+
/* Epoch ms; the json format renders it as an ISO timestamp. */
|
|
12
|
+
ts: number
|
|
13
|
+
level: 'info' | 'warn' | 'error'
|
|
14
|
+
msg: string
|
|
15
|
+
/* DEBUG-gated diagnostic channel that emitted this record. */
|
|
16
|
+
channel?: string
|
|
17
|
+
/* Full 32-hex trace id; tsv mode prints the first 8 chars. */
|
|
18
|
+
trace?: string
|
|
19
|
+
/* The emitting request's own trace span id (TraceContext.spanId). Stable across
|
|
20
|
+
every record one request emits, so a consumer can split a multi-request trace
|
|
21
|
+
(a propagated session) back into its individual requests. */
|
|
22
|
+
requestSpan?: string
|
|
23
|
+
/* The span this request descends from (TraceContext.parentSpanId); absent when
|
|
24
|
+
abide started the trace — the journey's root request. Lets a consumer nest
|
|
25
|
+
requests within a trace. */
|
|
26
|
+
parentSpan?: string
|
|
27
|
+
/* Ms since the request scope opened (navigation start in the browser). */
|
|
28
|
+
elapsedMs?: number
|
|
29
|
+
method?: string
|
|
30
|
+
path?: string
|
|
31
|
+
/* Structured payload passed as the second argument. */
|
|
32
|
+
data?: unknown
|
|
33
|
+
/* Closing request record: response status + total duration at settle. */
|
|
34
|
+
status?: number
|
|
35
|
+
durationMs?: number
|
|
36
|
+
/* Closing request record: the request's cache read tallies, frozen at settle. */
|
|
37
|
+
cache?: { hits: number; misses: number; coalesced: number }
|
|
38
|
+
/* log.trace operation record: chosen operation name + minted span id. */
|
|
39
|
+
name?: string
|
|
40
|
+
spanId?: string
|
|
41
|
+
stack?: string
|
|
42
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Presentation hints for the tsv formatter only — the framework's styling
|
|
3
|
+
voices on the 'abide' channel: 'success' paints green, 'detail' dims
|
|
4
|
+
secondary text. Never serialised: the json format renders these records as
|
|
5
|
+
ordinary info lines.
|
|
6
|
+
*/
|
|
7
|
+
export type LogVoice = 'success' | 'detail'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Side-agnostic shape of the active page state: the matched route, its decoded
|
|
3
|
+
params, the live request/location URL, and whether a client SPA navigation is
|
|
4
|
+
in flight. The browser `page` proxy reads its public fields through this; the
|
|
5
|
+
server resolver reads them off the per-request store, the client resolver off
|
|
6
|
+
the module singleton. `navigating` is always false server-side — there is no
|
|
7
|
+
in-flight navigation during a synchronous render.
|
|
8
|
+
*/
|
|
9
|
+
export type PageSnapshot = {
|
|
10
|
+
route: string
|
|
11
|
+
params: Record<string, string>
|
|
12
|
+
url: URL
|
|
13
|
+
navigating: boolean
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
A single declared argument of a markdown prompt, parsed from the file's
|
|
3
|
+
YAML frontmatter `arguments:` list. `name` is the placeholder the body
|
|
4
|
+
interpolates via `{{name}}`; `description` + `required` feed the argument
|
|
5
|
+
list MCP advertises in `prompts/list`. Build-time only — markdown prompts
|
|
6
|
+
carry no runtime schema object, so this drives the generated JSON Schema.
|
|
7
|
+
*/
|
|
8
|
+
export type PromptArgument = {
|
|
9
|
+
name: string
|
|
10
|
+
description?: string
|
|
11
|
+
required?: boolean
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HttpVerb } from './HttpVerb.ts'
|
|
2
|
+
import type { RemoteCallable } from './RemoteCallable.ts'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Bare-response remote function — same call shape as RemoteFunction but
|
|
6
|
+
resolves to the underlying Response without Content-Type decode and
|
|
7
|
+
without throwing on non-2xx. Produced as `.raw` on every RemoteFunction
|
|
8
|
+
so callers that need status / headers / body streaming or want to
|
|
9
|
+
implement custom error handling can opt out of the decode.
|
|
10
|
+
*/
|
|
11
|
+
export type RawRemoteFunction<Args> = RemoteCallable<Args, Response> & {
|
|
12
|
+
readonly method: HttpVerb
|
|
13
|
+
readonly url: string
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Call signature shared by RemoteFunction and RawRemoteFunction. The base
|
|
3
|
+
signature keeps `args` required so a schema'd verb can't silently drop its
|
|
4
|
+
input; when `Args` admits undefined (no-input verbs) an intersected
|
|
5
|
+
optional-arg signature lets call sites write `fn()` instead of
|
|
6
|
+
`fn(undefined)`. Intersection rather than a bare conditional so the type
|
|
7
|
+
stays callable while `Args` is still generic (cache() invokes producers
|
|
8
|
+
before `Args` resolves). FormData is the multipart upload escape hatch —
|
|
9
|
+
see RemoteFunction.
|
|
10
|
+
*/
|
|
11
|
+
export type RemoteCallable<Args, Resolved> = ((args: Args | FormData) => Promise<Resolved>) &
|
|
12
|
+
(undefined extends Args ? (args?: Args | FormData) => Promise<Resolved> : unknown)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ClientFlags } from './ClientFlags.ts'
|
|
2
|
+
import type { HttpVerb } from './HttpVerb.ts'
|
|
3
|
+
import type { RawRemoteFunction } from './RawRemoteFunction.ts'
|
|
4
|
+
import type { RemoteCallable } from './RemoteCallable.ts'
|
|
5
|
+
import type { Subscribable } from './Subscribable.ts'
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Remote function reference produced by GET/POST/... inside an `$rpc/**`
|
|
9
|
+
module and consumed by rpc dispatch, cache(), SSR auto-hydration, and
|
|
10
|
+
direct calls. Same callable signature on server and client — the bundler
|
|
11
|
+
swaps the implementation for browser builds.
|
|
12
|
+
|
|
13
|
+
The plain call resolves to the decoded body shape (sniffed from
|
|
14
|
+
Content-Type) and throws HttpError on non-2xx. `.raw` is a sibling
|
|
15
|
+
RemoteFunction whose call resolves to the underlying Response — same
|
|
16
|
+
method, same url, same args, no decode. Pass `fn.raw` to cache() to
|
|
17
|
+
memoise raw Responses against the same cache key as `fn` (both share one
|
|
18
|
+
stored entry — the decode just happens on the way out for callers of
|
|
19
|
+
`fn`). `.stream(args)` returns an iterable view of the Response body:
|
|
20
|
+
SSE / JSONL handlers yield each frame; non-streaming handlers yield the
|
|
21
|
+
decoded body once then complete. The result is a Subscribable, so it
|
|
22
|
+
can be passed to tail() and shared across reactive consumers.
|
|
23
|
+
For sustained broadcast / pub-sub use the `abide/server/socket` primitive —
|
|
24
|
+
HTTP rpc isn't the place for long-lived multi-publisher subscriptions.
|
|
25
|
+
`.fetch(req)` is the framework's request-dispatch entry point — used by
|
|
26
|
+
the router to invoke the handler from an incoming HTTP request, not
|
|
27
|
+
for user code.
|
|
28
|
+
`crossOrigin` (server-side only, set via the verb's opts) exempts a
|
|
29
|
+
mutating verb from the router's same-origin CSRF gate, accepting browser
|
|
30
|
+
requests whose Origin doesn't match the app's own host.
|
|
31
|
+
*/
|
|
32
|
+
/*
|
|
33
|
+
A body verb (POST/PUT/PATCH) also accepts a FormData in place of typed args:
|
|
34
|
+
buildRpcRequest ships it as a multipart body and the server splits text fields
|
|
35
|
+
into args (still schema-validated) and File parts into files(). FormData is
|
|
36
|
+
stringly-typed, so this is the upload escape hatch — typed object args remain
|
|
37
|
+
the default for everything else.
|
|
38
|
+
*/
|
|
39
|
+
export type RemoteFunction<Args, Return> = RemoteCallable<Args, Return> & {
|
|
40
|
+
readonly method: HttpVerb
|
|
41
|
+
readonly url: string
|
|
42
|
+
readonly clients: ClientFlags
|
|
43
|
+
readonly crossOrigin?: boolean
|
|
44
|
+
readonly raw: RawRemoteFunction<Args>
|
|
45
|
+
stream(args?: Args | FormData): Subscribable<Return>
|
|
46
|
+
fetch(request: Request): Promise<Response>
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Method of a cache entry that may re-fire unprompted — snapshot replay on the
|
|
3
|
+
client, invalidate-policy refetch. Mirrors REPLAYABLE_METHODS (the runtime
|
|
4
|
+
gate; narrow via isReplayableMethod): only GET qualifies, the one safe
|
|
5
|
+
read-only method.
|
|
6
|
+
*/
|
|
7
|
+
export type ReplayableMethod = 'GET'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TraceContext } from './TraceContext.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
The request-scope facts the shared layer reads through requestScopeSlot:
|
|
5
|
+
trace position, elapsed ms since the scope opened (request start on the
|
|
6
|
+
server, navigation start in the browser), and the verb+path that anchors log
|
|
7
|
+
lines. Resolved fresh per read so `elapsedMs` is current at the call.
|
|
8
|
+
*/
|
|
9
|
+
export type RequestScopeInfo = {
|
|
10
|
+
trace: TraceContext
|
|
11
|
+
elapsedMs: number
|
|
12
|
+
method: string
|
|
13
|
+
path: string
|
|
14
|
+
/* The calling client's reported connectivity (server only, from OFFLINE_HEADER); drives server-side online(). Omitted client-side — online() reads navigator there. */
|
|
15
|
+
online?: boolean
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* A verb invoker mirrors the verb's own call: a plain call decodes the body
|
|
2
|
+
(throws HttpError on non-2xx), `.raw` returns the Response untouched. Shared
|
|
3
|
+
by every name→callable RPC proxy (the CLI client, the test harness). */
|
|
4
|
+
export type RpcInvoker = ((args?: unknown) => Promise<unknown>) & {
|
|
5
|
+
raw: (args?: unknown) => Promise<Response>
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SocketSubCallbacks } from './SocketSubCallbacks.ts'
|
|
2
|
+
|
|
3
|
+
/* The multiplexed-ws abstraction a Socket<T> drives: open/close a per-sub
|
|
4
|
+
subscription and publish to a topic. The browser singleton (socketChannel)
|
|
5
|
+
and the test harness (createTestSocketChannel) each implement it;
|
|
6
|
+
buildSocketOverChannel turns either into Socket<T> objects, so the two
|
|
7
|
+
surfaces can't drift on the Socket contract. */
|
|
8
|
+
export type SocketChannel = {
|
|
9
|
+
subscribe(
|
|
10
|
+
sub: string,
|
|
11
|
+
socket: string,
|
|
12
|
+
replay: number | undefined,
|
|
13
|
+
callbacks: SocketSubCallbacks,
|
|
14
|
+
): void
|
|
15
|
+
unsubscribe(sub: string): void
|
|
16
|
+
publish(socket: string, message: unknown): void
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* The callback contract a SocketChannel drives per subscription — how the
|
|
2
|
+
channel hands a sub its frames and lifecycle. Shared by every channel
|
|
3
|
+
implementation (the browser multiplex, the test harness) and the Socket<T>
|
|
4
|
+
builder that wires these onto a push iterator. */
|
|
5
|
+
export type SocketSubCallbacks = {
|
|
6
|
+
onMessage(message: unknown): void
|
|
7
|
+
/* The sub's batched seed from the retained tail (possibly empty) — the replay/live boundary. */
|
|
8
|
+
onReplay(messages: unknown[]): void
|
|
9
|
+
onError(message: string): void
|
|
10
|
+
onEnd(): void
|
|
11
|
+
/* Transport loss (ws close), as opposed to a per-sub server `err` frame — recoverable. */
|
|
12
|
+
onDisconnect(): void
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Mirror of the Standard Schema v1 spec interface (standardschema.dev). Any
|
|
3
|
+
library that implements the spec — zod, valibot, arktype, etc. — produces
|
|
4
|
+
values whose `~standard` property structurally matches this shape, so users
|
|
5
|
+
can pass their existing schemas to verb helpers without an adapter.
|
|
6
|
+
|
|
7
|
+
Kept inline (no `@standard-schema/spec` dep) because the spec is type-only
|
|
8
|
+
and tiny; adding a package for ~30 lines of interface would be churn. The
|
|
9
|
+
namespace pattern below is the spec's own convention — `InferInput` /
|
|
10
|
+
`InferOutput` ride along the same export.
|
|
11
|
+
*/
|
|
12
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
13
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export namespace StandardSchemaV1 {
|
|
17
|
+
export interface Props<Input = unknown, Output = Input> {
|
|
18
|
+
readonly version: 1
|
|
19
|
+
readonly vendor: string
|
|
20
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>
|
|
21
|
+
readonly types?: Types<Input, Output> | undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type Result<Output> = SuccessResult<Output> | FailureResult
|
|
25
|
+
|
|
26
|
+
export interface SuccessResult<Output> {
|
|
27
|
+
readonly value: Output
|
|
28
|
+
readonly issues?: undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FailureResult {
|
|
32
|
+
readonly issues: ReadonlyArray<Issue>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface Issue {
|
|
36
|
+
readonly message: string
|
|
37
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PathSegment {
|
|
41
|
+
readonly key: PropertyKey
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Types<Input = unknown, Output = Input> {
|
|
45
|
+
readonly input: Input
|
|
46
|
+
readonly output: Output
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<
|
|
50
|
+
Schema['~standard']['types']
|
|
51
|
+
>['input']
|
|
52
|
+
|
|
53
|
+
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<
|
|
54
|
+
Schema['~standard']['types']
|
|
55
|
+
>['output']
|
|
56
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CacheSnapshotEntry } from './CacheSnapshotEntry.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Payload of one streamed `window.__abideResolve(...)` call. A full
|
|
5
|
+
`CacheSnapshotEntry` settles the placeholder with warm data; a `{ key, miss }`
|
|
6
|
+
marker means the server couldn't snapshot that body (binary, rejected, evicted)
|
|
7
|
+
so the client settles the placeholder with a live re-fetch instead. Discriminate
|
|
8
|
+
on the `miss` field.
|
|
9
|
+
*/
|
|
10
|
+
export type StreamedResolution = CacheSnapshotEntry | { key: string; miss: true }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TailHooks } from './TailHooks.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
The thing `tail()` reads from: an AsyncIterable carrying a stable `name`
|
|
5
|
+
used as the subscription registry key. Both `Socket<T>` (the declared
|
|
6
|
+
broadcast primitive) and the result of `fn.stream(args)` (per-call HTTP
|
|
7
|
+
stream consumer) satisfy this shape, so tail() can share one iterator
|
|
8
|
+
across multiple readers regardless of source.
|
|
9
|
+
|
|
10
|
+
The name on a Socket comes from the file path under `src/server/sockets/`.
|
|
11
|
+
The name on an fn.stream(args) result is `keyForRemoteCall(method, url,
|
|
12
|
+
args)` — the same key cache() uses — so two readers of the same remote-call
|
|
13
|
+
args dedupe to one underlying fetch.
|
|
14
|
+
|
|
15
|
+
`tail` is the optional retention capability: a source that keeps a tail of
|
|
16
|
+
recent frames hands back an iterable seeded with at most the last `count`
|
|
17
|
+
before going live. Sockets implement it verbatim; one-shot rpc streams omit
|
|
18
|
+
it. The tail() consumer uses it to bound replay to what the reader will
|
|
19
|
+
keep — it never requires it. Implementers must signal `hooks.replayed`
|
|
20
|
+
in-band once the seed portion is delivered (even when empty) so window
|
|
21
|
+
readers can commit atomically; see TailHooks.
|
|
22
|
+
*/
|
|
23
|
+
export interface Subscribable<T> extends AsyncIterable<T> {
|
|
24
|
+
readonly name: string
|
|
25
|
+
tail?(count: number, hooks?: TailHooks): AsyncIterable<T>
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Hooks a tail() reader passes to a Subscribable's retention capability.
|
|
3
|
+
`replayed` must be signalled in-band exactly once per iteration — after the
|
|
4
|
+
last replayed frame, before any live frame, and even when nothing was
|
|
5
|
+
replayed — so a window reader can commit its seed atomically instead of
|
|
6
|
+
guessing where replay ends (an empty replay keeps the reader's held window;
|
|
7
|
+
nothing was replayed, so nothing can duplicate). Sources without the
|
|
8
|
+
capability never see hooks.
|
|
9
|
+
*/
|
|
10
|
+
export interface TailHooks {
|
|
11
|
+
readonly replayed?: () => void
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Window form of `tail()`: `last` is the rolling window size — the reader holds
|
|
3
|
+
the last ≤`last` frames, however they arrived. A source that retains a tail
|
|
4
|
+
(a socket declared with `{ tail: n }`) seeds the window by replaying up to
|
|
5
|
+
`last` retained frames; a source with no retention (an rpc stream, an
|
|
6
|
+
undeclared socket) fills it from live frames only. Integer ≥ 1.
|
|
7
|
+
*/
|
|
8
|
+
export interface TailOptions {
|
|
9
|
+
readonly last: number
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The request's W3C Trace Context position. `traceId` identifies the whole
|
|
3
|
+
end-to-end operation (inherited from an inbound `traceparent` or minted at the
|
|
4
|
+
boundary); `spanId` is the id abide mints for this request — it rides outbound
|
|
5
|
+
`traceparent` headers as the parent of downstream work, and a future span
|
|
6
|
+
exporter materialises the request's root span under this exact id.
|
|
7
|
+
`parentSpanId` preserves the inbound header's span id so that root span can
|
|
8
|
+
parent under the upstream caller; absent when abide started the trace.
|
|
9
|
+
`flags` echo the inbound sampling flags ('01' when abide starts the trace, so
|
|
10
|
+
downstream recorders don't drop what the developer is trying to see).
|
|
11
|
+
*/
|
|
12
|
+
export type TraceContext = {
|
|
13
|
+
traceId: string
|
|
14
|
+
spanId: string
|
|
15
|
+
parentSpanId?: string
|
|
16
|
+
flags: string
|
|
17
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { basePath } from './basePath.ts'
|
|
2
|
+
import type { RouteSegment } from './parseRouteSegments.ts'
|
|
3
|
+
import { parseRouteSegments } from './parseRouteSegments.ts'
|
|
4
|
+
import { queryStringFromArgs } from './queryStringFromArgs.ts'
|
|
5
|
+
|
|
6
|
+
/* `undefined` is allowed and dropped (queryStringFromArgs skips it), so an
|
|
7
|
+
optional field — url('/p', { ref: maybeUndefined }) — types without a guard. */
|
|
8
|
+
type QueryValue = string | number | boolean | undefined
|
|
9
|
+
type Query = Record<string, QueryValue>
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Augmentable rpc map. Codegen emits a `declare module '<importName>/shared/url'`
|
|
13
|
+
block filling this with `'/rpc/<file>': args` for each query-carrying (GET)
|
|
14
|
+
verb, so url('/rpc/search', { q }) types its args against the verb's own
|
|
15
|
+
signature. Empty by default — an absent entry falls through to the page/asset
|
|
16
|
+
branch, so the helper works before the generated d.ts lands.
|
|
17
|
+
*/
|
|
18
|
+
// @readme url
|
|
19
|
+
// biome-ignore lint/suspicious/noEmptyInterface: augmented by the generated rpc.d.ts
|
|
20
|
+
export interface RpcRoutes {}
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Augmentable autocomplete sets — keys only, values unused. The page codegen
|
|
24
|
+
(writeRoutesDts) fills PageRoutes with each route path, the public codegen
|
|
25
|
+
(writePublicAssetsDts) fills PublicAssets with each `public/` file path. They
|
|
26
|
+
exist purely so editors suggest known paths; PathParams still derives a page's
|
|
27
|
+
params from the literal, so neither map drives typing.
|
|
28
|
+
*/
|
|
29
|
+
// biome-ignore lint/suspicious/noEmptyInterface: augmented by the generated routes.d.ts
|
|
30
|
+
export interface PageRoutes {}
|
|
31
|
+
// biome-ignore lint/suspicious/noEmptyInterface: augmented by the generated publicAssets.d.ts
|
|
32
|
+
export interface PublicAssets {}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
Known in-app paths for autocomplete. `(string & {})` at the call site keeps any
|
|
36
|
+
string accepted (dynamic/raw/external paths) — there's no hard route-existence
|
|
37
|
+
error, which would reject assets and interpolated strings — while these light
|
|
38
|
+
up suggestions once codegen lands.
|
|
39
|
+
*/
|
|
40
|
+
type KnownPath = keyof PageRoutes | keyof RpcRoutes | keyof PublicAssets
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
Pulls the `[name]` / `[...rest]` params a route literal declares straight from
|
|
44
|
+
the path type, so url('/product/[id]', …) requires `id` without a generated
|
|
45
|
+
shape map. Values accept string | number (stringified on output). A path with
|
|
46
|
+
no bracket segments yields {}, which collapses the params slot away. The
|
|
47
|
+
catch-all branch recurses on its head too, so `[name]` segments before a
|
|
48
|
+
`[...rest]` are kept.
|
|
49
|
+
*/
|
|
50
|
+
type PathParams<P extends string> = P extends `${infer Head}[...${infer Rest}]${infer Tail}`
|
|
51
|
+
? PathParams<Head> & { [K in Rest]: string | number } & PathParams<Tail>
|
|
52
|
+
: P extends `${string}[${infer Name}]${infer Tail}`
|
|
53
|
+
? { [K in Name]: string | number } & PathParams<Tail>
|
|
54
|
+
: // biome-ignore lint/complexity/noBannedTypes: {} is the "no params" base case — keyof {} is never, which collapses the params slot; Record<string, never> would not (keyof is string)
|
|
55
|
+
{}
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
Resolves any in-app URL to its base-correct, typed form — the single chokepoint
|
|
59
|
+
so a project mounted under APP_URL's subpath (e.g. /v2) generates links, asset
|
|
60
|
+
refs, and rpc hrefs that stay within the mount. Three disjoint URL kinds, keyed
|
|
61
|
+
off the path:
|
|
62
|
+
- rpc (flat /rpc/*, present in RpcRoutes): the verb's args, serialised to query.
|
|
63
|
+
- page route (has [name] segments): path params, then optional query.
|
|
64
|
+
- asset / paramless / raw: bare path, then optional query.
|
|
65
|
+
External URLs (scheme-qualified or protocol-relative) skip the base untouched,
|
|
66
|
+
as do non-rooted specifiers — base only ever prefixes a rooted internal path.
|
|
67
|
+
*/
|
|
68
|
+
export function url<P extends KnownPath | (string & {})>(
|
|
69
|
+
path: P,
|
|
70
|
+
...args: P extends keyof RpcRoutes
|
|
71
|
+
? undefined extends RpcRoutes[P]
|
|
72
|
+
? [args?: RpcRoutes[P]]
|
|
73
|
+
: [args: RpcRoutes[P]]
|
|
74
|
+
: keyof PathParams<P> extends never
|
|
75
|
+
? [query?: Query]
|
|
76
|
+
: [params: PathParams<P>, query?: Query]
|
|
77
|
+
): string
|
|
78
|
+
export function url(path: string, first?: Query, second?: Query): string {
|
|
79
|
+
// Scheme-qualified (http:, mailto:) or protocol-relative URLs are external — leave them whole.
|
|
80
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(path) || path.startsWith('//')) {
|
|
81
|
+
return appendQuery(path, first)
|
|
82
|
+
}
|
|
83
|
+
const segments = parseRouteSegments(path)
|
|
84
|
+
const hasParams = segments.some((segment) => segment.kind === 'param')
|
|
85
|
+
// With path params the second arg is the query; without, the first arg is.
|
|
86
|
+
const query = hasParams ? second : first
|
|
87
|
+
const resolved = hasParams ? interpolate(segments, first ?? {}) : path
|
|
88
|
+
// Base only prefixes rooted internal paths; relative specifiers are left alone.
|
|
89
|
+
const prefixed = resolved.startsWith('/') ? basePath() + resolved : resolved
|
|
90
|
+
return appendQuery(prefixed, query)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Substitutes `[name]` / `[...rest]` segments with their stringified, URL-encoded
|
|
94
|
+
param values (matching the query side, which encodes too). A `[name]` value is
|
|
95
|
+
encoded whole so `/`, `?`, `#`, and spaces can't alter the path structure; a
|
|
96
|
+
`[...rest]` catch-all keeps its `/` separators and encodes each sub-segment. */
|
|
97
|
+
function interpolate(segments: RouteSegment[], params: Query): string {
|
|
98
|
+
return segments
|
|
99
|
+
.map((segment) => {
|
|
100
|
+
if (segment.kind === 'literal') {
|
|
101
|
+
return segment.value
|
|
102
|
+
}
|
|
103
|
+
const value = String(params[segment.name])
|
|
104
|
+
return segment.catchAll
|
|
105
|
+
? value.split('/').map(encodeURIComponent).join('/')
|
|
106
|
+
: encodeURIComponent(value)
|
|
107
|
+
})
|
|
108
|
+
.join('/')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Appends a `?`-query built from the same encoder buildRpcRequest uses, or nothing. */
|
|
112
|
+
function appendQuery(target: string, query: Query | undefined): string {
|
|
113
|
+
if (!query) {
|
|
114
|
+
return target
|
|
115
|
+
}
|
|
116
|
+
const queryString = queryStringFromArgs(query, false)
|
|
117
|
+
return queryString ? `${target}?${queryString}` : target
|
|
118
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { basePath } from './basePath.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Prefixes a rooted internal path (`/rpc/…`, `/__abide/…`) with the mount base
|
|
5
|
+
so the client's framework requests route through the proxy (`/v2/rpc/…`). The
|
|
6
|
+
single rule the runtime fetch sites (remoteProxy, openResolveStream,
|
|
7
|
+
socketChannel, the streaming placeholders) share — '' at root is a no-op.
|
|
8
|
+
*/
|
|
9
|
+
export function withBase(path: string): string {
|
|
10
|
+
return `${basePath()}${path}`
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { basePath } from './basePath.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Re-homes a URL under the mount base by prefixing its pathname (`/people` →
|
|
5
|
+
`/v2/people`) — the URL-level counterpart of withBase for sites that carry
|
|
6
|
+
whole URLs rather than rooted paths. Identity at root mount, so there is no
|
|
7
|
+
allocation (and no behaviour change) when no base is set.
|
|
8
|
+
*/
|
|
9
|
+
export function withBaseUrl(url: URL): URL {
|
|
10
|
+
const base = basePath()
|
|
11
|
+
if (!base) {
|
|
12
|
+
return url
|
|
13
|
+
}
|
|
14
|
+
const prefixed = new URL(url)
|
|
15
|
+
prefixed.pathname = base + url.pathname
|
|
16
|
+
return prefixed
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from './types/StandardSchemaV1.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Attaches a `toJSONSchema()` projection to a Standard Schema whose library
|
|
5
|
+
doesn't expose one natively. jsonSchemaForSchema probes that method to feed the
|
|
6
|
+
OpenAPI document, the MCP tool schemas, the CLI flag help, and the bundle setup
|
|
7
|
+
form. Zod 4 / Effect / Arktype carry their own; everything else wraps once where
|
|
8
|
+
the schema is declared:
|
|
9
|
+
|
|
10
|
+
export const config = env(withJsonSchema(vSchema, (s) => toJsonSchema(s)))
|
|
11
|
+
|
|
12
|
+
Mutates and returns the same schema with the method attached, so the wrapped
|
|
13
|
+
value stays usable everywhere the bare schema was.
|
|
14
|
+
*/
|
|
15
|
+
// @readme rpc
|
|
16
|
+
export function withJsonSchema<Schema extends StandardSchemaV1>(
|
|
17
|
+
schema: Schema,
|
|
18
|
+
toJsonSchema: (schema: Schema) => Record<string, unknown>,
|
|
19
|
+
): Schema & { toJSONSchema: () => Record<string, unknown> } {
|
|
20
|
+
return Object.assign(schema, { toJSONSchema: () => toJsonSchema(schema) })
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* The banner every generated abide `.d.ts` carries, warning off hand edits. */
|
|
2
|
+
const DTS_BANNER = '// Generated by abide. Do not edit by hand.'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Writes a generated `.d.ts` to `src/.abide/<name>.d.ts` (the path the consumer's
|
|
6
|
+
src tsconfig include picks up), wrapping `body` in the shared banner + the
|
|
7
|
+
`export {}` footer that makes the file a module. The three codegen writers
|
|
8
|
+
(routes, rpc, public assets) differ only in `body`, so the envelope lives here.
|
|
9
|
+
*/
|
|
10
|
+
export async function writeDts(cwd: string, name: string, body: string): Promise<void> {
|
|
11
|
+
await Bun.write(`${cwd}/src/.abide/${name}.d.ts`, `${DTS_BANNER}\n${body}\n\nexport {}\n`)
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { writeDts } from './writeDts.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Emits a `.d.ts` that augments abide's `AppHealthMap` interface with the app
|
|
5
|
+
health() hook's resolved return type, so the client `health()` read types
|
|
6
|
+
against the project's own hook (e.g. `health().authenticated`). Conditional
|
|
7
|
+
over `typeof import('../app.ts')` because the hook is optional — absent, the
|
|
8
|
+
fields resolve empty; a non-object return is ignored, matching the runtime
|
|
9
|
+
merge. With no src/app.ts at all the import would be an error, so the file
|
|
10
|
+
carries only the framework shape. Written to `src/.abide/health.d.ts` like
|
|
11
|
+
its routes/rpc siblings.
|
|
12
|
+
*/
|
|
13
|
+
export async function writeHealthDts({
|
|
14
|
+
cwd,
|
|
15
|
+
hasAppModule,
|
|
16
|
+
importName,
|
|
17
|
+
}: {
|
|
18
|
+
cwd: string
|
|
19
|
+
hasAppModule: boolean
|
|
20
|
+
importName: string
|
|
21
|
+
}): Promise<void> {
|
|
22
|
+
const body = hasAppModule
|
|
23
|
+
? `type AppHealthFields<App> = App extends { health: (...args: never[]) => infer Result }
|
|
24
|
+
? Awaited<Result> extends object
|
|
25
|
+
? Awaited<Result>
|
|
26
|
+
: Record<never, never>
|
|
27
|
+
: Record<never, never>
|
|
28
|
+
|
|
29
|
+
declare module '${importName}/shared/health' {
|
|
30
|
+
interface AppHealthMap {
|
|
31
|
+
fields: AppHealthFields<typeof import('../app.ts')>
|
|
32
|
+
}
|
|
33
|
+
}`
|
|
34
|
+
: '// src/app.ts absent — health() carries only the framework fields.'
|
|
35
|
+
await writeDts(cwd, 'health', body)
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises'
|
|
2
|
+
import { appDataDir } from './appDataDir.ts'
|
|
3
|
+
import { lastConnectionPath } from './lastConnectionPath.ts'
|
|
4
|
+
import type { LastConnection } from './types/LastConnection.ts'
|
|
5
|
+
|
|
6
|
+
// Persists the connection intent, creating the data dir on first write.
|
|
7
|
+
export async function writeLastConnection(
|
|
8
|
+
programName: string,
|
|
9
|
+
value: LastConnection,
|
|
10
|
+
): Promise<void> {
|
|
11
|
+
await mkdir(appDataDir(programName), { recursive: true })
|
|
12
|
+
await Bun.write(lastConnectionPath(programName), JSON.stringify(value))
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { writeDts } from './writeDts.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Emits a `.d.ts` that augments abide's `PublicAssets` interface with one entry
|
|
5
|
+
per file under `public/`, keyed by its site-root path (`/logo.png`) — the same
|
|
6
|
+
key createPublicAssetServer serves it at. Keys only (value `true`): the map
|
|
7
|
+
exists purely so `url('/logo.png')` autocompletes known assets; it carries no
|
|
8
|
+
type beyond the path. Written to `src/.abide/publicAssets.d.ts` so the
|
|
9
|
+
consumer's src tsconfig include picks it up, keyed on the project's abide
|
|
10
|
+
import name like writeRoutesDts / writeRpcDts.
|
|
11
|
+
*/
|
|
12
|
+
export async function writePublicAssetsDts({
|
|
13
|
+
cwd,
|
|
14
|
+
publicFiles,
|
|
15
|
+
importName,
|
|
16
|
+
}: {
|
|
17
|
+
cwd: string
|
|
18
|
+
publicFiles: string[]
|
|
19
|
+
importName: string
|
|
20
|
+
}): Promise<void> {
|
|
21
|
+
const entries = publicFiles
|
|
22
|
+
.map((file) => ` ${JSON.stringify(`/${file}`)}: true`)
|
|
23
|
+
.toSorted()
|
|
24
|
+
.join('\n')
|
|
25
|
+
const body = `declare module '${importName}/shared/url' {
|
|
26
|
+
interface PublicAssets {
|
|
27
|
+
${entries}
|
|
28
|
+
}
|
|
29
|
+
}`
|
|
30
|
+
await writeDts(cwd, 'publicAssets', body)
|
|
31
|
+
}
|