@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,27 @@
|
|
|
1
|
+
import type { TypedResponse } from './TypedResponse.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Handler signature for verb-defined remote functions. Args is `undefined` for
|
|
5
|
+
GETs/DELETEs with no query, JSON-shaped objects for json bodies, and
|
|
6
|
+
form-shaped objects for form-encoded bodies. For a multipart upload it's the
|
|
7
|
+
text fields (`inputSchema`) intersected with the validated File parts
|
|
8
|
+
(`filesSchema`), merged into one bag. For a raw binary body Args is `undefined`
|
|
9
|
+
— read the stream via `request()` from `abide/server` instead.
|
|
10
|
+
|
|
11
|
+
Return is the value type the call site sees after Content-Type-driven
|
|
12
|
+
decoding (a parsed object for JSON, a string for text/*, a Blob otherwise,
|
|
13
|
+
`undefined` for 204). The handler must return a Response at runtime; the
|
|
14
|
+
`TypedResponse<Return>` brand on `json`/`error`/`redirect`/`jsonl`/`sse`
|
|
15
|
+
carries the body shape through the function's inferred return type so the
|
|
16
|
+
verb helper can infer `Return` automatically — no need to annotate
|
|
17
|
+
`GET<Args, Return>` when the handler returns one of the respond helpers.
|
|
18
|
+
A bare `new Response(...)` is still acceptable: the brand is optional, so
|
|
19
|
+
untagged Responses fall back to `Return = unknown`.
|
|
20
|
+
|
|
21
|
+
Handlers that need the inbound Request (headers, `request.signal`, …) read
|
|
22
|
+
it via `request()` from `abide/server` rather than a handler parameter, so
|
|
23
|
+
the signature stays a single parsed-`args` bag.
|
|
24
|
+
*/
|
|
25
|
+
export type RemoteHandler<Args, Return> = (
|
|
26
|
+
args: Args,
|
|
27
|
+
) => TypedResponse<Return> | Promise<TypedResponse<Return>>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RemoteFunction } from '../../../shared/types/RemoteFunction.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Manifest of RPC URL → module loader. Produced by the resolver plugin from
|
|
5
|
+
every `.ts` under src/server/rpc — each file maps to one URL (derived from its
|
|
6
|
+
path under `$rpc`, prefixed with `/rpc/`). Each module has exactly one
|
|
7
|
+
named export, a RemoteFunction whose `.method` and `.url` were stamped in
|
|
8
|
+
by the bundler rewrite.
|
|
9
|
+
*/
|
|
10
|
+
export type RemoteRoutes = Record<
|
|
11
|
+
string,
|
|
12
|
+
() => Promise<Record<string, RemoteFunction<unknown, unknown>>>
|
|
13
|
+
>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
A `Response` tagged with the body type the framework will hand back to
|
|
3
|
+
callers after Content-Type-driven decoding. The tag is phantom — it
|
|
4
|
+
adds no runtime field, only a type-level slot so the verb helpers can
|
|
5
|
+
infer `Return` from the handler's return type instead of forcing every
|
|
6
|
+
route to annotate it via `GET<Args, Return>`.
|
|
7
|
+
|
|
8
|
+
The respond helpers (`json<T>`, `error`, `redirect`, `jsonl<F>`,
|
|
9
|
+
`sse<F>`) all return a `TypedResponse<T>`, so a handler ending in
|
|
10
|
+
`return json({ user })` exposes `{ user: ... }` as its body type; the
|
|
11
|
+
verb overload picks it up via `RemoteHandler<Args, Return>`.
|
|
12
|
+
|
|
13
|
+
`T` is optional on the brand so a plain `new Response(...)` (untagged)
|
|
14
|
+
remains assignable to `TypedResponse<unknown>`; in that case `Return`
|
|
15
|
+
just falls back to its `unknown` default, matching pre-existing
|
|
16
|
+
behaviour for handlers that build Responses by hand.
|
|
17
|
+
*/
|
|
18
|
+
export type TypedResponse<T> = Response & { readonly __body?: T }
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ClientFlags } from '../../../shared/types/ClientFlags.ts'
|
|
2
|
+
import type { RemoteFunction } from '../../../shared/types/RemoteFunction.ts'
|
|
3
|
+
import type { StandardSchemaV1 } from '../../../shared/types/StandardSchemaV1.ts'
|
|
4
|
+
import type { RemoteHandler } from './RemoteHandler.ts'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
Shared signature for every verb helper (GET / POST / …). Three overloads:
|
|
8
|
+
|
|
9
|
+
- `Verb(fn, { inputSchema, outputSchema?, clients? })` — `Args` infers
|
|
10
|
+
from `InferInput<InputSchema>`, the handler receives
|
|
11
|
+
`InferOutput<InputSchema>`. Generic order is `<Return, InputSchema>` so
|
|
12
|
+
users can override `Return` while letting `InputSchema` infer from
|
|
13
|
+
`opts.inputSchema`. `outputSchema` is an optional Standard Schema for
|
|
14
|
+
the success body — it feeds the OpenAPI 200 response and the MCP tool
|
|
15
|
+
`outputSchema`. JSON Schema is projected from each schema's own
|
|
16
|
+
`toJSONSchema()` (wrap with withJsonSchema if the library lacks one).
|
|
17
|
+
`clients` controls which surfaces (browser / mcp / cli) expose this verb.
|
|
18
|
+
`crossOrigin: true` exempts a mutating verb from the router's same-origin
|
|
19
|
+
CSRF gate — by default a browser request whose Origin doesn't match the
|
|
20
|
+
app's own host is refused with 403 on every non-GET/HEAD verb.
|
|
21
|
+
`maxBodySize` caps the body's actual received bytes (413 past it),
|
|
22
|
+
enforced before parsing; omitted, the only ceiling is Bun.serve's
|
|
23
|
+
server-wide maxRequestBodySize. `timeout` (ms) bounds the handler's
|
|
24
|
+
execution on every surface (SSR / MCP / CLI / network) — a 504 once
|
|
25
|
+
exceeded; on the network path it also aborts request().signal so a
|
|
26
|
+
handler's `fetch(ext, { signal: request().signal })` is cancelled, not
|
|
27
|
+
just abandoned.
|
|
28
|
+
- `Verb(fn, { clients })` — schemaless but with explicit client
|
|
29
|
+
targeting (e.g. server-internal RPC with `clients: { browser: false }`).
|
|
30
|
+
- `Verb(fn)` — bare handler. `Args` and `Return` come from the handler
|
|
31
|
+
type; `Return` is usually inferred via the `TypedResponse<T>` brand on
|
|
32
|
+
`json`/`error`/`redirect`/`jsonl`/`sse`.
|
|
33
|
+
*/
|
|
34
|
+
export type VerbHelper = {
|
|
35
|
+
/*
|
|
36
|
+
`Verb(fn, { inputSchema, filesSchema, … })` — multipart upload. The
|
|
37
|
+
handler receives the text fields (`InferOutput<InputSchema>`) intersected
|
|
38
|
+
with the validated File parts (`InferOutput<FilesSchema>`); both are merged
|
|
39
|
+
into one args bag. The call site sends a FormData (RemoteFunction's call
|
|
40
|
+
accepts it), since a File can't ride a JSON body. filesSchema stays off the
|
|
41
|
+
JSON-Schema projection — a File has no honest conversion (see
|
|
42
|
+
jsonSchemaForSchema) — so only inputSchema feeds MCP/CLI/OpenAPI.
|
|
43
|
+
*/
|
|
44
|
+
<
|
|
45
|
+
Return = unknown,
|
|
46
|
+
InputSchema extends StandardSchemaV1 = StandardSchemaV1,
|
|
47
|
+
FilesSchema extends StandardSchemaV1 = StandardSchemaV1,
|
|
48
|
+
>(
|
|
49
|
+
fn: RemoteHandler<
|
|
50
|
+
StandardSchemaV1.InferOutput<InputSchema> & StandardSchemaV1.InferOutput<FilesSchema>,
|
|
51
|
+
Return
|
|
52
|
+
>,
|
|
53
|
+
opts: {
|
|
54
|
+
inputSchema: InputSchema
|
|
55
|
+
filesSchema: FilesSchema
|
|
56
|
+
outputSchema?: StandardSchemaV1
|
|
57
|
+
clients?: Partial<ClientFlags>
|
|
58
|
+
crossOrigin?: boolean
|
|
59
|
+
maxBodySize?: number
|
|
60
|
+
timeout?: number
|
|
61
|
+
},
|
|
62
|
+
): RemoteFunction<StandardSchemaV1.InferInput<InputSchema>, Return>
|
|
63
|
+
<Return = unknown, InputSchema extends StandardSchemaV1 = StandardSchemaV1>(
|
|
64
|
+
fn: RemoteHandler<StandardSchemaV1.InferOutput<InputSchema>, Return>,
|
|
65
|
+
opts: {
|
|
66
|
+
inputSchema: InputSchema
|
|
67
|
+
outputSchema?: StandardSchemaV1
|
|
68
|
+
clients?: Partial<ClientFlags>
|
|
69
|
+
crossOrigin?: boolean
|
|
70
|
+
maxBodySize?: number
|
|
71
|
+
timeout?: number
|
|
72
|
+
},
|
|
73
|
+
): RemoteFunction<StandardSchemaV1.InferInput<InputSchema>, Return>
|
|
74
|
+
<Args = undefined, Return = unknown>(
|
|
75
|
+
fn: RemoteHandler<Args, Return>,
|
|
76
|
+
opts: {
|
|
77
|
+
outputSchema?: StandardSchemaV1
|
|
78
|
+
clients?: Partial<ClientFlags>
|
|
79
|
+
crossOrigin?: boolean
|
|
80
|
+
maxBodySize?: number
|
|
81
|
+
timeout?: number
|
|
82
|
+
},
|
|
83
|
+
): RemoteFunction<Args, Return>
|
|
84
|
+
<Args = undefined, Return = unknown>(
|
|
85
|
+
fn: RemoteHandler<Args, Return>,
|
|
86
|
+
): RemoteFunction<Args, Return>
|
|
87
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ClientFlags } from '../../../shared/types/ClientFlags.ts'
|
|
2
|
+
import type { RemoteFunction } from '../../../shared/types/RemoteFunction.ts'
|
|
3
|
+
import type { StandardSchemaV1 } from '../../../shared/types/StandardSchemaV1.ts'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Per-verb registry record on the server side. MCP and CLI enumerate this
|
|
7
|
+
to discover which RPCs are advertised (clients flags) and what shapes
|
|
8
|
+
they expect/return. The schemas and resolved clients stay off the public
|
|
9
|
+
RemoteFunction shape so the browser-side proxy doesn't need to carry
|
|
10
|
+
server-only state.
|
|
11
|
+
|
|
12
|
+
`inputSchema` validates the argument bag and feeds the MCP tool
|
|
13
|
+
`inputSchema` / OpenAPI parameters; `outputSchema` describes the success
|
|
14
|
+
body and feeds the OpenAPI 200 response + MCP tool `outputSchema`. Each
|
|
15
|
+
projects to JSON Schema via its own `toJSONSchema()` (jsonSchemaForSchema) —
|
|
16
|
+
schemas whose library lacks one are wrapped with withJsonSchema.
|
|
17
|
+
|
|
18
|
+
`filesSchema` validates the File parts of a multipart body, kept separate
|
|
19
|
+
from `inputSchema` because a File has no honest JSON-Schema conversion — it
|
|
20
|
+
stays out of the MCP/CLI projection that `inputSchema` feeds, and the OpenAPI
|
|
21
|
+
multipart body advertises the file parts generically as binary.
|
|
22
|
+
*/
|
|
23
|
+
export type VerbRegistryEntry = {
|
|
24
|
+
remote: RemoteFunction<unknown, unknown>
|
|
25
|
+
inputSchema: StandardSchemaV1 | undefined
|
|
26
|
+
outputSchema: StandardSchemaV1 | undefined
|
|
27
|
+
filesSchema: StandardSchemaV1 | undefined
|
|
28
|
+
clients: ClientFlags
|
|
29
|
+
/* The verb's declared opts, recorded so introspection (inspector) can report
|
|
30
|
+
the deadline/body-cap/CSRF-exemption a handler runs under. Undefined = the
|
|
31
|
+
framework default (no deadline, Bun's server-wide body ceiling, gated). */
|
|
32
|
+
timeout: number | undefined
|
|
33
|
+
maxBodySize: number | undefined
|
|
34
|
+
crossOrigin: boolean | undefined
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RemoteFunction } from '../../shared/types/RemoteFunction.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Verb helpers (GET / POST / …) are placeholders — the bundler rewrites every
|
|
5
|
+
`export const x = GET(fn)` inside `src/server/rpc/<file>.ts` into a call to
|
|
6
|
+
defineVerb (server target) or remoteProxy (client target). If a call slips
|
|
7
|
+
through, the bundler plugin didn't process the file; throwing here surfaces
|
|
8
|
+
that cleanly instead of silently returning undefined.
|
|
9
|
+
*/
|
|
10
|
+
export function unprocessed<Args, Return>(verb: string): RemoteFunction<Args, Return> {
|
|
11
|
+
throw new Error(
|
|
12
|
+
`[abide] \`${verb}\` was called outside an $rpc module — verb helpers are only valid as the value of \`export const <filename> = ...\` inside a file under src/server/rpc/`,
|
|
13
|
+
)
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VerbRegistryEntry } from './types/VerbRegistryEntry.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Process-wide registry of every verb-bound RPC declared in the app.
|
|
5
|
+
defineVerb inserts on first construction (which happens at module-load
|
|
6
|
+
time inside the rpc dispatcher cache or eagerly when MCP / CLI walks the
|
|
7
|
+
rpc manifest). MCP server reads this to build its tools list; the CLI
|
|
8
|
+
binary reads it to generate subcommands. The browser path never touches
|
|
9
|
+
this — the client stub has no schema or clients metadata to register.
|
|
10
|
+
*/
|
|
11
|
+
export const verbRegistry = new Map<string, VerbRegistryEntry>()
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// IPC payload the dev server sends its orchestrator parent (via process.send)
|
|
2
|
+
// once its listener is up and init() has run. The orchestrator retires the
|
|
3
|
+
// previous worker only after this arrives — workers overlap on the dev port via
|
|
4
|
+
// reusePort, so the port never goes dark across a restart. Shared so producer
|
|
5
|
+
// (createServer) and consumer (devEntry) can't drift.
|
|
6
|
+
export const DEV_READY_MESSAGE = 'abide:ready'
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Dev-only live-reload client, injected into the served shell when the server
|
|
3
|
+
runs under `abide dev`. It opens an EventSource to /__abide/dev; each
|
|
4
|
+
connection's first event carries the worker's reload stamp — `{ structure,
|
|
5
|
+
cssHref }` (devClientFingerprint). The channel only drops when the dev
|
|
6
|
+
orchestrator swaps the server after a rebuild, and on reconnect:
|
|
7
|
+
- `structure` changed → reload (any non-CSS edit).
|
|
8
|
+
- only `cssHref` changed → swap the entry stylesheet's `<link>` in place,
|
|
9
|
+
so a CSS edit restyles the live page with no reload and no state loss.
|
|
10
|
+
- both equal (server-only edit) → keep the page alive.
|
|
11
|
+
Self-managed retry keeps the first reconnect fast (250ms) so a rebuild swap
|
|
12
|
+
recovers quickly, then backs off exponentially up to a 5s cap — a server that
|
|
13
|
+
stays down (dev stopped) settles to one attempt every 5s instead of flooding
|
|
14
|
+
the network, and still reconnects on its own if the server comes back. The
|
|
15
|
+
backoff resets once a connection opens.
|
|
16
|
+
|
|
17
|
+
Hidden tabs hold no connection: the channel closes on `visibilitychange:
|
|
18
|
+
hidden` and reopens on visible, where the reconnect's first event carries
|
|
19
|
+
whatever the current worker announces — a rebuild that happened while the tab
|
|
20
|
+
slept still reloads it. The initial connect runs even when the page loads
|
|
21
|
+
hidden (the baseline must be the serving worker's stamp, captured before a swap
|
|
22
|
+
can replace it) and releases itself once that first event lands.
|
|
23
|
+
*/
|
|
24
|
+
import { DEV_HOT_PREFIX } from '../../shared/DEV_HOT_PREFIX.ts'
|
|
25
|
+
import { DEV_RELOAD_PATH } from '../../shared/DEV_RELOAD_PATH.ts'
|
|
26
|
+
|
|
27
|
+
export const DEV_RELOAD_CLIENT_SCRIPT = `<script>
|
|
28
|
+
window.__abideDev = true;
|
|
29
|
+
;(() => {
|
|
30
|
+
let stamp
|
|
31
|
+
let source
|
|
32
|
+
let retryTimer
|
|
33
|
+
let retryDelay = 250
|
|
34
|
+
function disconnect() {
|
|
35
|
+
clearTimeout(retryTimer)
|
|
36
|
+
if (source) {
|
|
37
|
+
source.close()
|
|
38
|
+
source = undefined
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function swapCss(href) {
|
|
42
|
+
const links = document.querySelectorAll('link[rel="stylesheet"]')
|
|
43
|
+
for (const link of links) {
|
|
44
|
+
const current = link.getAttribute('href') || ''
|
|
45
|
+
if (current.indexOf('/_app/') !== -1 && current.slice(-4) === '.css') {
|
|
46
|
+
link.href = href
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function swapComponents(next, prev) {
|
|
52
|
+
const components = next.components || {}
|
|
53
|
+
const before = prev.components || {}
|
|
54
|
+
for (const id in components) {
|
|
55
|
+
if (components[id] !== before[id]) {
|
|
56
|
+
// The hot module sources its runtime from window.__abide and self-invokes
|
|
57
|
+
// hotReplace; a load/compile failure or a component with no live instance
|
|
58
|
+
// falls back to a reload.
|
|
59
|
+
import('${DEV_HOT_PREFIX}' + id + '?v=' + components[id]).catch(() => location.reload())
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function connect() {
|
|
64
|
+
if (source) {
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
source = new EventSource('${DEV_RELOAD_PATH}')
|
|
68
|
+
source.onopen = () => {
|
|
69
|
+
retryDelay = 250
|
|
70
|
+
}
|
|
71
|
+
source.onmessage = (event) => {
|
|
72
|
+
const next = JSON.parse(event.data)
|
|
73
|
+
if (stamp === undefined) {
|
|
74
|
+
stamp = next
|
|
75
|
+
if (document.hidden) {
|
|
76
|
+
disconnect()
|
|
77
|
+
}
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
if (next.structure !== stamp.structure) {
|
|
81
|
+
location.reload()
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
if (next.cssHref && next.cssHref !== stamp.cssHref) {
|
|
85
|
+
swapCss(next.cssHref)
|
|
86
|
+
}
|
|
87
|
+
swapComponents(next, stamp)
|
|
88
|
+
stamp = next
|
|
89
|
+
}
|
|
90
|
+
source.onerror = () => {
|
|
91
|
+
disconnect()
|
|
92
|
+
if (!document.hidden) {
|
|
93
|
+
retryTimer = setTimeout(connect, retryDelay)
|
|
94
|
+
retryDelay = Math.min(retryDelay * 2, 5000)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
document.addEventListener('visibilitychange', () => {
|
|
99
|
+
if (document.hidden) {
|
|
100
|
+
disconnect()
|
|
101
|
+
} else {
|
|
102
|
+
connect()
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
connect()
|
|
106
|
+
})()
|
|
107
|
+
</script>`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The tiny inline script the abide-ui SSR stream ships in <head>. For each streamed
|
|
3
|
+
`<abide-resolve data-id data-resume>` frame it registers the resolved value into
|
|
4
|
+
`window.__abideResume` (the resume manifest hydration reads) and swaps the resolved
|
|
5
|
+
markup into the matching `<!--abide:await:ID-->…<!--/abide:await:ID-->` boundary —
|
|
6
|
+
so the pending shell paints instantly and each value lands as it arrives, before
|
|
7
|
+
the client bundle even loads. Vanilla and self-contained (no framework runtime),
|
|
8
|
+
minified to one line so it inlines cheaply ahead of the document body.
|
|
9
|
+
*/
|
|
10
|
+
export const SSR_SWAP_SCRIPT =
|
|
11
|
+
"function __abideSwap(){var f=document.querySelector('abide-resolve');while(f){" +
|
|
12
|
+
"var id=f.getAttribute('data-id'),w=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT),o=null,c;" +
|
|
13
|
+
"try{(window.__abideResume=window.__abideResume||{})[id]=JSON.parse(f.getAttribute('data-resume')||'null');}catch(e){}" +
|
|
14
|
+
"while((c=w.nextNode())){if(c.data==='abide:await:'+id){o=c;break;}}" +
|
|
15
|
+
"if(o){var n=o.nextSibling;while(n&&!(n.nodeType===8&&n.data==='/abide:await:'+id)){var x=n.nextSibling;n.remove();n=x;}" +
|
|
16
|
+
"while(f.firstChild){o.parentNode.insertBefore(f.firstChild,n);}}f.remove();f=document.querySelector('abide-resolve');}}"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Whether the client advertised gzip in Accept-Encoding. The static-asset
|
|
3
|
+
servers and the dynamic-response gzip wrapper gate compressed output on this,
|
|
4
|
+
so the check lives in one place. Effectively always true for browsers and most
|
|
5
|
+
HTTP clients; a bare client that omits the header gets identity bytes.
|
|
6
|
+
*/
|
|
7
|
+
export function acceptsGzip(req: Request): boolean {
|
|
8
|
+
const header = (req.headers.get('accept-encoding') ?? '').toLowerCase()
|
|
9
|
+
/*
|
|
10
|
+
Honour q-values: `gzip;q=0` is an explicit refusal even though the substring
|
|
11
|
+
is present. Find the gzip (or wildcard) directive and reject only when its
|
|
12
|
+
quality is zero.
|
|
13
|
+
*/
|
|
14
|
+
const directives = header.split(',').map((part) => part.trim())
|
|
15
|
+
// An explicit gzip directive wins over the wildcard; fall back to `*` otherwise.
|
|
16
|
+
const directive =
|
|
17
|
+
directives.find((part) => part === 'gzip' || part.startsWith('gzip;')) ??
|
|
18
|
+
directives.find((part) => part === '*' || part.startsWith('*;'))
|
|
19
|
+
if (directive === undefined) {
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
const quality = directive.match(/;\s*q=([\d.]+)/)
|
|
23
|
+
return quality === null || Number(quality[1]) > 0
|
|
24
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { globalCacheStore } from '../../shared/globalCacheStore.ts'
|
|
2
|
+
import type { CacheEntry } from '../../shared/types/CacheEntry.ts'
|
|
3
|
+
import type { InspectorCacheEntry } from './types/InspectorCacheEntry.ts'
|
|
4
|
+
import type { InspectorCacheSnapshot } from './types/InspectorCacheSnapshot.ts'
|
|
5
|
+
|
|
6
|
+
const PREVIEW_LIMIT = 200
|
|
7
|
+
|
|
8
|
+
/* A short JSON peek at a warm value, degrading non-serializable values to String. */
|
|
9
|
+
function preview(value: unknown): string | undefined {
|
|
10
|
+
if (value === undefined) {
|
|
11
|
+
return undefined
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const json = JSON.stringify(value)
|
|
15
|
+
return json.length > PREVIEW_LIMIT ? `${json.slice(0, PREVIEW_LIMIT)}…` : json
|
|
16
|
+
} catch {
|
|
17
|
+
return String(value)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* The entry's armed invalidate policy as a label, if it declared one. */
|
|
22
|
+
function policyLabel(entry: CacheEntry): string | undefined {
|
|
23
|
+
const policy = entry.invalidation
|
|
24
|
+
if (!policy) {
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
if (policy.debounce !== undefined) {
|
|
28
|
+
return `debounce ${policy.debounce}ms`
|
|
29
|
+
}
|
|
30
|
+
if (policy.throttle !== undefined) {
|
|
31
|
+
return `throttle ${policy.throttle}ms`
|
|
32
|
+
}
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function projectEntry(entry: CacheEntry, now: number): InspectorCacheEntry {
|
|
37
|
+
return {
|
|
38
|
+
key: entry.key,
|
|
39
|
+
status: entry.refreshing ? 'refreshing' : entry.settled ? 'settled' : 'in-flight',
|
|
40
|
+
remote: entry.request !== undefined,
|
|
41
|
+
ttl: entry.ttl,
|
|
42
|
+
expiresInMs: entry.expiresAt !== undefined ? entry.expiresAt - now : undefined,
|
|
43
|
+
scope: entry.scope ? [...entry.scope] : [],
|
|
44
|
+
value: preview(entry.value),
|
|
45
|
+
policy: policyLabel(entry),
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
Snapshots the process-level cache store (the persistent one `cache(fn, { global:
|
|
51
|
+
true })` writes to) for the inspector. Read at call time, so it reflects the
|
|
52
|
+
store as it stands; request-scoped stores are deliberately excluded — they're
|
|
53
|
+
ephemeral and already visible as per-request cache tallies.
|
|
54
|
+
*/
|
|
55
|
+
export function buildCacheSnapshot(): InspectorCacheSnapshot {
|
|
56
|
+
const now = Date.now()
|
|
57
|
+
const entries = Array.from(globalCacheStore().entries.values(), (entry) =>
|
|
58
|
+
projectEntry(entry, now),
|
|
59
|
+
)
|
|
60
|
+
return { entries }
|
|
61
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ABIDE_VERSION } from '../../shared/ABIDE_VERSION.ts'
|
|
2
|
+
import { abideLog } from '../../shared/abideLog.ts'
|
|
3
|
+
import type { AppModule } from '../AppModule.ts'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
The canonical /__abide/health payload: the app health(request) hook's fields
|
|
7
|
+
under the framework identity keys, which win on collision. A thrown or
|
|
8
|
+
non-object hook degrades to no fields — an app bug must not masquerade as an
|
|
9
|
+
unreachable server, so the base payload always builds. Shared by the
|
|
10
|
+
health/identity routes and the SSR renderer's __SSR__.health seed so the
|
|
11
|
+
wire and the seed can't drift.
|
|
12
|
+
*/
|
|
13
|
+
export async function buildHealthPayload(
|
|
14
|
+
request: Request,
|
|
15
|
+
opts: { app?: AppModule; appName: string; appVersion: string },
|
|
16
|
+
): Promise<Record<string, unknown>> {
|
|
17
|
+
let fields: Record<string, unknown> = {}
|
|
18
|
+
if (opts.app?.health) {
|
|
19
|
+
try {
|
|
20
|
+
const result = await opts.app.health(request)
|
|
21
|
+
if (result && typeof result === 'object' && !Array.isArray(result)) {
|
|
22
|
+
fields = result as Record<string, unknown>
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
abideLog.error(error)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
`abide` carries the framework version — truthy for the probe check,
|
|
30
|
+
informative for skew diagnosis. The IDENTITY_PATH alias overrides it to
|
|
31
|
+
the legacy `abide: true` shape at its call site.
|
|
32
|
+
*/
|
|
33
|
+
return { ...fields, abide: ABIDE_VERSION, name: opts.appName, version: opts.appVersion }
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsonSchemaForSchema } from '../../shared/jsonSchemaForSchema.ts'
|
|
2
|
+
import { verbRegistry } from '../rpc/verbRegistry.ts'
|
|
3
|
+
import { socketOperations } from '../sockets/socketOperations.ts'
|
|
4
|
+
import { socketRegistry } from '../sockets/socketRegistry.ts'
|
|
5
|
+
import type { InspectorSurface } from './types/InspectorSurface.ts'
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Projects the live verb + socket registries into the inspector's catalog. Read
|
|
9
|
+
at call time (not cached) so verbs constructed after boot — lazily on first
|
|
10
|
+
hit, or eagerly once ensureRegistriesLoaded walked the manifest — show up.
|
|
11
|
+
Schemas go through jsonSchemaForSchema, the same projection MCP and OpenAPI
|
|
12
|
+
use, so the three can't disagree on a verb's shape; a missing schema stays
|
|
13
|
+
undefined to mark a verb that carries no machine-advertisable contract.
|
|
14
|
+
*/
|
|
15
|
+
export function buildInspectorSurface(): InspectorSurface {
|
|
16
|
+
const verbs = Array.from(verbRegistry.values()).map((entry) => ({
|
|
17
|
+
url: entry.remote.url,
|
|
18
|
+
method: entry.remote.method,
|
|
19
|
+
clients: { ...entry.remote.clients },
|
|
20
|
+
inputSchema: entry.inputSchema ? jsonSchemaForSchema(entry.inputSchema) : undefined,
|
|
21
|
+
outputSchema: entry.outputSchema ? jsonSchemaForSchema(entry.outputSchema) : undefined,
|
|
22
|
+
files: entry.filesSchema !== undefined,
|
|
23
|
+
timeout: entry.timeout,
|
|
24
|
+
maxBodySize: entry.maxBodySize,
|
|
25
|
+
crossOrigin: entry.crossOrigin,
|
|
26
|
+
}))
|
|
27
|
+
const sockets = Array.from(socketRegistry.values()).map((entry) => ({
|
|
28
|
+
name: entry.socket.name,
|
|
29
|
+
operations: socketOperations(entry).map((operation) => ({
|
|
30
|
+
kind: operation.kind,
|
|
31
|
+
name: operation.name,
|
|
32
|
+
method: operation.method,
|
|
33
|
+
restUrl: operation.restUrl,
|
|
34
|
+
})),
|
|
35
|
+
}))
|
|
36
|
+
return { verbs, sockets }
|
|
37
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { carriesBodyArgs } from '../../shared/carriesBodyArgs.ts'
|
|
2
|
+
import { commandNameForUrl } from '../../shared/commandNameForUrl.ts'
|
|
3
|
+
import { jsonSchemaForSchema } from '../../shared/jsonSchemaForSchema.ts'
|
|
4
|
+
import { verbRegistry } from '../rpc/verbRegistry.ts'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
Turns a verb's resolved JSON Schema into OpenAPI query parameters — one
|
|
8
|
+
per top-level property, marked required when the schema lists it. Used
|
|
9
|
+
for GET/DELETE/HEAD operations, which carry their args on the query
|
|
10
|
+
string (mirroring buildRpcRequest).
|
|
11
|
+
*/
|
|
12
|
+
function queryParameters(jsonSchema: Record<string, unknown>): Array<Record<string, unknown>> {
|
|
13
|
+
const properties = jsonSchema.properties as Record<string, unknown> | undefined
|
|
14
|
+
if (!properties) {
|
|
15
|
+
return []
|
|
16
|
+
}
|
|
17
|
+
const required = new Set((jsonSchema.required as string[] | undefined) ?? [])
|
|
18
|
+
return Object.entries(properties).map(([name, schema]) => ({
|
|
19
|
+
name,
|
|
20
|
+
in: 'query',
|
|
21
|
+
required: required.has(name),
|
|
22
|
+
schema,
|
|
23
|
+
}))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
Request body schema for a multipart upload verb: the text fields from
|
|
28
|
+
inputSchema, plus the binary parts. A File has no honest
|
|
29
|
+
Standard-Schema→JSON-Schema conversion, so the file parts are advertised
|
|
30
|
+
generically as additional binary properties rather than named per field.
|
|
31
|
+
*/
|
|
32
|
+
function multipartBodySchema(textSchema: Record<string, unknown>): Record<string, unknown> {
|
|
33
|
+
const textProperties = (textSchema.properties as Record<string, unknown> | undefined) ?? {}
|
|
34
|
+
const schema: Record<string, unknown> = {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: { ...textProperties },
|
|
37
|
+
additionalProperties: { type: 'string', format: 'binary' },
|
|
38
|
+
}
|
|
39
|
+
const required = (textSchema.required as string[] | undefined) ?? []
|
|
40
|
+
if (required.length > 0) {
|
|
41
|
+
schema.required = required
|
|
42
|
+
}
|
|
43
|
+
return schema
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
Builds an OpenAPI 3.1 document from the verb registry — the HTTP surface
|
|
48
|
+
every rpc exposes regardless of which non-browser clients it advertises.
|
|
49
|
+
GET/DELETE/HEAD args become query parameters; POST/PUT/PATCH args become
|
|
50
|
+
a JSON request body. operationId is the folder-prefixed command name so
|
|
51
|
+
it lines up with the MCP tool / CLI subcommand identifiers.
|
|
52
|
+
*/
|
|
53
|
+
export function buildOpenApiSpec(info: {
|
|
54
|
+
title: string
|
|
55
|
+
version: string
|
|
56
|
+
}): Record<string, unknown> {
|
|
57
|
+
const paths: Record<string, Record<string, unknown>> = {}
|
|
58
|
+
for (const entry of verbRegistry.values()) {
|
|
59
|
+
const url = entry.remote.url
|
|
60
|
+
const method = entry.remote.method
|
|
61
|
+
const jsonSchema = jsonSchemaForSchema(entry.inputSchema)
|
|
62
|
+
const description = jsonSchema.description as string | undefined
|
|
63
|
+
/*
|
|
64
|
+
When the verb declares an `outputSchema`, describe the 200 body
|
|
65
|
+
with it so external tooling sees the real return shape; otherwise
|
|
66
|
+
fall back to a bare OK.
|
|
67
|
+
*/
|
|
68
|
+
const okResponse: Record<string, unknown> = { description: 'OK' }
|
|
69
|
+
if (entry.outputSchema) {
|
|
70
|
+
okResponse.content = {
|
|
71
|
+
'application/json': {
|
|
72
|
+
schema: jsonSchemaForSchema(entry.outputSchema),
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const operation: Record<string, unknown> = {
|
|
77
|
+
operationId: commandNameForUrl(url),
|
|
78
|
+
...(description ? { description } : {}),
|
|
79
|
+
responses: { '200': okResponse },
|
|
80
|
+
}
|
|
81
|
+
if (carriesBodyArgs(method)) {
|
|
82
|
+
operation.requestBody = entry.filesSchema
|
|
83
|
+
? {
|
|
84
|
+
content: {
|
|
85
|
+
'multipart/form-data': {
|
|
86
|
+
schema: multipartBodySchema(jsonSchema),
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
: { content: { 'application/json': { schema: jsonSchema } } }
|
|
91
|
+
} else {
|
|
92
|
+
const parameters = queryParameters(jsonSchema)
|
|
93
|
+
if (parameters.length > 0) {
|
|
94
|
+
operation.parameters = parameters
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
paths[url] ??= {}
|
|
98
|
+
const path = paths[url]
|
|
99
|
+
path[method.toLowerCase()] = operation
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
openapi: '3.1.0',
|
|
103
|
+
info: { title: info.title, version: info.version },
|
|
104
|
+
paths,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IMMUTABLE_ASSET_CACHE_CONTROL,
|
|
3
|
+
REVALIDATE_ASSET_CACHE_CONTROL,
|
|
4
|
+
} from '../../shared/CACHE_CONTROL_VALUES.ts'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
Bun.build emits `[name]-[hash].[ext]` for chunks; hash is alnum and >=8 chars.
|
|
8
|
+
Source maps inherit the same name (e.g. foo-abc12345.js.map), so the suffix may be `.map`.
|
|
9
|
+
*/
|
|
10
|
+
const HASHED = /-[a-z0-9]{8,}\.[a-z0-9]+(\.map)?$/i
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Returns the right `Cache-Control` for an asset path served under `/_app/`.
|
|
14
|
+
Hashed chunk filenames are content-addressed and immutable; everything else
|
|
15
|
+
(the entry bundle, the html shell, etc.) must revalidate every time.
|
|
16
|
+
*/
|
|
17
|
+
export function cacheControlForAsset(pathname: string): string {
|
|
18
|
+
if (HASHED.test(pathname)) {
|
|
19
|
+
return IMMUTABLE_ASSET_CACHE_CONTROL
|
|
20
|
+
}
|
|
21
|
+
return REVALIDATE_ASSET_CACHE_CONTROL
|
|
22
|
+
}
|