@abide/abide 0.48.0 → 0.50.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/AGENTS.md +85 -59
- package/CHANGELOG.md +216 -0
- package/README.md +21 -10
- package/package.json +15 -4
- package/src/abideLsp.ts +5 -6
- package/src/abideResolverPlugin.ts +197 -169
- package/src/build.ts +79 -56
- package/src/buildCli.ts +3 -5
- package/src/buildDisconnected.ts +2 -5
- package/src/bundleApp.ts +2 -3
- package/src/checkAbide.ts +12 -2
- package/src/compile.ts +2 -4
- package/src/devEntry.ts +113 -28
- package/src/discoveryEntry.ts +3 -2
- package/src/lib/bundle/disconnected.abide +69 -73
- package/src/lib/bundle/infoPlist.ts +13 -7
- package/src/lib/bundle/installDownloads.ts +13 -3
- package/src/lib/bundle/installMacMenu.ts +13 -3
- package/src/lib/bundle/spawnEmbeddedServer.ts +13 -4
- package/src/lib/bundle/waitForServer.ts +6 -1
- package/src/lib/cli/parseArgvForRpc.ts +36 -9
- package/src/lib/cli/tokenizeArgvFlags.ts +4 -2
- package/src/lib/mcp/createMcpResourceServer.ts +13 -2
- package/src/lib/mcp/mcpTools.ts +15 -6
- package/src/lib/mcp/toolResultFromResponse.ts +40 -12
- package/src/lib/server/error.ts +6 -6
- package/src/lib/server/json.ts +17 -3
- package/src/lib/server/rpc/defineRpc.ts +58 -24
- package/src/lib/server/rpc/parseArgs.ts +113 -14
- package/src/lib/server/rpc/resolveRpcJsonSchema.ts +28 -0
- package/src/lib/server/rpc/runWithRpcTimeout.ts +12 -1
- package/src/lib/server/rpc/types/RpcHelper.ts +75 -105
- package/src/lib/server/rpc/types/RpcRegistryEntry.ts +24 -9
- package/src/lib/server/rpc/validationError.ts +1 -1
- package/src/lib/server/runtime/DEV_RELOAD_CLIENT_SCRIPT.ts +0 -15
- package/src/lib/server/runtime/buildCacheSnapshot.ts +10 -9
- package/src/lib/server/runtime/buildInspectorSurface.ts +6 -4
- package/src/lib/server/runtime/buildOpenApiSpec.ts +55 -11
- package/src/lib/server/runtime/buildPreloadManifest.ts +12 -10
- package/src/lib/server/runtime/createAppAssetServer.ts +18 -15
- package/src/lib/server/runtime/createAppRouteResolver.ts +145 -0
- package/src/lib/server/runtime/createPlumbingRouter.ts +212 -0
- package/src/lib/server/runtime/createRouteDispatcher.ts +4 -10
- package/src/lib/server/runtime/createServer.ts +120 -324
- package/src/lib/server/runtime/createUiPageRenderer.ts +137 -26
- package/src/lib/server/runtime/devClientFingerprint.ts +19 -34
- package/src/lib/server/runtime/finalizeResponse.ts +11 -1
- package/src/lib/server/runtime/installAmbientScopeStore.ts +30 -9
- package/src/lib/server/runtime/logExposedSurfaces.ts +8 -7
- package/src/lib/server/runtime/pathStore.ts +15 -0
- package/src/lib/server/runtime/registryManifests.ts +1 -1
- package/src/lib/server/runtime/renderCellBarrierStore.ts +15 -0
- package/src/lib/server/runtime/runWithRequestScope.ts +3 -0
- package/src/lib/server/runtime/serializeCacheSnapshot.ts +6 -4
- package/src/lib/server/runtime/snapshotEntryFromCache.ts +24 -16
- package/src/lib/server/runtime/streamCacheResolutions.ts +14 -7
- package/src/lib/server/runtime/streamFromIterator.ts +30 -2
- package/src/lib/server/runtime/textResponse.ts +23 -0
- package/src/lib/server/runtime/types/DevReloadStamp.ts +6 -10
- package/src/lib/server/runtime/types/InspectorCacheEntry.ts +1 -1
- package/src/lib/server/runtime/types/RequestStore.ts +27 -0
- package/src/lib/server/runtime/warnUnguardedMcp.ts +15 -5
- package/src/lib/server/sockets/createSocketDispatcher.ts +9 -11
- package/src/lib/server/sockets/defineSocket.ts +5 -4
- package/src/lib/server/sse.ts +5 -1
- package/src/lib/shared/ASYNC_CELL.ts +5 -0
- package/src/lib/shared/DEV_REBUILD_PATH.ts +6 -0
- package/src/lib/shared/HTTP_METHODS.ts +6 -0
- package/src/lib/shared/HttpError.ts +1 -5
- package/src/lib/shared/MCP_PATH.ts +6 -0
- package/src/lib/shared/PROXIED_SERVER_SUBDIRS.ts +15 -0
- package/src/lib/shared/REF_JSON_TAGS.ts +13 -1
- package/src/lib/shared/RPC_SHIM_GLOBALS.ts +9 -0
- package/src/lib/shared/activeCacheStore.ts +1 -0
- package/src/lib/shared/activePage.ts +1 -0
- package/src/lib/shared/buildArtifact.ts +20 -0
- package/src/lib/shared/buildRpcRequest.ts +6 -2
- package/src/lib/shared/buildSocketOverChannel.ts +4 -3
- package/src/lib/shared/bundleGraphFromMetafile.ts +68 -0
- package/src/lib/shared/cache.ts +156 -131
- package/src/lib/shared/canonicalJson.ts +24 -1
- package/src/lib/shared/changeAffectsClient.ts +12 -7
- package/src/lib/shared/createCacheStore.ts +31 -8
- package/src/lib/shared/createChannelLog.ts +24 -0
- package/src/lib/shared/createLifecycleChannel.ts +7 -1
- package/src/lib/shared/createReachable.ts +47 -78
- package/src/lib/shared/createRemoteFunction.ts +52 -30
- package/src/lib/shared/createRpcServerProgram.ts +820 -0
- package/src/lib/shared/decodeRefJson.ts +4 -4
- package/src/lib/shared/decodeResponse.ts +2 -2
- package/src/lib/shared/decodeWireBody.ts +35 -0
- package/src/lib/shared/detectRpcMethod.ts +8 -1
- package/src/lib/shared/done.ts +8 -2
- package/src/lib/shared/encodeRefJson.ts +4 -4
- package/src/lib/shared/encodeWireBody.ts +18 -0
- package/src/lib/shared/exitOnBuildFailure.ts +4 -3
- package/src/lib/{server/rpc → shared}/fieldErrorsFromIssues.ts +5 -1
- package/src/lib/shared/generateDeclarations.ts +72 -0
- package/src/lib/shared/hasSeedableRequest.ts +25 -0
- package/src/lib/shared/hydrationWindow.ts +53 -0
- package/src/lib/shared/isAsyncCell.ts +11 -0
- package/src/lib/shared/isAsyncIterable.ts +8 -0
- package/src/lib/shared/isSubscribable.ts +3 -3
- package/src/lib/shared/isThenable.ts +9 -0
- package/src/lib/shared/jsonSchemaForType.ts +258 -0
- package/src/lib/shared/lenientDecode.ts +15 -0
- package/src/lib/shared/loadProjectTsConfig.ts +28 -0
- package/src/lib/shared/markFrameworkSourcesIgnored.ts +1 -1
- package/src/lib/shared/matchRoute.ts +4 -14
- package/src/lib/shared/parseEnv.ts +17 -6
- package/src/lib/shared/peek.ts +14 -0
- package/src/lib/shared/pending.ts +9 -6
- package/src/lib/shared/pendingAsyncCellsSlot.ts +13 -0
- package/src/lib/shared/prepareRpcModule.ts +91 -93
- package/src/lib/shared/prepareSocketModule.ts +3 -2
- package/src/lib/shared/probeRegistries.ts +5 -18
- package/src/lib/shared/reachable.ts +7 -10
- package/src/lib/shared/refresh.ts +12 -2
- package/src/lib/shared/refreshing.ts +8 -2
- package/src/lib/shared/resolvedCellsSlot.ts +13 -0
- package/src/lib/shared/reviveWireField.ts +49 -0
- package/src/lib/shared/reviveWireOutput.ts +36 -0
- package/src/lib/shared/rpcServerForRoot.ts +25 -0
- package/src/lib/shared/scanPages.ts +25 -0
- package/src/lib/shared/serializeEnv.ts +18 -6
- package/src/lib/shared/snapshotShippable.ts +8 -7
- package/src/lib/shared/snippet.ts +11 -6
- package/src/lib/shared/streamedCellsSlot.ts +14 -0
- package/src/lib/shared/subscribableFromResponse.ts +4 -4
- package/src/lib/shared/subscribableProbes.ts +1 -1
- package/src/lib/shared/tailProbeSlot.ts +1 -1
- package/src/lib/shared/types/AsyncComputed.ts +20 -0
- package/src/lib/shared/types/AsyncState.ts +13 -0
- package/src/lib/shared/types/CacheEntry.ts +7 -7
- package/src/lib/shared/types/CacheOptions.ts +23 -37
- package/src/lib/shared/types/CachePolicy.ts +25 -0
- package/src/lib/shared/types/CacheSnapshotEntry.ts +6 -5
- package/src/lib/shared/types/ErrorJsonSchemas.ts +8 -0
- package/src/lib/shared/types/HttpMethod.ts +3 -1
- package/src/lib/shared/types/InputCoercion.ts +17 -0
- package/src/lib/shared/types/{Subscribable.ts → NamedAsyncIterable.ts} +1 -1
- package/src/lib/shared/types/OutputWirePlan.ts +17 -0
- package/src/lib/shared/types/PagesScan.ts +7 -0
- package/src/lib/shared/types/PendingAsyncCells.ts +10 -0
- package/src/lib/shared/types/RawRemoteFunction.ts +6 -0
- package/src/lib/shared/types/RemoteCallable.ts +8 -7
- package/src/lib/shared/types/RemoteFunction.ts +16 -15
- package/src/lib/shared/types/ResolvedCells.ts +11 -0
- package/src/lib/shared/types/ReturnBody.ts +15 -0
- package/src/lib/shared/types/RpcBuildStamps.ts +23 -0
- package/src/lib/shared/types/RpcErrorGuard.ts +3 -8
- package/src/lib/shared/types/Socket.ts +4 -4
- package/src/lib/shared/types/SsrPayload.ts +5 -1
- package/src/lib/shared/types/StreamPolicy.ts +11 -0
- package/src/lib/shared/types/StreamedCells.ts +19 -0
- package/src/lib/shared/types/StreamedResolution.ts +24 -6
- package/src/lib/shared/types/TailHooks.ts +1 -1
- package/src/lib/shared/types/WireKind.ts +11 -0
- package/src/lib/shared/url.ts +5 -0
- package/src/lib/shared/validationHttpError.ts +33 -0
- package/src/lib/shared/warmSeedKey.ts +16 -0
- package/src/lib/shared/wireJsonReplacer.ts +30 -0
- package/src/lib/shared/writeRpcDts.ts +11 -1
- package/src/lib/shared/writeTestSocketsDts.ts +1 -1
- package/src/lib/test/createTestApp.ts +19 -1
- package/src/lib/ui/README.md +1 -1
- package/src/lib/ui/activePendingCells.ts +14 -0
- package/src/lib/ui/compile/BLOCK_KEYWORDS.ts +21 -0
- package/src/lib/ui/compile/SSR_ESCAPE.ts +4 -1
- package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +35 -7
- package/src/lib/ui/compile/abideUiPlugin.ts +19 -2
- package/src/lib/ui/compile/analyzeComponent.ts +89 -6
- package/src/lib/ui/compile/assignmentTargetNames.ts +54 -0
- package/src/lib/ui/compile/asyncInterpolationFields.ts +152 -0
- package/src/lib/ui/compile/asyncValuePositionError.ts +21 -0
- package/src/lib/ui/compile/asyncValuePositionInterpolations.ts +64 -0
- package/src/lib/ui/compile/attrLiftPosition.ts +18 -0
- package/src/lib/ui/compile/bindListenEvent.ts +5 -6
- package/src/lib/ui/compile/cachedSourceFile.ts +40 -0
- package/src/lib/ui/compile/catchBinding.ts +7 -5
- package/src/lib/ui/compile/classifyInterpolationType.ts +46 -0
- package/src/lib/ui/compile/collectAbideDiagnostics.ts +96 -0
- package/src/lib/ui/compile/compileComponent.ts +19 -3
- package/src/lib/ui/compile/compileModule.ts +27 -58
- package/src/lib/ui/compile/compileSSR.ts +52 -13
- package/src/lib/ui/compile/compileShadow.ts +265 -42
- package/src/lib/ui/compile/composeProps.ts +15 -4
- package/src/lib/ui/compile/createShadowLanguageService.ts +116 -68
- package/src/lib/ui/compile/createShadowProgram.ts +35 -6
- package/src/lib/ui/compile/declaredNames.ts +36 -0
- package/src/lib/ui/compile/desugarSignals.ts +419 -37
- package/src/lib/ui/compile/expressionIsPrefixEvaluable.ts +19 -0
- package/src/lib/ui/compile/generateBuild.ts +74 -17
- package/src/lib/ui/compile/generateSSR.ts +286 -75
- package/src/lib/ui/compile/hoistableAwaits.ts +193 -0
- package/src/lib/ui/compile/hoistableChildRenders.ts +112 -0
- package/src/lib/ui/compile/interpolatedTemplateLiteral.ts +3 -1
- package/src/lib/ui/compile/interpolationClassifierForRoot.ts +37 -0
- package/src/lib/ui/compile/isSpuriousAsyncReadDiagnostic.ts +174 -0
- package/src/lib/ui/compile/isWhitespaceText.ts +10 -2
- package/src/lib/ui/compile/liftAsyncSubExpressions.ts +166 -0
- package/src/lib/ui/compile/lowerAsyncInterpolations.ts +92 -0
- package/src/lib/ui/compile/lowerContext.ts +10 -0
- package/src/lib/ui/compile/lowerDocAccess.ts +51 -10
- package/src/lib/ui/compile/lowerScript.ts +40 -4
- package/src/lib/ui/compile/nodeAtShadowOffset.ts +28 -0
- package/src/lib/ui/compile/parseTemplate.ts +18 -1090
- package/src/lib/ui/compile/parseTemplateRecovering.ts +1385 -0
- package/src/lib/ui/compile/referencedIdentifiers.ts +35 -0
- package/src/lib/ui/compile/renameSignalRefs.ts +26 -40
- package/src/lib/ui/compile/resolveReactiveExport.ts +4 -7
- package/src/lib/ui/compile/scopeCss.ts +27 -4
- package/src/lib/ui/compile/seedTypeClassifierForRoot.ts +65 -0
- package/src/lib/ui/compile/shadowInterpolationClassifier.ts +47 -0
- package/src/lib/ui/compile/sourceFileOptionsSignature.ts +20 -0
- package/src/lib/ui/compile/structuralHeadTokens.ts +107 -0
- package/src/lib/ui/compile/templateSemanticTokens.ts +21 -0
- package/src/lib/ui/compile/templateStartOffset.ts +15 -0
- package/src/lib/ui/compile/tryPlan.ts +4 -3
- package/src/lib/ui/compile/types/AnalyzedComponent.ts +4 -0
- package/src/lib/ui/compile/types/AsyncInterpolationField.ts +19 -0
- package/src/lib/ui/compile/types/InterpolationClassifier.ts +12 -0
- package/src/lib/ui/compile/types/InterpolationKind.ts +7 -0
- package/src/lib/ui/compile/types/ParseDiagnostic.ts +8 -0
- package/src/lib/ui/compile/types/SeedTypeClassifier.ts +15 -0
- package/src/lib/ui/compile/types/TemplateNode.ts +36 -4
- package/src/lib/ui/compile/types/ValuePositionInterpolation.ts +13 -0
- package/src/lib/ui/compile/writtenTemplateNames.ts +84 -0
- package/src/lib/ui/computed.ts +28 -1
- package/src/lib/ui/createScope.ts +35 -68
- package/src/lib/ui/dom/anchoredBranch.ts +142 -0
- package/src/lib/ui/dom/appendText.ts +8 -3
- package/src/lib/ui/dom/awaitBlock.ts +62 -75
- package/src/lib/ui/dom/bindProp.ts +22 -0
- package/src/lib/ui/dom/bindableProp.ts +47 -0
- package/src/lib/ui/dom/cellPending.ts +24 -0
- package/src/lib/ui/dom/discardBoundary.ts +24 -6
- package/src/lib/ui/dom/disposeRange.ts +2 -1
- package/src/lib/ui/dom/each.ts +41 -12
- package/src/lib/ui/dom/eachAsync.ts +39 -3
- package/src/lib/ui/dom/fillBefore.ts +6 -7
- package/src/lib/ui/dom/fillBoundary.ts +2 -3
- package/src/lib/ui/dom/fillRange.ts +4 -4
- package/src/lib/ui/dom/hydrate.ts +6 -12
- package/src/lib/ui/dom/isComment.ts +1 -1
- package/src/lib/ui/dom/matchingRangeClose.ts +29 -0
- package/src/lib/ui/dom/mergeProps.ts +1 -1
- package/src/lib/ui/dom/mount.ts +1 -2
- package/src/lib/ui/dom/mountChild.ts +9 -40
- package/src/lib/ui/dom/mountRange.ts +2 -3
- package/src/lib/ui/dom/mountSlot.ts +1 -1
- package/src/lib/ui/dom/mountStreamedChild.ts +84 -0
- package/src/lib/ui/dom/mountSwappableRange.ts +46 -4
- package/src/lib/ui/dom/mutateDocContainer.ts +65 -0
- package/src/lib/ui/dom/on.ts +2 -2
- package/src/lib/ui/dom/readCell.ts +40 -0
- package/src/lib/ui/dom/restProps.ts +2 -2
- package/src/lib/ui/dom/spreadProps.ts +3 -4
- package/src/lib/ui/dom/switchBlock.ts +30 -7
- package/src/lib/ui/dom/tryBlock.ts +233 -70
- package/src/lib/ui/dom/types/SwitchCase.ts +5 -1
- package/src/lib/ui/dom/when.ts +12 -2
- package/src/lib/ui/dom/withScope.ts +9 -2
- package/src/lib/ui/finalizeStreamedChildren.ts +89 -0
- package/src/lib/ui/flight.ts +56 -0
- package/src/lib/ui/html.ts +12 -1
- package/src/lib/ui/isolateCellBarrier.ts +17 -0
- package/src/lib/ui/linked.ts +48 -2
- package/src/lib/ui/props.ts +17 -0
- package/src/lib/ui/remoteProxy.ts +84 -159
- package/src/lib/ui/renderChain.ts +53 -13
- package/src/lib/ui/renderToStream.ts +22 -18
- package/src/lib/ui/resumeSeedScript.ts +1 -1
- package/src/lib/ui/router.ts +86 -53
- package/src/lib/ui/runtime/AsyncCellError.ts +20 -0
- package/src/lib/ui/runtime/CELL_SEED.ts +14 -0
- package/src/lib/ui/runtime/CHILD_PRESENT.ts +2 -2
- package/src/lib/ui/runtime/CURRENT_BOUNDARY.ts +11 -0
- package/src/lib/ui/runtime/CURRENT_PATH.ts +29 -0
- package/src/lib/ui/runtime/RENDER.ts +10 -7
- package/src/lib/ui/runtime/RESUME.ts +4 -4
- package/src/lib/ui/runtime/STREAMED_CELLS.ts +57 -0
- package/src/lib/ui/runtime/ambientPathBacking.ts +32 -0
- package/src/lib/ui/runtime/applyPatchToTree.ts +17 -4
- package/src/lib/ui/runtime/blockId.ts +31 -0
- package/src/lib/ui/runtime/boundaryFor.ts +11 -0
- package/src/lib/ui/runtime/cellBarrierBacking.ts +30 -0
- package/src/lib/ui/runtime/createAsyncCell.ts +300 -0
- package/src/lib/ui/runtime/createDoc.ts +31 -54
- package/src/lib/ui/runtime/createEffectNode.ts +9 -0
- package/src/lib/ui/runtime/enterRenderPass.ts +5 -4
- package/src/lib/ui/runtime/flushEffects.ts +33 -1
- package/src/lib/ui/runtime/isAsyncFunction.ts +14 -0
- package/src/lib/ui/runtime/nextBlockId.ts +8 -7
- package/src/lib/ui/runtime/renderPath.ts +16 -0
- package/src/lib/ui/runtime/scope.ts +11 -0
- package/src/lib/ui/runtime/toTeardown.ts +10 -3
- package/src/lib/ui/runtime/types/Boundary.ts +9 -0
- package/src/lib/ui/runtime/types/RenderContext.ts +9 -7
- package/src/lib/ui/runtime/types/SsrRender.ts +9 -2
- package/src/lib/ui/runtime/types/UiComponent.ts +1 -5
- package/src/lib/ui/runtime/types/UiProps.ts +6 -5
- package/src/lib/ui/runtime/withOptionalPath.ts +8 -0
- package/src/lib/ui/runtime/withPath.ts +16 -0
- package/src/lib/ui/runtime/withPathFrom.ts +20 -0
- package/src/lib/ui/runtime/withoutHydration.ts +22 -0
- package/src/lib/ui/seedStreamedResolution.ts +31 -6
- package/src/lib/ui/settleAsyncCells.ts +24 -0
- package/src/lib/ui/socketProxy.ts +1 -1
- package/src/lib/ui/startClient.ts +16 -31
- package/src/lib/ui/state.ts +9 -3
- package/src/lib/ui/trackedComputed.ts +68 -0
- package/src/lib/ui/types/Scope.ts +8 -24
- package/src/lib/ui/watch.ts +3 -3
- package/src/serverEntry.ts +14 -0
- package/template/src/server/rpc/getHello.ts +15 -13
- package/template/test/app.test.ts +1 -1
- package/src/lib/server/runtime/devHotModuleResponse.ts +0 -41
- package/src/lib/shared/DEV_HOT_PREFIX.ts +0 -7
- package/src/lib/shared/UNREACHABLE_STATUSES.ts +0 -13
- package/src/lib/shared/hasReplayableRequest.ts +0 -17
- package/src/lib/shared/hydratingSlot.ts +0 -12
- package/src/lib/shared/outboxProbeSlot.ts +0 -20
- package/src/lib/shared/types/Outbox.ts +0 -9
- package/src/lib/shared/types/OutboxEntry.ts +0 -27
- package/src/lib/shared/types/SmartReadOptions.ts +0 -36
- package/src/lib/shared/wakeHydrationPeeks.ts +0 -20
- package/src/lib/ui/COMPONENT_WRAPPER_PREFIX.ts +0 -5
- package/src/lib/ui/compile/REACTIVE_CALLEES.ts +0 -11
- package/src/lib/ui/compile/assertRuntimeHelpersBound.ts +0 -80
- package/src/lib/ui/compile/markupTokens.ts +0 -313
- package/src/lib/ui/compile/structuralBlockTokens.ts +0 -100
- package/src/lib/ui/dom/applyResolved.ts +0 -87
- package/src/lib/ui/dom/scopeLabel.ts +0 -21
- package/src/lib/ui/dom/text.ts +0 -20
- package/src/lib/ui/history.ts +0 -101
- package/src/lib/ui/installHotBridge.ts +0 -93
- package/src/lib/ui/installInspectorBridge.ts +0 -140
- package/src/lib/ui/outbox.ts +0 -35
- package/src/lib/ui/persist.ts +0 -115
- package/src/lib/ui/rpcOutbox/createOutboxQueue.ts +0 -281
- package/src/lib/ui/rpcOutbox/outboxRegistry.ts +0 -69
- package/src/lib/ui/runtime/PATCH_BUS.ts +0 -28
- package/src/lib/ui/runtime/captureModelDoc.ts +0 -28
- package/src/lib/ui/runtime/hotInstances.ts +0 -10
- package/src/lib/ui/runtime/hotReloadEnabled.ts +0 -8
- package/src/lib/ui/runtime/hotReplace.ts +0 -38
- package/src/lib/ui/runtime/liveScopes.ts +0 -15
- package/src/lib/ui/runtime/localStoragePersistence.ts +0 -47
- package/src/lib/ui/runtime/registerHotInstance.ts +0 -23
- package/src/lib/ui/runtime/seedModelDoc.ts +0 -26
- package/src/lib/ui/runtime/types/HotInstance.ts +0 -22
- package/src/lib/ui/runtime/types/PatchEvent.ts +0 -16
- package/src/lib/ui/seedResolved.ts +0 -28
- package/src/lib/ui/sync.ts +0 -48
- package/src/lib/ui/types/History.ts +0 -14
- package/src/lib/ui/types/PersistHandle.ts +0 -11
- package/src/lib/ui/types/PersistenceStore.ts +0 -12
- package/src/lib/ui/types/ResolvedFrame.ts +0 -15
- package/src/lib/ui/types/SyncTransport.ts +0 -13
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { Server } from 'bun'
|
|
2
|
+
import type { McpServer } from '../../mcp/types/McpServer.ts'
|
|
3
|
+
import { NO_STORE } from '../../shared/CACHE_CONTROL_VALUES.ts'
|
|
4
|
+
import { CLI_PATH } from '../../shared/CLI_PATH.ts'
|
|
5
|
+
import { DEV_REBUILD_PATH } from '../../shared/DEV_REBUILD_PATH.ts'
|
|
6
|
+
import { DEV_RELOAD_PATH } from '../../shared/DEV_RELOAD_PATH.ts'
|
|
7
|
+
import { HEALTH_PATH } from '../../shared/HEALTH_PATH.ts'
|
|
8
|
+
import { IDENTITY_PATH } from '../../shared/IDENTITY_PATH.ts'
|
|
9
|
+
import { INSPECTOR_PATH } from '../../shared/INSPECTOR_PATH.ts'
|
|
10
|
+
import { lenientDecode } from '../../shared/lenientDecode.ts'
|
|
11
|
+
import { MCP_PATH } from '../../shared/MCP_PATH.ts'
|
|
12
|
+
import { SOCKETS_PATH } from '../../shared/SOCKETS_PATH.ts'
|
|
13
|
+
import { TEXT_PLAIN } from '../../shared/TEXT_PLAIN.ts'
|
|
14
|
+
import { handleCliDownload } from '../cli/handleCliDownload.ts'
|
|
15
|
+
import { handleCliInstall } from '../cli/handleCliInstall.ts'
|
|
16
|
+
import type { createSocketDispatcher } from '../sockets/createSocketDispatcher.ts'
|
|
17
|
+
import type { buildHealthPayload } from './buildHealthPayload.ts'
|
|
18
|
+
import { crossOriginGate } from './crossOriginGate.ts'
|
|
19
|
+
import { DEV_REBUILD_MESSAGE } from './DEV_REBUILD_MESSAGE.ts'
|
|
20
|
+
import { devReloadResponse } from './devReloadResponse.ts'
|
|
21
|
+
import { disableIdleTimeoutForStream } from './disableIdleTimeoutForStream.ts'
|
|
22
|
+
import { gzipResponse } from './gzipResponse.ts'
|
|
23
|
+
import { textResponse } from './textResponse.ts'
|
|
24
|
+
import type { DevReloadStamp } from './types/DevReloadStamp.ts'
|
|
25
|
+
import type { RequestStore } from './types/RequestStore.ts'
|
|
26
|
+
|
|
27
|
+
const SOCKETS_REST_PREFIX = `${SOCKETS_PATH}/`
|
|
28
|
+
const CLI_DOWNLOAD_PREFIX = `${CLI_PATH}/`
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
Returned by the router when a request matches none of its framework routes, so
|
|
32
|
+
the fetch handler falls through to the app's rpc/page/asset routes. A dedicated
|
|
33
|
+
sentinel — not `undefined` — because a successful socket upgrade legitimately
|
|
34
|
+
returns `undefined` (Bun's signal that it took the connection over), which must
|
|
35
|
+
stay distinct from "not a plumbing route".
|
|
36
|
+
*/
|
|
37
|
+
export const PLUMBING_PASS: unique symbol = Symbol('abide.plumbingPass')
|
|
38
|
+
|
|
39
|
+
/* Either the handled response (buffered, streamed, or `undefined` for a socket
|
|
40
|
+
upgrade handoff) or the pass sentinel. Returned synchronously so the common
|
|
41
|
+
app-route path pays no extra await/promise allocation — only a matched route
|
|
42
|
+
yields a promise. */
|
|
43
|
+
type PlumbingResult = Response | undefined | Promise<Response | undefined> | typeof PLUMBING_PASS
|
|
44
|
+
|
|
45
|
+
/* dispatchRequest, injected: runs a handler inside the per-request scope + app.handle middleware. */
|
|
46
|
+
type DispatchRequest = (
|
|
47
|
+
req: Request,
|
|
48
|
+
pathParams: Record<string, string>,
|
|
49
|
+
handler: (
|
|
50
|
+
req: Request,
|
|
51
|
+
pathParams: Record<string, string>,
|
|
52
|
+
store: RequestStore,
|
|
53
|
+
) => Promise<Response>,
|
|
54
|
+
url: URL,
|
|
55
|
+
) => Promise<Response>
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
The framework's own HTTP surface — health/identity probe, inspector, the dev
|
|
59
|
+
live-reload + rebuild channels, the sockets upgrade and its
|
|
60
|
+
SSE/JSON HTTP face, the MCP endpoint, and CLI install/download — resolved ahead
|
|
61
|
+
of the app's rpc/page routes. Extracted from createServer's fetch handler as a
|
|
62
|
+
sibling of createRouteDispatcher: the app-route half already sat behind a seam,
|
|
63
|
+
this is the framework-plumbing half, testable without a live socket. The probe
|
|
64
|
+
and dev/inspector channels answer directly (ahead of app.handle) so they land
|
|
65
|
+
even when the app guards everything behind auth; the sockets-REST/MCP/CLI faces
|
|
66
|
+
run through dispatchRequest so app.handle auth applies like the rpc paths.
|
|
67
|
+
Returns PLUMBING_PASS for any path it doesn't own, so the caller continues to
|
|
68
|
+
the app routes.
|
|
69
|
+
*/
|
|
70
|
+
export function createPlumbingRouter({
|
|
71
|
+
dev,
|
|
72
|
+
clientFingerprint,
|
|
73
|
+
inspectorHandler,
|
|
74
|
+
socketDispatcher,
|
|
75
|
+
mcp,
|
|
76
|
+
cliName,
|
|
77
|
+
cliCwd,
|
|
78
|
+
healthPayload,
|
|
79
|
+
dispatchRequest,
|
|
80
|
+
}: {
|
|
81
|
+
dev: boolean
|
|
82
|
+
clientFingerprint: DevReloadStamp | undefined
|
|
83
|
+
inspectorHandler: ((request: Request, url: URL) => Promise<Response>) | undefined
|
|
84
|
+
socketDispatcher: ReturnType<typeof createSocketDispatcher>
|
|
85
|
+
mcp: McpServer | undefined
|
|
86
|
+
cliName: string
|
|
87
|
+
cliCwd: string
|
|
88
|
+
healthPayload: (req: Request) => ReturnType<typeof buildHealthPayload>
|
|
89
|
+
dispatchRequest: DispatchRequest
|
|
90
|
+
}): (req: Request, url: URL, bunServer: Server<unknown>) => PlumbingResult {
|
|
91
|
+
/*
|
|
92
|
+
Health/identity probe — answered directly, ahead of any app.handle
|
|
93
|
+
middleware, so the bundle's connect screen, the CLI, and the client
|
|
94
|
+
health() can confirm a URL really is a live abide server even when the app
|
|
95
|
+
guards everything behind auth (reporting `authenticated: false` requires
|
|
96
|
+
exactly that). The app's optional health hook contributes fields; the
|
|
97
|
+
framework's identity keys win on collision, and a thrown hook is logged and
|
|
98
|
+
skipped so an app bug can't masquerade as an unreachable server.
|
|
99
|
+
IDENTITY_PATH is the compatibility alias for the same payload.
|
|
100
|
+
*/
|
|
101
|
+
async function healthProbe(req: Request, url: URL): Promise<Response> {
|
|
102
|
+
const payload = await healthPayload(req)
|
|
103
|
+
return gzipResponse(
|
|
104
|
+
req,
|
|
105
|
+
Response.json(
|
|
106
|
+
/*
|
|
107
|
+
The IDENTITY_PATH alias keeps the legacy `abide: true` shape:
|
|
108
|
+
already-shipped probers check it with strict equality, and a
|
|
109
|
+
version string would make them treat an upgraded healthy server
|
|
110
|
+
as not-abide.
|
|
111
|
+
*/
|
|
112
|
+
url.pathname === IDENTITY_PATH ? { ...payload, abide: true } : payload,
|
|
113
|
+
{ headers: { 'Cache-Control': NO_STORE } },
|
|
114
|
+
),
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return function routePlumbing(req, url, bunServer) {
|
|
119
|
+
if (url.pathname === HEALTH_PATH || url.pathname === IDENTITY_PATH) {
|
|
120
|
+
return healthProbe(req, url)
|
|
121
|
+
}
|
|
122
|
+
/*
|
|
123
|
+
Inspector surface — answered directly, ahead of app.handle, since it's
|
|
124
|
+
privileged operator tooling gated by ABIDE_ENABLE_INSPECTOR (not the
|
|
125
|
+
app's user auth). Undefined handler = flag off, so the whole block
|
|
126
|
+
compiles out of the hot path when the inspector's off.
|
|
127
|
+
*/
|
|
128
|
+
if (
|
|
129
|
+
inspectorHandler &&
|
|
130
|
+
(url.pathname === INSPECTOR_PATH || url.pathname.startsWith(`${INSPECTOR_PATH}/`))
|
|
131
|
+
) {
|
|
132
|
+
// The events feed is long-lived SSE: opt it out of the idle timeout,
|
|
133
|
+
// else Bun reaps it and the reconnect replays the whole buffer
|
|
134
|
+
// (duplicate boot logs every ~10s).
|
|
135
|
+
return inspectorHandler(req, url).then((response) =>
|
|
136
|
+
disableIdleTimeoutForStream(bunServer, req, response),
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
/*
|
|
140
|
+
Dev live-reload channel — answered directly, ahead of app.handle, so a
|
|
141
|
+
restart-driven reconnect always lands even when the app guards
|
|
142
|
+
everything behind auth. Only mounted under `abide dev`.
|
|
143
|
+
*/
|
|
144
|
+
if (clientFingerprint !== undefined && url.pathname === DEV_RELOAD_PATH) {
|
|
145
|
+
// Long-lived SSE: opt out of the idle timeout, else Bun reaps it and
|
|
146
|
+
// the reconnect triggers a spurious reload loop.
|
|
147
|
+
return disableIdleTimeoutForStream(bunServer, req, devReloadResponse(clientFingerprint))
|
|
148
|
+
}
|
|
149
|
+
/*
|
|
150
|
+
Manual rebuild trigger: signal the orchestrator parent over IPC to
|
|
151
|
+
rebuild + restart. Same-origin sibling of the live-reload channel, so a
|
|
152
|
+
script refreshes on the app's own port. process.send exists only when
|
|
153
|
+
the dev orchestrator spawned us with ipc; the optional chain no-ops on a
|
|
154
|
+
bare server.
|
|
155
|
+
*/
|
|
156
|
+
if (dev && req.method === 'POST' && url.pathname === DEV_REBUILD_PATH) {
|
|
157
|
+
process.send?.(DEV_REBUILD_MESSAGE)
|
|
158
|
+
return new Response('rebuilding\n', { headers: { 'Content-Type': TEXT_PLAIN } })
|
|
159
|
+
}
|
|
160
|
+
if (url.pathname === SOCKETS_PATH) {
|
|
161
|
+
// Reject cross-origin upgrades (CSWSH) before handing off to Bun.
|
|
162
|
+
const upgradeForbidden = crossOriginGate(req, url)
|
|
163
|
+
if (upgradeForbidden) {
|
|
164
|
+
return upgradeForbidden
|
|
165
|
+
}
|
|
166
|
+
if (bunServer.upgrade(req, { data: {} })) {
|
|
167
|
+
return undefined
|
|
168
|
+
}
|
|
169
|
+
return textResponse(400, 'Upgrade failed')
|
|
170
|
+
}
|
|
171
|
+
/*
|
|
172
|
+
HTTP face of a socket (`/__abide/sockets/<name>`) — tail over SSE / JSON
|
|
173
|
+
and publish — for the CLI and MCP. Runs through dispatchRequest so
|
|
174
|
+
app.handle auth applies, like the rpc paths. The socket name may contain
|
|
175
|
+
`/` (nested files), so it's the whole remaining pathname, percent-decoded.
|
|
176
|
+
*/
|
|
177
|
+
if (url.pathname.startsWith(SOCKETS_REST_PREFIX)) {
|
|
178
|
+
/*
|
|
179
|
+
Gate cross-origin browser publishes (CSRF, see crossOriginGate). GET
|
|
180
|
+
tail reads stay open cross-origin like rpc reads; only the mutating
|
|
181
|
+
POST is gated.
|
|
182
|
+
*/
|
|
183
|
+
const publishForbidden = crossOriginGate(req, url, { allowReadOnly: true })
|
|
184
|
+
if (publishForbidden) {
|
|
185
|
+
return publishForbidden
|
|
186
|
+
}
|
|
187
|
+
const name = lenientDecode(url.pathname.slice(SOCKETS_REST_PREFIX.length))
|
|
188
|
+
return dispatchRequest(req, {}, async () => socketDispatcher.rest(req, name), url)
|
|
189
|
+
}
|
|
190
|
+
if (url.pathname === MCP_PATH && mcp) {
|
|
191
|
+
// Gate cross-site browser posts (CSRF, see crossOriginGate).
|
|
192
|
+
const mcpForbidden = crossOriginGate(req, url)
|
|
193
|
+
if (mcpForbidden) {
|
|
194
|
+
return mcpForbidden
|
|
195
|
+
}
|
|
196
|
+
return dispatchRequest(req, {}, async () => mcp.handle(req), url)
|
|
197
|
+
}
|
|
198
|
+
if (url.pathname === CLI_PATH) {
|
|
199
|
+
return dispatchRequest(req, {}, async () => handleCliInstall(req, cliName), url)
|
|
200
|
+
}
|
|
201
|
+
if (url.pathname.startsWith(CLI_DOWNLOAD_PREFIX)) {
|
|
202
|
+
const platform = url.pathname.slice(CLI_DOWNLOAD_PREFIX.length)
|
|
203
|
+
return dispatchRequest(
|
|
204
|
+
req,
|
|
205
|
+
{},
|
|
206
|
+
async () => handleCliDownload(req, platform, cliName, cliCwd),
|
|
207
|
+
url,
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
return PLUMBING_PASS
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -2,12 +2,12 @@ import { NO_STORE } from '../../shared/CACHE_CONTROL_VALUES.ts'
|
|
|
2
2
|
import { memoizeByKey } from '../../shared/memoizeByKey.ts'
|
|
3
3
|
import { NAV_HEADER } from '../../shared/NAV_HEADER.ts'
|
|
4
4
|
import { REMOTE_FUNCTION } from '../../shared/REMOTE_FUNCTION.ts'
|
|
5
|
-
import { TEXT_PLAIN } from '../../shared/TEXT_PLAIN.ts'
|
|
6
5
|
import type { HttpMethod } from '../../shared/types/HttpMethod.ts'
|
|
7
6
|
import type { RemoteFunction } from '../../shared/types/RemoteFunction.ts'
|
|
8
7
|
import type { Pages } from '../../ui/types/Pages.ts'
|
|
9
8
|
import type { RemoteRoutes } from '../rpc/types/RemoteRoutes.ts'
|
|
10
9
|
import { crossOriginGate } from './crossOriginGate.ts'
|
|
10
|
+
import { textResponse } from './textResponse.ts'
|
|
11
11
|
import type { RequestStore } from './types/RequestStore.ts'
|
|
12
12
|
|
|
13
13
|
type AnyRemoteFunction = RemoteFunction<unknown, unknown>
|
|
@@ -26,12 +26,9 @@ type RenderPage = (
|
|
|
26
26
|
store: RequestStore,
|
|
27
27
|
) => Promise<Response>
|
|
28
28
|
|
|
29
|
-
/* The framework's 405 — `Allow` names the permitted rpc(s)
|
|
29
|
+
/* The framework's 405 — `Allow` names the permitted rpc(s); body/headers come from the shared textResponse so the rpc and page branches can't drift. */
|
|
30
30
|
function methodNotAllowed(allow: string): Response {
|
|
31
|
-
return
|
|
32
|
-
status: 405,
|
|
33
|
-
headers: { Allow: allow, 'Content-Type': TEXT_PLAIN, 'Cache-Control': NO_STORE },
|
|
34
|
-
})
|
|
31
|
+
return textResponse(405, undefined, { Allow: allow })
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
/*
|
|
@@ -118,10 +115,7 @@ export function createRouteDispatcher({
|
|
|
118
115
|
}
|
|
119
116
|
return renderPage(routeUrl, pathParams, store)
|
|
120
117
|
}
|
|
121
|
-
return
|
|
122
|
-
status: 404,
|
|
123
|
-
headers: { 'Content-Type': TEXT_PLAIN, 'Cache-Control': NO_STORE },
|
|
124
|
-
})
|
|
118
|
+
return textResponse(404)
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
121
|
}
|