@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,14 @@
|
|
|
1
|
+
import { dataDirEnvPath } from './dataDirEnvPath.ts'
|
|
2
|
+
import { loadEnvFile } from './loadEnvFile.ts'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Loads the user's `.env` from the program's per-user data dir into `process.env`.
|
|
6
|
+
This is the cwd-independent config layer — where the connect-screen form writes
|
|
7
|
+
the user's answers, and where a bundle launched via `open` (cwd `/`, so Bun's
|
|
8
|
+
CWD `.env` autoload finds nothing) actually picks up its config. Loaded before
|
|
9
|
+
the binary-dir `.env`, so a user's saved config overrides the shipped default;
|
|
10
|
+
still loses to a shell export or a CWD `.env` (fill-when-unset, see loadEnvFile).
|
|
11
|
+
*/
|
|
12
|
+
export async function loadEnvFromDataDir(programName: string): Promise<void> {
|
|
13
|
+
await loadEnvFile(dataDirEnvPath(programName))
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { appNameSlot } from './appNameSlot.ts'
|
|
2
|
+
import { createChannelLog } from './createChannelLog.ts'
|
|
3
|
+
import type { ChannelLog } from './types/ChannelLog.ts'
|
|
4
|
+
import type { Log } from './types/Log.ts'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
The unified logger: every record carries the request-scope context (short
|
|
8
|
+
trace id, +elapsed, verb+path) when one is active, plus a channel — the
|
|
9
|
+
line's speaker. `log(...)`/`warn`/`error`/`trace` speak on the app's own
|
|
10
|
+
always-on channel (the app name, resolved per emission so boot order doesn't
|
|
11
|
+
matter); `log.channel(name)` returns the same shape on a DEBUG-gated
|
|
12
|
+
diagnostic channel (browser: the `abide-debug` localStorage key). Renders as
|
|
13
|
+
the tab-separated tsv format (default) or one JSON object per line under
|
|
14
|
+
ABIDE_LOG_FORMAT=json.
|
|
15
|
+
*/
|
|
16
|
+
// @readme observability
|
|
17
|
+
export const log: Log = Object.assign(
|
|
18
|
+
createChannelLog(() => appNameSlot.name ?? 'app', true),
|
|
19
|
+
{
|
|
20
|
+
channel(name: string): ChannelLog {
|
|
21
|
+
return createChannelLog(() => name, false)
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { emitLogRecord } from './emitLogRecord.ts'
|
|
2
|
+
import type { CacheStats } from './types/CacheStats.ts'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Emits the request's closing record — the line that ends a trace: status as
|
|
6
|
+
the message, total duration at settle, cache read tallies frozen at that
|
|
7
|
+
moment. Framework-internal (runWithRequestScope at settle, the asset paths
|
|
8
|
+
directly); not part of the public log surface because its structured fields
|
|
9
|
+
only make sense at the request boundary the framework owns.
|
|
10
|
+
*/
|
|
11
|
+
export function logClosingRecord(
|
|
12
|
+
method: string,
|
|
13
|
+
path: string,
|
|
14
|
+
status: number,
|
|
15
|
+
durationMs: number,
|
|
16
|
+
cache?: CacheStats,
|
|
17
|
+
): void {
|
|
18
|
+
emitLogRecord({
|
|
19
|
+
level: 'info',
|
|
20
|
+
msg: '',
|
|
21
|
+
channel: 'abide',
|
|
22
|
+
method,
|
|
23
|
+
path,
|
|
24
|
+
status,
|
|
25
|
+
durationMs,
|
|
26
|
+
cache,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LogRecord } from './types/LogRecord.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Passive observation seam for the unified log. emitLogRecord calls the tap (when
|
|
5
|
+
set) with every fully-built record, before formatting — so an observer sees the
|
|
6
|
+
exact structured record stdout/console would, trace context and all. The
|
|
7
|
+
inspector installs one to feed its live event buffer; unset everywhere else, so
|
|
8
|
+
the call no-ops with zero allocation. One slot, not a listener set: the single
|
|
9
|
+
in-process observer fans out to its own readers. Mirrors requestScopeSlot.
|
|
10
|
+
*/
|
|
11
|
+
export const logTapSlot: { tap: ((record: LogRecord) => void) | undefined } = {
|
|
12
|
+
tap: undefined,
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { abideLog } from './abideLog.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Builds one of abide's virtual manifest modules — the `{ key: () => import(...) }`
|
|
5
|
+
map the bundler emits for rpc / sockets / prompts / pages / layouts. They differ
|
|
6
|
+
only in their files, the key derived per file, the import dir, the export name,
|
|
7
|
+
and the log label; this is the single shape they share.
|
|
8
|
+
*/
|
|
9
|
+
export function manifestModule(options: {
|
|
10
|
+
files: string[]
|
|
11
|
+
keyForFile: (file: string) => string
|
|
12
|
+
importDir: string
|
|
13
|
+
exportName: string
|
|
14
|
+
/*
|
|
15
|
+
A plain `resolved N <label>: keys` line at build time, when set. Omitted for
|
|
16
|
+
manifests whose contents are enumerated once at boot as an aligned table (see
|
|
17
|
+
logExposedSurfaces) — rpc/sockets/pages/layouts — which both avoids the
|
|
18
|
+
redundant list and the double-log of manifests (pages/layouts) loaded by both
|
|
19
|
+
the server and client bundles. prompts/errors have no table, so they pass a
|
|
20
|
+
label to keep their build-time line.
|
|
21
|
+
*/
|
|
22
|
+
label?: string
|
|
23
|
+
}): { contents: string; loader: 'js' } {
|
|
24
|
+
const entries = options.files
|
|
25
|
+
.toSorted()
|
|
26
|
+
.map((file) => ({ key: options.keyForFile(file), file }))
|
|
27
|
+
const lines = entries
|
|
28
|
+
.map(
|
|
29
|
+
({ key, file }) =>
|
|
30
|
+
` ${JSON.stringify(key)}: () => import(${JSON.stringify(`${options.importDir}/${file}`)}),`,
|
|
31
|
+
)
|
|
32
|
+
.join('\n')
|
|
33
|
+
if (options.label && entries.length > 0) {
|
|
34
|
+
abideLog.info(
|
|
35
|
+
`resolved ${entries.length} ${options.label}: ${entries.map((entry) => entry.key).join(', ')}`,
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
return { contents: `export const ${options.exportName} = {\n${lines}\n}\n`, loader: 'js' }
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
One DEBUG pattern against one channel name, npm-debug conventions:
|
|
3
|
+
`*` matches everything, `abide:*` matches 'abide' and every 'abide:…'
|
|
4
|
+
sub-channel, anything else matches exactly. Negation (`-` prefix) is the
|
|
5
|
+
caller's concern — patterns arrive here already stripped.
|
|
6
|
+
*/
|
|
7
|
+
export function matchesDebugPattern(name: string, pattern: string): boolean {
|
|
8
|
+
if (pattern === '*') {
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
if (pattern.endsWith(':*')) {
|
|
12
|
+
const prefix = pattern.slice(0, -2)
|
|
13
|
+
return name === prefix || name.startsWith(`${prefix}:`)
|
|
14
|
+
}
|
|
15
|
+
return pattern === name
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Memoises an async loader keyed by string: the first call for a key starts the
|
|
3
|
+
load and caches its promise; later calls reuse it. `load` returns undefined when
|
|
4
|
+
the key has no loader, which is passed through (and not cached) so the caller can
|
|
5
|
+
treat "unknown key" distinctly from "loaded value". Used by the rpc-module and
|
|
6
|
+
socket-module load caches, which share this exact shape.
|
|
7
|
+
*/
|
|
8
|
+
export function memoizeByKey<T>(
|
|
9
|
+
load: (key: string) => Promise<T> | undefined,
|
|
10
|
+
): (key: string) => Promise<T> | undefined {
|
|
11
|
+
const cache = new Map<string, Promise<T>>()
|
|
12
|
+
return (key) => {
|
|
13
|
+
const existing = cache.get(key)
|
|
14
|
+
if (existing) {
|
|
15
|
+
return existing
|
|
16
|
+
}
|
|
17
|
+
const started = load(key)
|
|
18
|
+
if (!started) {
|
|
19
|
+
return undefined
|
|
20
|
+
}
|
|
21
|
+
cache.set(key, started)
|
|
22
|
+
// Evict on rejection so a transient load failure doesn't poison the key
|
|
23
|
+
// forever; the next call retries. The separate handle doesn't swallow the
|
|
24
|
+
// rejection seen by the returned promise.
|
|
25
|
+
void started.catch(() => {
|
|
26
|
+
if (cache.get(key) === started) {
|
|
27
|
+
cache.delete(key)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
return started
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CompileTarget } from './types/CompileTarget.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Prepends the `bun-` prefix if missing so CLI users can pass either
|
|
5
|
+
`darwin-arm64` or the canonical `bun-darwin-arm64` form to `--target`.
|
|
6
|
+
*/
|
|
7
|
+
export function normalizeTarget(input: string): CompileTarget {
|
|
8
|
+
const normalized = input.startsWith('bun-') ? input : `bun-${input}`
|
|
9
|
+
return normalized as CompileTarget
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createSubscriber } from './createSubscriber.ts'
|
|
2
|
+
import { requestScopeSlot } from './requestScopeSlot.ts'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Reactive network-connectivity probe in the pending()/refreshing() family:
|
|
6
|
+
reading it from a $derived/$effect re-runs that scope when the browser's
|
|
7
|
+
online/offline events fire. navigator.onLine's *offline* signal is reliable
|
|
8
|
+
(a true network loss always reports); its online value can false-positive
|
|
9
|
+
behind captive portals — verified backend reachability is a separate,
|
|
10
|
+
opt-in concern (the bundle launcher's liveness watch owns it for bundles).
|
|
11
|
+
|
|
12
|
+
On the server it reflects the *calling client's* reported connectivity — the
|
|
13
|
+
OFFLINE_HEADER a abide RPC fetch stamps while offline (read off the request
|
|
14
|
+
scope). In a bundle the client and embedded server share a machine, so this is
|
|
15
|
+
exactly the outbound reachability a handler reaching external sites needs:
|
|
16
|
+
`if (!online()) return error(503)` skips a doomed fetch. True outside any
|
|
17
|
+
request scope (boot, cron) and for non-abide-client requests (no header).
|
|
18
|
+
|
|
19
|
+
It answers "did the calling client report itself offline," NOT "can this
|
|
20
|
+
server reach the internet." So during SSR it is always true: the initial
|
|
21
|
+
render is a browser document navigation abide didn't issue, carrying no
|
|
22
|
+
header — there's been no client round-trip to report connectivity yet. Gate
|
|
23
|
+
external fetches on online() in the RPC/handler path (a real client called),
|
|
24
|
+
not in SSR; in SSR bound the fetch with AbortSignal.timeout instead, or defer
|
|
25
|
+
the read to the hydrated client where navigator.onLine is live. Bundles feel
|
|
26
|
+
this most — localhost serves the SSR even with the machine offline.
|
|
27
|
+
|
|
28
|
+
Reports, never acts — reading this opens no fetch and no stream.
|
|
29
|
+
*/
|
|
30
|
+
const subscribeOnline =
|
|
31
|
+
typeof window === 'undefined'
|
|
32
|
+
? undefined
|
|
33
|
+
: createSubscriber((update) => {
|
|
34
|
+
const changed = () => update()
|
|
35
|
+
window.addEventListener('online', changed)
|
|
36
|
+
window.addEventListener('offline', changed)
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener('online', changed)
|
|
39
|
+
window.removeEventListener('offline', changed)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// @readme probes
|
|
44
|
+
export function online(): boolean {
|
|
45
|
+
/* window, not navigator: Bun defines a partial navigator with no onLine. */
|
|
46
|
+
if (typeof window === 'undefined') {
|
|
47
|
+
return requestScopeSlot.resolver?.()?.online ?? true
|
|
48
|
+
}
|
|
49
|
+
subscribeOnline?.()
|
|
50
|
+
return navigator.onLine
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { activePage } from './activePage.ts'
|
|
2
|
+
import type { PageSnapshot } from './types/PageSnapshot.ts'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
The reactive page proxy: the matched route, decoded params, browser-space URL,
|
|
6
|
+
and `navigating` flag for the active page. Isomorphic — the server resolver reads
|
|
7
|
+
the per-request store, the client resolver the router-updated snapshot — so
|
|
8
|
+
`{page.url.pathname}` and `page.params.id` work the same during SSR and after
|
|
9
|
+
hydration. Read inside a abide-ui effect/derived, a field re-runs its reader when
|
|
10
|
+
navigation updates the snapshot (the client resolver reads a abide-ui signal).
|
|
11
|
+
|
|
12
|
+
`url` is browser-space on both sides: under a mount base the pathname carries the
|
|
13
|
+
prefix (the server re-applies it to the proxy-stripped request URL), so compare
|
|
14
|
+
active state against url() output, e.g. `page.url.pathname.startsWith(url('/x'))`.
|
|
15
|
+
*/
|
|
16
|
+
// @readme page
|
|
17
|
+
export const page: PageSnapshot = {
|
|
18
|
+
get route(): string {
|
|
19
|
+
return activePage().route
|
|
20
|
+
},
|
|
21
|
+
get params(): Record<string, string> {
|
|
22
|
+
return activePage().params
|
|
23
|
+
},
|
|
24
|
+
get url(): URL {
|
|
25
|
+
return activePage().url
|
|
26
|
+
},
|
|
27
|
+
get navigating(): boolean {
|
|
28
|
+
return activePage().navigating
|
|
29
|
+
},
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PageSnapshot } from './types/PageSnapshot.ts'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Internal slot the runtime entries register their page resolver into. The
|
|
5
|
+
server entry installs an ALS-backed resolver (request-scoped, so concurrent
|
|
6
|
+
and streaming renders never share state); the client entry installs a
|
|
7
|
+
module-singleton resolver. `fallback` is a single lazy snapshot used only
|
|
8
|
+
when no resolver is registered — keeps isolated tests working without forcing
|
|
9
|
+
them to spin up the runtime. Mirrors cacheStoreSlot.
|
|
10
|
+
*/
|
|
11
|
+
export const pageSlot: {
|
|
12
|
+
resolver: (() => PageSnapshot | undefined) | undefined
|
|
13
|
+
fallback: PageSnapshot | undefined
|
|
14
|
+
} = {
|
|
15
|
+
resolver: undefined,
|
|
16
|
+
fallback: undefined,
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Maps a page-relative path (under `src/ui/pages/`) to its URL route. Pages are
|
|
3
|
+
folder-based: every leaf is `page.abide` or `layout.abide`, and the URL
|
|
4
|
+
is the directory path. Pages mount at the directory path; layouts mount at
|
|
5
|
+
the directory prefix. Dynamic segments keep their `[name]` / `[...rest]`
|
|
6
|
+
shape — translation to Bun's `:name` / `*` happens at server registration
|
|
7
|
+
via toBunRoutePattern; consumers see the readable form in `nav.route`.
|
|
8
|
+
*/
|
|
9
|
+
export function pageUrlForFile(relPath: string): string {
|
|
10
|
+
const segments = relPath.split('/')
|
|
11
|
+
segments.pop()
|
|
12
|
+
const path = segments.filter(Boolean).join('/')
|
|
13
|
+
return path === '' ? '/' : `/${path}`
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Parses an env string into an integer within [min, max], returning undefined for
|
|
3
|
+
missing, empty, or out-of-range/non-integer input so the caller can fall back to
|
|
4
|
+
a default. A bare Number() turns '' into 0 and 'abc' into NaN, both silently
|
|
5
|
+
wrong; this rejects them instead.
|
|
6
|
+
*/
|
|
7
|
+
export function parseBoundedEnvInt(
|
|
8
|
+
value: string | undefined,
|
|
9
|
+
min: number,
|
|
10
|
+
max: number,
|
|
11
|
+
): number | undefined {
|
|
12
|
+
if (value === undefined || value.trim() === '') {
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
15
|
+
const parsed = Number(value)
|
|
16
|
+
if (!Number.isInteger(parsed) || parsed < min || parsed > max) {
|
|
17
|
+
return undefined
|
|
18
|
+
}
|
|
19
|
+
return parsed
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
DEBUG's comma list, parsed once per distinct string — the gate runs on every
|
|
3
|
+
log emission, and the env never changes server-side. A single-slot memo
|
|
4
|
+
suffices: the browser's abide-debug localStorage toggle produces a new string
|
|
5
|
+
that misses the memo and reparses.
|
|
6
|
+
*/
|
|
7
|
+
let lastEnv: string | undefined
|
|
8
|
+
let lastPatterns: string[] = []
|
|
9
|
+
|
|
10
|
+
export function parseDebugPatterns(env: string | undefined): string[] {
|
|
11
|
+
if (env !== lastEnv) {
|
|
12
|
+
lastEnv = env
|
|
13
|
+
lastPatterns = env
|
|
14
|
+
? env
|
|
15
|
+
.split(',')
|
|
16
|
+
.map((raw) => raw.trim())
|
|
17
|
+
.filter((pattern) => pattern !== '')
|
|
18
|
+
: []
|
|
19
|
+
}
|
|
20
|
+
return lastPatterns
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const ENV_LINE = /^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Parses `.env` text into a key→value record. Skips blanks, comments, and
|
|
5
|
+
malformed lines; strips a single layer of surrounding single or double quotes.
|
|
6
|
+
Intentionally minimal — no variable expansion, escapes, or multi-line. The pure
|
|
7
|
+
counterpart to loadEnvFile (which merges into process.env) and serializeEnv
|
|
8
|
+
(which writes records back), so all three round-trip the same shape.
|
|
9
|
+
*/
|
|
10
|
+
export function parseEnv(text: string): Record<string, string> {
|
|
11
|
+
const result: Record<string, string> = {}
|
|
12
|
+
for (const line of text.split('\n')) {
|
|
13
|
+
if (!line || line.startsWith('#')) {
|
|
14
|
+
continue
|
|
15
|
+
}
|
|
16
|
+
const match = ENV_LINE.exec(line)
|
|
17
|
+
if (!match) {
|
|
18
|
+
continue
|
|
19
|
+
}
|
|
20
|
+
const [, key, rawValue] = match
|
|
21
|
+
const trimmed = rawValue?.trim() ?? ''
|
|
22
|
+
const unquoted =
|
|
23
|
+
(trimmed.startsWith('"') && trimmed.endsWith('"')) ||
|
|
24
|
+
(trimmed.startsWith("'") && trimmed.endsWith("'"))
|
|
25
|
+
? trimmed.slice(1, -1)
|
|
26
|
+
: trimmed
|
|
27
|
+
result[key as string] = unquoted
|
|
28
|
+
}
|
|
29
|
+
return result
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PromptArgument } from './types/PromptArgument.ts'
|
|
2
|
+
|
|
3
|
+
export type ParsedPromptMarkdown = {
|
|
4
|
+
description: string | undefined
|
|
5
|
+
arguments: PromptArgument[]
|
|
6
|
+
body: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Leading YAML frontmatter block fenced by `---` lines (CRLF tolerant).
|
|
10
|
+
const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Splits a `src/mcp/prompts/**.md` file into its frontmatter metadata and
|
|
14
|
+
template body. The frontmatter (optional) carries `description` and an
|
|
15
|
+
`arguments` list; everything after the closing `---` is the prompt body,
|
|
16
|
+
interpolated at render time via `{{name}}` placeholders. A file with no
|
|
17
|
+
frontmatter is all body. Parsed with Bun.YAML — the resolver plugin runs
|
|
18
|
+
under Bun, so the native parser is always available at build time.
|
|
19
|
+
*/
|
|
20
|
+
export function parsePromptMarkdown(source: string): ParsedPromptMarkdown {
|
|
21
|
+
const match = FRONTMATTER.exec(source)
|
|
22
|
+
if (!match) {
|
|
23
|
+
return { description: undefined, arguments: [], body: source.trim() }
|
|
24
|
+
}
|
|
25
|
+
// The pattern makes group 1 mandatory; the '' default exists for noUncheckedIndexedAccess in consumer tsconfigs.
|
|
26
|
+
const frontmatter = (Bun.YAML.parse(match[1] ?? '') ?? {}) as {
|
|
27
|
+
description?: string
|
|
28
|
+
arguments?: PromptArgument[]
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
description: frontmatter.description,
|
|
32
|
+
arguments: Array.isArray(frontmatter.arguments) ? frontmatter.arguments : [],
|
|
33
|
+
body: source.slice(match[0].length).trim(),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type RouteSegment =
|
|
2
|
+
| { kind: 'literal'; value: string }
|
|
3
|
+
| { kind: 'param'; name: string; catchAll: boolean }
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Splits a abide route URL into typed segments. `[name]` becomes a param,
|
|
7
|
+
`[...rest]` becomes a catch-all param, anything else is a literal. Used
|
|
8
|
+
by toBunRoutePattern (server-side Bun pattern emission) and writeRoutesDts
|
|
9
|
+
(client-side `Routes` type augmentation) so the two consumers can't drift
|
|
10
|
+
on what counts as a param.
|
|
11
|
+
*/
|
|
12
|
+
export function parseRouteSegments(routeUrl: string): RouteSegment[] {
|
|
13
|
+
return routeUrl.split('/').map((segment) => {
|
|
14
|
+
if (segment.startsWith('[...') && segment.endsWith(']')) {
|
|
15
|
+
return { kind: 'param', name: segment.slice(4, -1), catchAll: true }
|
|
16
|
+
}
|
|
17
|
+
if (segment.startsWith('[') && segment.endsWith(']')) {
|
|
18
|
+
return { kind: 'param', name: segment.slice(1, -1), catchAll: false }
|
|
19
|
+
}
|
|
20
|
+
return { kind: 'literal', value: segment }
|
|
21
|
+
})
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TraceContext } from './types/TraceContext.ts'
|
|
2
|
+
|
|
3
|
+
const TRACEPARENT_PATTERN = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Parses a W3C `traceparent` header into a TraceContext, or undefined when the
|
|
7
|
+
value is malformed (per spec, an unreadable header is ignored and the receiver
|
|
8
|
+
starts a fresh trace). Rejects the all-zero trace/span ids and the reserved
|
|
9
|
+
version 'ff'. The header's span id lands in `spanId`: from the wire's point of
|
|
10
|
+
view that field is "the id of the step that sent this" — callers minting their
|
|
11
|
+
own step id move it to `parentSpanId` (createTraceContext does).
|
|
12
|
+
*/
|
|
13
|
+
export function parseTraceparent(header: string): TraceContext | undefined {
|
|
14
|
+
const match = TRACEPARENT_PATTERN.exec(header.trim().toLowerCase())
|
|
15
|
+
if (!match) {
|
|
16
|
+
return undefined
|
|
17
|
+
}
|
|
18
|
+
/* The pattern makes all four groups mandatory, but consumer tsconfigs with
|
|
19
|
+
noUncheckedIndexedAccess type-check this shipped source and see them as
|
|
20
|
+
possibly undefined — default to '' so the zero-id guards reject that path. */
|
|
21
|
+
const [, version = '', traceId = '', spanId = '', flags = ''] = match
|
|
22
|
+
if (version === 'ff' || /^0*$/.test(traceId) || /^0*$/.test(spanId)) {
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
25
|
+
return { traceId, spanId, flags }
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { probeRegistries } from './probeRegistries.ts'
|
|
2
|
+
import type { CacheEntry } from './types/CacheEntry.ts'
|
|
3
|
+
import type { CacheSelector } from './types/CacheSelector.ts'
|
|
4
|
+
import type { Subscribable } from './types/Subscribable.ts'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
Reactive in-flight probe over both registries — the cache (calls) and the
|
|
8
|
+
tail registry (streams). Pending means "no value yet":
|
|
9
|
+
pending() → any call in flight, or any registered stream
|
|
10
|
+
awaiting its first frame (global activity bar)
|
|
11
|
+
pending(fn) → that function's calls (per-route spinner; remote or
|
|
12
|
+
producer, same selector grammar as cache.invalidate)
|
|
13
|
+
pending(fn, args) → exactly that call (per-row spinner)
|
|
14
|
+
pending({ scope }) → a tagged group
|
|
15
|
+
pending(subscribable) → that stream awaiting its first frame
|
|
16
|
+
(tail.status === 'pending'; true when nothing
|
|
17
|
+
is reading yet — there is no value either way)
|
|
18
|
+
Probes report, never act: reading one opens no fetch and no stream. SSR
|
|
19
|
+
loading state is driven by {#await}, not this. Scan semantics (tap order,
|
|
20
|
+
selector grammar, registry spans) live in probeRegistries.
|
|
21
|
+
*/
|
|
22
|
+
// @readme probes
|
|
23
|
+
export function pending<Args, Return>(
|
|
24
|
+
arg?: CacheSelector<Args, Return> | Subscribable<unknown>,
|
|
25
|
+
args?: Args,
|
|
26
|
+
): boolean {
|
|
27
|
+
return probeRegistries(arg, args, 'pending', unsettled, true)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const unsettled = (entry: CacheEntry) => entry.settled !== true
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { findExportCallSite } from './findExportCallSite.ts'
|
|
2
|
+
import { importNamesToStrip } from './importNamesToStrip.ts'
|
|
3
|
+
import { stripImport } from './stripImport.ts'
|
|
4
|
+
import type { HttpVerb } from './types/HttpVerb.ts'
|
|
5
|
+
|
|
6
|
+
const VERB_NAMES = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'] as const
|
|
7
|
+
const VERB_SET = new Set<string>(VERB_NAMES)
|
|
8
|
+
|
|
9
|
+
const SINGLE_EXPORT_ERROR =
|
|
10
|
+
'[abide] $rpc module contains more than one `<VERB>(...)` export — each file must declare exactly one remote function'
|
|
11
|
+
|
|
12
|
+
export type PreparedRpcModule = {
|
|
13
|
+
verb: HttpVerb
|
|
14
|
+
exportName: string
|
|
15
|
+
rewriteForServer: (url: string) => string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
Scans an `$rpc/**` module once and returns its declared verb + export
|
|
20
|
+
name plus a closure that, given the route URL, emits the server-side
|
|
21
|
+
rewrite (`__abideDefineVerb__("VERB", "<url>", … )` spliced into the
|
|
22
|
+
original source). The single scan replaces the prior separate
|
|
23
|
+
extract + rewrite passes, so the resolver plugin only walks each source
|
|
24
|
+
character-by-character once.
|
|
25
|
+
|
|
26
|
+
A regex pass would be tidier but it can't tell a `GET` mention inside a
|
|
27
|
+
docstring or template literal from the real call, and it can't follow
|
|
28
|
+
nested generics like `GET<Map<K, V>>(`.
|
|
29
|
+
*/
|
|
30
|
+
export function prepareRpcModule(
|
|
31
|
+
source: string,
|
|
32
|
+
importName: string,
|
|
33
|
+
): PreparedRpcModule | undefined {
|
|
34
|
+
/*
|
|
35
|
+
The "no barrels" surface places each verb at its own path
|
|
36
|
+
(`abide/server/GET`, `abide/server/POST`, …) — strip every one so
|
|
37
|
+
the user's verb import doesn't linger and side-effect-load the
|
|
38
|
+
stub module into the server bundle. The user may import under the
|
|
39
|
+
project's chosen name or the canonical package name, so strip both.
|
|
40
|
+
*/
|
|
41
|
+
const stripped = importNamesToStrip(importName).reduce(
|
|
42
|
+
(current, name) =>
|
|
43
|
+
VERB_NAMES.reduce((acc, verb) => stripImport(acc, `${name}/server/${verb}`), current),
|
|
44
|
+
source,
|
|
45
|
+
)
|
|
46
|
+
const site = findExportCallSite(stripped, (ident) => VERB_SET.has(ident), SINGLE_EXPORT_ERROR)
|
|
47
|
+
if (!site) {
|
|
48
|
+
return undefined
|
|
49
|
+
}
|
|
50
|
+
const verb = site.ident as HttpVerb
|
|
51
|
+
return {
|
|
52
|
+
verb,
|
|
53
|
+
exportName: site.exportName,
|
|
54
|
+
rewriteForServer(url: string): string {
|
|
55
|
+
const binding = `__abideDefineVerb__(${JSON.stringify(verb)}, ${JSON.stringify(url)}, `
|
|
56
|
+
return stripped.slice(0, site.callStart) + binding + stripped.slice(site.parenStart + 1)
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { findExportCallSite } from './findExportCallSite.ts'
|
|
2
|
+
import { importNamesToStrip } from './importNamesToStrip.ts'
|
|
3
|
+
import { stripImport } from './stripImport.ts'
|
|
4
|
+
|
|
5
|
+
const SINGLE_EXPORT_ERROR =
|
|
6
|
+
'[abide] $sockets module contains more than one `socket(...)` export — each file must declare exactly one socket'
|
|
7
|
+
|
|
8
|
+
export type PreparedSocketModule = {
|
|
9
|
+
exportName: string
|
|
10
|
+
rewriteForServer: (name: string) => string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Scans a `$sockets/**` module once and returns its declared export name
|
|
15
|
+
plus a closure that, given the socket name, emits the server-side
|
|
16
|
+
rewrite (`__abideDefineSocket__("<name>"[, opts])` spliced into the
|
|
17
|
+
original source). The single scan replaces the prior separate
|
|
18
|
+
extract + rewrite passes, so the resolver plugin only walks each source
|
|
19
|
+
character-by-character once.
|
|
20
|
+
*/
|
|
21
|
+
export function prepareSocketModule(
|
|
22
|
+
source: string,
|
|
23
|
+
importName: string,
|
|
24
|
+
): PreparedSocketModule | undefined {
|
|
25
|
+
/*
|
|
26
|
+
Strip the user's `socket` import under the project's chosen name and the
|
|
27
|
+
canonical package name so the dead import can't side-effect-load the
|
|
28
|
+
socket helper into the server bundle.
|
|
29
|
+
*/
|
|
30
|
+
const stripped = importNamesToStrip(importName).reduce(
|
|
31
|
+
(current, name) => stripImport(current, `${name}/server/socket`),
|
|
32
|
+
source,
|
|
33
|
+
)
|
|
34
|
+
const site = findExportCallSite(stripped, (ident) => ident === 'socket', SINGLE_EXPORT_ERROR)
|
|
35
|
+
if (!site) {
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
exportName: site.exportName,
|
|
40
|
+
rewriteForServer(name: string): string {
|
|
41
|
+
const inner = stripped.slice(site.parenStart + 1, site.parenEnd).trim()
|
|
42
|
+
const binding =
|
|
43
|
+
inner.length === 0
|
|
44
|
+
? `__abideDefineSocket__(${JSON.stringify(name)})`
|
|
45
|
+
: `__abideDefineSocket__(${JSON.stringify(name)}, ${stripped.slice(site.parenStart + 1, site.parenEnd)})`
|
|
46
|
+
return stripped.slice(0, site.callStart) + binding + stripped.slice(site.parenEnd + 1)
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|