@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
package/src/bundleApp.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { dirname } from 'node:path'
|
|
2
|
+
import { buildDisconnected } from './buildDisconnected.ts'
|
|
3
|
+
import { compile } from './compile.ts'
|
|
4
|
+
import { ensureWebviewLib } from './lib/bundle/ensureWebviewLib.ts'
|
|
5
|
+
import { infoPlist } from './lib/bundle/infoPlist.ts'
|
|
6
|
+
import { pngToIcns } from './lib/bundle/pngToIcns.ts'
|
|
7
|
+
import { serverBinaryFilename } from './lib/bundle/serverBinaryFilename.ts'
|
|
8
|
+
import { signMacApp } from './lib/bundle/signMacApp.ts'
|
|
9
|
+
import { webviewLibName } from './lib/bundle/webviewLibName.ts'
|
|
10
|
+
import { abideLog } from './lib/shared/abideLog.ts'
|
|
11
|
+
import { bundleLayout } from './lib/shared/bundleLayout.ts'
|
|
12
|
+
import { detectTarget } from './lib/shared/detectTarget.ts'
|
|
13
|
+
import { exitOnBuildFailure } from './lib/shared/exitOnBuildFailure.ts'
|
|
14
|
+
import { programNameForPackage } from './lib/shared/programNameForPackage.ts'
|
|
15
|
+
import { readPackageJson } from './lib/shared/readPackageJson.ts'
|
|
16
|
+
import { serverBuildPlugins } from './serverBuildPlugins.ts'
|
|
17
|
+
|
|
18
|
+
const APP_ENTRY = new URL('./appEntry.ts', import.meta.url).pathname
|
|
19
|
+
const WORKER_ENTRY = new URL('./controlServerWorker.ts', import.meta.url).pathname
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
Assembles a movable, self-contained app bundle for the host platform —
|
|
23
|
+
no cross-compilation, and on macOS an ad-hoc seal so it launches on other
|
|
24
|
+
Macs (signMacApp). Three pieces travel together so the app runs on another
|
|
25
|
+
machine of the same OS with nothing installed:
|
|
26
|
+
|
|
27
|
+
- the standalone server binary (`compile()`, assets embedded)
|
|
28
|
+
- the launcher binary (appEntry — spawns the server, opens the webview)
|
|
29
|
+
- the native webview shared library
|
|
30
|
+
|
|
31
|
+
macOS gets a `.app` bundle (`Contents/MacOS/` + `Contents/Frameworks/` +
|
|
32
|
+
Info.plist); other platforms get a flat `<name>/` directory with the two
|
|
33
|
+
binaries and the lib side by side. The launcher finds both relatives at
|
|
34
|
+
runtime via resolveServerBinary / resolveWebviewLib.
|
|
35
|
+
*/
|
|
36
|
+
export async function bundleApp({ cwd = process.cwd() }: { cwd?: string } = {}): Promise<string> {
|
|
37
|
+
const target = detectTarget()
|
|
38
|
+
const { name, version } = await readPackage(cwd)
|
|
39
|
+
const programName = programNameForPackage(name)
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
Layout differs by OS: a macOS .app nests binaries under Contents/MacOS, the
|
|
43
|
+
lib under Contents/Frameworks, and data under Contents/Resources; elsewhere
|
|
44
|
+
everything sits flat in one directory. bundleLayout derives the rest from
|
|
45
|
+
binDir — the same source the boot readers resolve from — so build and runtime
|
|
46
|
+
agree on where the lib, resources, and shipped `.env` land.
|
|
47
|
+
*/
|
|
48
|
+
const isMac = process.platform === 'darwin'
|
|
49
|
+
const bundleRoot = isMac ? `${cwd}/dist/${programName}.app` : `${cwd}/dist/${programName}`
|
|
50
|
+
const binDir = isMac ? `${bundleRoot}/Contents/MacOS` : bundleRoot
|
|
51
|
+
const { libDir, resourcesDir, envPath } = bundleLayout(binDir)
|
|
52
|
+
|
|
53
|
+
await Bun.$`rm -rf ${bundleRoot}`.quiet()
|
|
54
|
+
await Bun.$`mkdir -p ${binDir} ${libDir}`.quiet()
|
|
55
|
+
|
|
56
|
+
// 1. Server binary — self-contained, embeds the client assets. compile()
|
|
57
|
+
// runs the client build, which clears dist first, so it must precede the
|
|
58
|
+
// connect-screen build that writes into dist.
|
|
59
|
+
await compile({ cwd, target, outfile: `${binDir}/${serverBinaryFilename()}` })
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
Opt-in: ship the project's `bundle.env` as the shipped `.env`, which the
|
|
63
|
+
server loads at boot (loadEnvFromBinaryDir) as its default config layer. A
|
|
64
|
+
dedicated file, never the working `.env` — a compiled bundle is extractable,
|
|
65
|
+
so only ship-safe defaults belong here; user-specific/secret values come from
|
|
66
|
+
the data-dir `.env` instead. Named outside Bun's `.env.*` autoload family on
|
|
67
|
+
purpose: it's a build input, not a runtime overlay, so `bun dev`/`bun start`
|
|
68
|
+
never pick it up. bundleLayout places it under Contents/Resources
|
|
69
|
+
in a macOS `.app` (sealed as a resource, so it survives codesign) and beside
|
|
70
|
+
the binaries otherwise. Skipped when absent.
|
|
71
|
+
*/
|
|
72
|
+
const bundleEnv = Bun.file(`${cwd}/bundle.env`)
|
|
73
|
+
if (await bundleEnv.exists()) {
|
|
74
|
+
await Bun.$`mkdir -p ${dirname(envPath)}`.quiet()
|
|
75
|
+
await Bun.write(envPath, bundleEnv)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 2. Connect screen — bake dist/bundle-disconnected.html before the launcher
|
|
79
|
+
// build, which inlines it via the abide:bundle-disconnected virtual.
|
|
80
|
+
await buildDisconnected({ cwd })
|
|
81
|
+
|
|
82
|
+
// 3. Launcher binary — named after the program so CFBundleExecutable matches.
|
|
83
|
+
const launcherSuffix = target.includes('windows') ? '.exe' : ''
|
|
84
|
+
const launcherPath = `${binDir}/${programName}${launcherSuffix}`
|
|
85
|
+
const launcherResult = await Bun.build({
|
|
86
|
+
entrypoints: [APP_ENTRY],
|
|
87
|
+
target: 'bun',
|
|
88
|
+
compile: { target, outfile: launcherPath },
|
|
89
|
+
plugins: serverBuildPlugins({ cwd }),
|
|
90
|
+
/*
|
|
91
|
+
Inject the worker's absolute path as a static literal. `new Worker()` is
|
|
92
|
+
embedded into the standalone binary only when its specifier is a build-time
|
|
93
|
+
literal, and a relative one would resolve against `cwd` (the consumer
|
|
94
|
+
project) rather than appEntry's directory — so the launcher passes the
|
|
95
|
+
absolute path through this define instead.
|
|
96
|
+
*/
|
|
97
|
+
define: { __ABIDE_WORKER_ENTRY__: JSON.stringify(WORKER_ENTRY) },
|
|
98
|
+
})
|
|
99
|
+
exitOnBuildFailure(launcherResult)
|
|
100
|
+
|
|
101
|
+
// 4. Webview lib — built from the vendored source if needed, then copied
|
|
102
|
+
// beside the binaries (or into Frameworks on macOS) so the bundle is self-contained.
|
|
103
|
+
const libSource = await ensureWebviewLib(cwd)
|
|
104
|
+
await Bun.write(`${libDir}/${webviewLibName()}`, Bun.file(libSource))
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
macOS-only: produce Contents/Resources/icon.icns from an optional project
|
|
108
|
+
icon, then write the Info.plist that makes the .app launchable from
|
|
109
|
+
Finder, wiring CFBundleIconFile when an icon was produced. A ready-made
|
|
110
|
+
src/bundle/icon.icns is used as-is; otherwise src/bundle/icon.png is
|
|
111
|
+
converted via sips + iconutil so authors don't need to make an .icns.
|
|
112
|
+
*/
|
|
113
|
+
if (isMac) {
|
|
114
|
+
const icnsSource = `${cwd}/src/bundle/icon.icns`
|
|
115
|
+
const pngSource = `${cwd}/src/bundle/icon.png`
|
|
116
|
+
let hasIcon = false
|
|
117
|
+
if (await Bun.file(icnsSource).exists()) {
|
|
118
|
+
await Bun.$`mkdir -p ${resourcesDir}`.quiet()
|
|
119
|
+
await Bun.write(`${resourcesDir}/icon.icns`, Bun.file(icnsSource))
|
|
120
|
+
hasIcon = true
|
|
121
|
+
} else if (await Bun.file(pngSource).exists()) {
|
|
122
|
+
await Bun.$`mkdir -p ${resourcesDir}`.quiet()
|
|
123
|
+
hasIcon = await pngToIcns(pngSource, `${resourcesDir}/icon.icns`)
|
|
124
|
+
}
|
|
125
|
+
await Bun.write(
|
|
126
|
+
`${bundleRoot}/Contents/Info.plist`,
|
|
127
|
+
infoPlist({ name: programName, version, icon: hasIcon ? 'icon' : undefined }),
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
// Seal the finished bundle so it launches on other Macs — must run last,
|
|
131
|
+
// after every binary, the lib, and Info.plist are in place.
|
|
132
|
+
await signMacApp(bundleRoot, [
|
|
133
|
+
`${libDir}/${webviewLibName()}`,
|
|
134
|
+
`${binDir}/${serverBinaryFilename()}`,
|
|
135
|
+
launcherPath,
|
|
136
|
+
])
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
abideLog.success(`bundled app: ${bundleRoot} (target: ${target})`)
|
|
140
|
+
return bundleRoot
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Reads name + version from package.json, with fallbacks when absent.
|
|
144
|
+
async function readPackage(cwd: string): Promise<{ name: string | undefined; version: string }> {
|
|
145
|
+
const pkg = (await readPackageJson(cwd)) as { name?: string; version?: string } | undefined
|
|
146
|
+
return { name: pkg?.name, version: pkg?.version ?? '0.0.0' }
|
|
147
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @ts-expect-error virtual module resolved by abideResolverPlugin
|
|
2
|
+
import Disconnected from './_virtual/bundle-disconnected-component.ts'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Client entry for the bundle connect screen. Standalone — it mounts the
|
|
6
|
+
disconnected component (the user's src/bundle/disconnected.abide override or the
|
|
7
|
+
lib default, picked by the resolver) into #app, with no router or SSR hydration.
|
|
8
|
+
buildDisconnected bundles this into a single self-contained HTML file. A compiled
|
|
9
|
+
abide-ui component's default export is its mounter, so calling it mounts.
|
|
10
|
+
*/
|
|
11
|
+
const target = document.getElementById('app')
|
|
12
|
+
if (target) {
|
|
13
|
+
Disconnected(target)
|
|
14
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import ts from 'typescript'
|
|
3
|
+
import { collectAbideDiagnostics } from './lib/ui/compile/collectAbideDiagnostics.ts'
|
|
4
|
+
import { createShadowProgram } from './lib/ui/compile/createShadowProgram.ts'
|
|
5
|
+
import { nearestProjectRoot } from './lib/ui/compile/nearestProjectRoot.ts'
|
|
6
|
+
import type { AbideDiagnostic } from './lib/ui/compile/types/AbideDiagnostic.ts'
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
Type-checks every `.abide` component in `cwd` through its shadow (ADR-0010) and
|
|
10
|
+
prints the diagnostics against the source files with a code frame — a
|
|
11
|
+
component type-check pass. Each component is grouped under its nearest tsconfig and
|
|
12
|
+
checked against that project's options, so a monorepo checked at its root reports
|
|
13
|
+
the same as each package checked on its own — and the same as the LSP. Returns
|
|
14
|
+
the error count so the CLI can set its exit code.
|
|
15
|
+
*/
|
|
16
|
+
export async function checkAbide({ cwd }: { cwd: string }): Promise<number> {
|
|
17
|
+
const diagnostics = collectByProject(cwd)
|
|
18
|
+
const byFile = new Map<string, AbideDiagnostic[]>()
|
|
19
|
+
for (const diagnostic of diagnostics) {
|
|
20
|
+
const bucket = byFile.get(diagnostic.file) ?? []
|
|
21
|
+
bucket.push(diagnostic)
|
|
22
|
+
byFile.set(diagnostic.file, bucket)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const [file, fileDiagnostics] of byFile) {
|
|
26
|
+
const text = (await Bun.file(file).text()).replaceAll('\r\n', '\n')
|
|
27
|
+
for (const diagnostic of fileDiagnostics.toSorted((a, b) => a.start - b.start)) {
|
|
28
|
+
printDiagnostic(file, text, diagnostic)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const errors = diagnostics.filter(
|
|
33
|
+
(diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error,
|
|
34
|
+
).length
|
|
35
|
+
const relative = byFile.size
|
|
36
|
+
console.log(
|
|
37
|
+
errors === 0
|
|
38
|
+
? `\n[abide check] no type errors in ${relative} component${relative === 1 ? '' : 's'}`
|
|
39
|
+
: `\n[abide check] ${errors} error${errors === 1 ? '' : 's'} in ${relative} file${relative === 1 ? '' : 's'}`,
|
|
40
|
+
)
|
|
41
|
+
return errors
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Groups every `.abide` under `cwd` by its nearest tsconfig and type-checks each
|
|
45
|
+
project's components against that project's options, then concatenates the
|
|
46
|
+
diagnostics. Imported components from another project resolve on demand through
|
|
47
|
+
the host, so the per-project root set stays each project's own files. */
|
|
48
|
+
function collectByProject(cwd: string): AbideDiagnostic[] {
|
|
49
|
+
const byProject = new Map<string, string[]>()
|
|
50
|
+
for (const relative of new Bun.Glob('**/*.abide').scanSync({ cwd, onlyFiles: true })) {
|
|
51
|
+
if (relative.includes('node_modules')) {
|
|
52
|
+
continue
|
|
53
|
+
}
|
|
54
|
+
const path = resolve(cwd, relative)
|
|
55
|
+
const root = nearestProjectRoot(path, cwd)
|
|
56
|
+
byProject.set(root, [...(byProject.get(root) ?? []), path])
|
|
57
|
+
}
|
|
58
|
+
return [...byProject].flatMap(([root, paths]) =>
|
|
59
|
+
collectAbideDiagnostics(createShadowProgram(root, paths)),
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Renders one diagnostic as `path:line:col severity message` plus the offending
|
|
64
|
+
line and a caret underline spanning the mapped range. */
|
|
65
|
+
function printDiagnostic(file: string, text: string, diagnostic: AbideDiagnostic): void {
|
|
66
|
+
const before = text.slice(0, diagnostic.start)
|
|
67
|
+
const lineNumber = before.split('\n').length
|
|
68
|
+
const column = diagnostic.start - (before.lastIndexOf('\n') + 1)
|
|
69
|
+
const lineText = text.split('\n')[lineNumber - 1] ?? ''
|
|
70
|
+
const severity = diagnostic.category === ts.DiagnosticCategory.Error ? 'error' : 'warning'
|
|
71
|
+
const gutter = String(lineNumber)
|
|
72
|
+
console.log(`\n${file}:${lineNumber}:${column + 1} ${severity} ${diagnostic.message}`)
|
|
73
|
+
console.log(` ${gutter} | ${lineText}`)
|
|
74
|
+
console.log(
|
|
75
|
+
` ${' '.repeat(gutter.length)} | ${' '.repeat(column)}${'^'.repeat(Math.max(1, diagnostic.length))}`,
|
|
76
|
+
)
|
|
77
|
+
}
|
package/src/cliEntry.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-expect-error virtual module resolved by abideResolverPlugin
|
|
2
|
+
import { banner, footer } from './_virtual/cli-chrome.ts'
|
|
3
|
+
// @ts-expect-error virtual module resolved by abideResolverPlugin
|
|
4
|
+
import manifest from './_virtual/cli-manifest.ts'
|
|
5
|
+
// @ts-expect-error virtual module resolved by abideResolverPlugin
|
|
6
|
+
import programName from './_virtual/cli-name.ts'
|
|
7
|
+
import { runCli } from './lib/cli/runCli.ts'
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
Standalone CLI binary entry. Compiled with `bun build --compile` into
|
|
11
|
+
`dist/cli` (or `dist/cli-thin/<platform>/` for cross-builds). The CLI is
|
|
12
|
+
a thin remote client — no handler code is bundled; it talks to a running
|
|
13
|
+
server over HTTP (ABIDE_APP_URL at runtime). The bundler emits:
|
|
14
|
+
- abide:cli-manifest — the per-rpc manifest (method, url, jsonSchema)
|
|
15
|
+
- abide:cli-name — the program name from package.json
|
|
16
|
+
- abide:cli-chrome — optional banner/footer text from src/cli/
|
|
17
|
+
*/
|
|
18
|
+
const exitCode = await runCli({
|
|
19
|
+
programName,
|
|
20
|
+
manifest,
|
|
21
|
+
banner,
|
|
22
|
+
footer,
|
|
23
|
+
argv: process.argv.slice(2),
|
|
24
|
+
})
|
|
25
|
+
process.exit(exitCode)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun'
|
|
2
|
+
import { abideResolverPlugin } from './abideResolverPlugin.ts'
|
|
3
|
+
import { abideLog } from './lib/shared/abideLog.ts'
|
|
4
|
+
import { isModuleNotFound } from './lib/shared/isModuleNotFound.ts'
|
|
5
|
+
import { abideUiPlugin } from './lib/ui/compile/abideUiPlugin.ts'
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
The client-target Bun.build plugin chain shared by the page bundle (build) and
|
|
9
|
+
the bundle connect screen (buildDisconnected): the abide-ui `.abide` loader,
|
|
10
|
+
abide's virtual-module resolver, and the optional Tailwind plugin. Tailwind is an
|
|
11
|
+
optional peer — a genuine "not installed" builds without it, but any other load
|
|
12
|
+
error surfaces (a plugin that loaded then threw on a real misconfig must not
|
|
13
|
+
silently ship unstyled). `tailwindWarning` names what each caller builds without
|
|
14
|
+
when Tailwind is absent.
|
|
15
|
+
*/
|
|
16
|
+
export async function clientBuildPlugins({
|
|
17
|
+
cwd,
|
|
18
|
+
tailwindWarning,
|
|
19
|
+
}: {
|
|
20
|
+
cwd: string
|
|
21
|
+
tailwindWarning: string
|
|
22
|
+
}): Promise<BunPlugin[]> {
|
|
23
|
+
const plugins: BunPlugin[] = [abideUiPlugin, abideResolverPlugin({ cwd, target: 'client' })]
|
|
24
|
+
try {
|
|
25
|
+
plugins.push((await import('bun-plugin-tailwind')).default)
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (!isModuleNotFound(error)) {
|
|
28
|
+
throw error
|
|
29
|
+
}
|
|
30
|
+
abideLog.warn(tailwindWarning)
|
|
31
|
+
}
|
|
32
|
+
return plugins
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-expect-error virtual module resolved by abideResolverPlugin
|
|
2
|
+
import { layouts } from './_virtual/layouts.ts'
|
|
3
|
+
// @ts-expect-error virtual module resolved by abideResolverPlugin
|
|
4
|
+
import { pages } from './_virtual/pages.ts'
|
|
5
|
+
import type { RouteLoader } from './lib/ui/runtime/types/RouteLoader.ts'
|
|
6
|
+
import { startClient } from './lib/ui/startClient.ts'
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
The SSR client entry. The pages/layouts manifests are
|
|
10
|
+
`{ route: () => import(page.abide) }` / `{ dir: () => import(layout.abide) }`; hand
|
|
11
|
+
the loaders straight to abide-ui's startClient — the router imports each route's
|
|
12
|
+
chunk (and its layout chunks) only when first visited, so the initial load downloads
|
|
13
|
+
just the current route's chain (plus the entry), not every page up front. startClient
|
|
14
|
+
also seeds the cache from __SSR__, installs the base, and adopts the server-rendered
|
|
15
|
+
#app for the current route.
|
|
16
|
+
*/
|
|
17
|
+
startClient(pages as Record<string, RouteLoader>, layouts as Record<string, RouteLoader>)
|
package/src/compile.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { build } from './build.ts'
|
|
2
|
+
import { abideLog } from './lib/shared/abideLog.ts'
|
|
3
|
+
import { detectTarget } from './lib/shared/detectTarget.ts'
|
|
4
|
+
import { exeSuffix } from './lib/shared/exeSuffix.ts'
|
|
5
|
+
import { exitOnBuildFailure } from './lib/shared/exitOnBuildFailure.ts'
|
|
6
|
+
import type { CompileTarget } from './lib/shared/types/CompileTarget.ts'
|
|
7
|
+
import { serverBuildPlugins } from './serverBuildPlugins.ts'
|
|
8
|
+
|
|
9
|
+
const SERVER_ENTRY = new URL('./serverEntry.ts', import.meta.url).pathname
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Produces a standalone Bun executable for the server. Runs the client `build`
|
|
13
|
+
first so the resolver plugin can embed the gzip-compressed assets into
|
|
14
|
+
the binary, then invokes Bun.build in compile mode against the server
|
|
15
|
+
entry. Defaults
|
|
16
|
+
the target to the host platform and appends `.exe` for windows targets.
|
|
17
|
+
Returns the path of the emitted binary; exits the process on build failure.
|
|
18
|
+
*/
|
|
19
|
+
// @readme plumbing
|
|
20
|
+
export async function compile({
|
|
21
|
+
cwd = process.cwd(),
|
|
22
|
+
target = detectTarget(),
|
|
23
|
+
outfile,
|
|
24
|
+
buildClient = true,
|
|
25
|
+
}: {
|
|
26
|
+
cwd?: string
|
|
27
|
+
target?: CompileTarget
|
|
28
|
+
outfile?: string
|
|
29
|
+
/*
|
|
30
|
+
Skip the client `build` (which clears dist). Set false when the caller already
|
|
31
|
+
built the platform-independent client once and is compiling several server
|
|
32
|
+
binaries against it — e.g. `abide cli` co-shipping a per-platform server beside
|
|
33
|
+
each CLI binary — so the shared `dist/_app` isn't wiped between targets.
|
|
34
|
+
*/
|
|
35
|
+
buildClient?: boolean
|
|
36
|
+
} = {}): Promise<string> {
|
|
37
|
+
if (buildClient) {
|
|
38
|
+
await build({ cwd })
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const outPath = outfile ?? `${cwd}/dist/app${exeSuffix(target)}`
|
|
42
|
+
|
|
43
|
+
const result = await Bun.build({
|
|
44
|
+
entrypoints: [SERVER_ENTRY],
|
|
45
|
+
target: 'bun',
|
|
46
|
+
format: 'esm',
|
|
47
|
+
minify: true,
|
|
48
|
+
/*
|
|
49
|
+
Bytecode embeds precompiled JS module metadata directly into the
|
|
50
|
+
standalone binary, dramatically cutting cold-start time for large
|
|
51
|
+
apps. Requires `target: 'bun'` + an explicit `format` because the
|
|
52
|
+
default for `bytecode` alone is CommonJS; we need ESM bytecode.
|
|
53
|
+
*/
|
|
54
|
+
bytecode: true,
|
|
55
|
+
compile: { target, outfile: outPath },
|
|
56
|
+
plugins: serverBuildPlugins({ cwd, embedAssets: true }),
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
exitOnBuildFailure(result)
|
|
60
|
+
|
|
61
|
+
abideLog.success(`compiled standalone binary: ${outPath} (target: ${target})`)
|
|
62
|
+
return outPath
|
|
63
|
+
}
|