@nice-code/action 0.16.0 → 0.18.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/README.md +637 -582
- package/build/{ActionDevtoolsCore-B3JwSaRH.d.cts → ActionDevtoolsCore-C5XrQI1K.d.mts} +2 -2
- package/build/{ActionDevtoolsCore-C4TDUY7-.d.mts → ActionDevtoolsCore-Dd1qJAwK.d.cts} +2 -2
- package/build/{ActionPayload.types-CO_hXlBc.d.cts → ActionPayload.types-BchJrBIX.d.mts} +468 -152
- package/build/{ActionPayload.types-fieMKAgt.d.mts → ActionPayload.types-snDlSIF-.d.cts} +468 -152
- package/build/devtools/browser/index.d.cts +1 -1
- package/build/devtools/browser/index.d.mts +1 -1
- package/build/devtools/server/index.d.cts +1 -1
- package/build/devtools/server/index.d.mts +1 -1
- package/build/index.cjs +224 -79
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +2 -2
- package/build/index.d.mts +2 -2
- package/build/index.mjs +219 -78
- package/build/index.mjs.map +1 -1
- package/build/platform/cloudflare/index.cjs +56 -0
- package/build/platform/cloudflare/index.cjs.map +1 -0
- package/build/platform/cloudflare/index.d.cts +67 -0
- package/build/platform/cloudflare/index.d.mts +67 -0
- package/build/platform/cloudflare/index.mjs +54 -0
- package/build/platform/cloudflare/index.mjs.map +1 -0
- package/build/react-query/index.d.cts +1 -1
- package/build/react-query/index.d.mts +1 -1
- package/build/wsAcceptorCarrier-CXGlQU_f.mjs +80 -0
- package/build/wsAcceptorCarrier-CXGlQU_f.mjs.map +1 -0
- package/build/wsAcceptorCarrier-DHRbsY1X.cjs +103 -0
- package/build/wsAcceptorCarrier-DHRbsY1X.cjs.map +1 -0
- package/package.json +15 -4
package/build/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AcceptorHandler, ActionCore, ActionDomain, ActionLocalHandler, type ActionPayload_Progress, type ActionPayload_Request, type ActionPayload_Result, ActionRootDomain, ActionRuntime, ActionSchema, ConnectionStateStore, ConnectorHandler, EActionPayloadType, EActionProgressType, EActionResponseMode, EErrId_NiceAction, EErrId_NiceTransport, EErrId_NiceTransport_WebSocket, EHandshakeMessageType, ERunningActionFinishedType, ERunningActionState, ERunningActionUpdateType, ESecurityLevel, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, type IAcceptChannelOptions, type IAcceptorConnectionBinding, type IAcceptorHandlerOptions, type IActionChannel, IActionCore, IActionCore_JsonObject, type IActionDomain, type IActionDomainChildOptions, type IActionFetchHandlerOptions, type IActionFrameCrypto, type IActionFrameCryptoConfig, type IActionFrameDecoder, IActionPayload_Base, IActionPayload_Base_JsonObject, IActionPayload_Data_Base, IActionPayload_Progress, IActionPayload_Progress_JsonObject, IActionPayload_Request_JsonObject, IActionPayload_Result, IActionPayload_Result_JsonObject, IActionProgress_Custom, IActionProgress_None, IActionProgress_Percentage, type IActionRootDomain, IActionRouteItemHandler, IActionTransportDef, IActionTransportInitialized, IActionTransportReady, IActionTransportReadyData_Base, type IActionTransportReadyData_Exchange, type IActionTransportReadyData_Link, IActionTransportReadyData_Methods, IActionTransportResolvers, type IActionWireFormat, type IBinaryWireSessionOptions, type IClientHandshakeConfig, type IClientVerifyKeyResolveInput, type IClientVerifyKeyResolver, type IConnectChannelOptions, type IConnectionAttachment, type IConnectionStateStoreOptions, type IDuplexCarrier, type IDuplexCarrierSource, type IExchangeAcceptorConfig, type IExchangeAcceptorSecurity, type IExchangeCarrier, type IExchangeCarrierSource, type IExchangeTransportOptions, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type
|
|
1
|
+
import { $ as EErrId_NiceTransport_WebSocket, $n as IClientVerifyKeyResolver, $r as TTransportedValue, $t as IAcceptorConnectionBinding, A as ILinkTransportOptions, An as ITransportStatusInfo_Ready, Ar as ActionPayload_Result, At as IDuplexCarrier, B as IActionFrameCryptoConfig, Bn as TSendActionDataMethod, Br as TActionDomainChildDef, Bt as IActionChannel, C as decodeActionFrame, Cn as ITransportMethod_SendActionData_Input, Cr as IRunningActionUpdate_Abort, Ct as IServeChannelOptions, D as secureTransport, Dn as ITransportStatusInfo_Base, Dr as TRunningActionUpdate, Dt as IExchangeAcceptorCarrier, E as ISecureTransportOptions, En as ITransportRouteInfo, Er as IRunningActionUpdate_Success, Et as IDuplexAcceptorCarrier, F as err_nice_transport, Fn as TOnResolveAnyIncomingActionData_Json, Fr as TRuntimeCoordinateEnvId, Ft as TFrame, G as TCarrierFetch, Gn as TTransportStatusInfo_GetTransport_Output, Gr as TPossibleDomainId, Gt as acceptChannelConnections, H as createBinaryWireAdapter, Hn as TTransportCache, Hr as TDomainActionId, Ht as TChannelAcceptorCases, I as ExchangeTransport, In as TOnResolveIncomingRequest, Ir as TRuntimeCoordinateStringId, It as IDuplexConnectionRouter, J as httpAcceptorCarrier, Jn as Transport, Jr as EActionResponseMode, Jt as ISecureChannel, K as httpCarrier, Kn as TUpdateActionRunConfig, Kr as TPossibleDomainIdList, Kt as connectChannel, L as IExchangeTransportOptions, Ln as TOnResolveIncomingRequestJson, Lr as IActionDomain, Lt as IHibernatableWsServerAdapterOptions, M as IActionTransportReadyData_Link, Mn as IUpdateActionRunConfig_Output, Mr as IRuntimeCoordinateSpecifics, Mt as IExchangeCarrier, N as TLinkFormatMessage, Nn as TGetTransportFn, Nr as IRuntimeFullCoordinates, Nt as IExchangeCarrierSource, O as IPlainTransportOptions, On as ITransportStatusInfo_Failed, Or as TRunningActionUpdateFinished, Ot as TAcceptorCarrier, P as EErrId_NiceTransport, Pn as TOnResolveAnyIncomingActionData, Pr as RuntimeCoordinate, Pt as TCarrier, Q as wsAcceptorCarrier, Qn as IClientVerifyKeyResolveInput, Qr as TActionSerializationDefinition, Qt as AcceptorHandler, R as IActionTransportReadyData_Exchange, Rn as TOnResolveIncomingResponse, Rr as IActionDomainChildOptions, Rt as createHibernatableWsServerAdapter, S as IActionFrameDecoder, Sn as ITransportDispatchAction, Sr as ERunningActionUpdateType, St as IChannelServer, T as err_nice_action, Tn as ITransportRouteClientParams, Tr as IRunningActionUpdate_Started, Tt as IAcceptorHibernation, U as IHttpCarrierOptions, Un as TTransportInitializationFinishedInfo, Ur as TInferInputFromSchema, Ut as TChannelPushHandlers, V as createActionFrameCrypto, Vn as TSendReturnDataMethod, Vr as TActionDomainSchema, Vt as IConnectChannelOptions, W as IHttpCarrierRequest, Wn as TTransportStatusInfo, Wr as TInferOutputFromSchema, Wt as acceptChannel, X as wsCarrier, Xn as ESecurityLevel, Xr as actionSchema, Xt as IBinaryWireSessionOptions, Y as IWsCarrierOptions, Yn as EHandshakeMessageType, Yr as TInferActionError, Yt as defineSecureChannel, Z as IWsAcceptorCarrierOptions, Zn as IClientHandshakeConfig, Zr as TActionSchemaOptions, Zt as createBinaryWireSessionFactory, _ as TActionProgress, _n as IActionTransportReady, _r as ActionPayload_Request, _t as IActionFetchHandlerOptions, a as IActionPayload_Data_Base, an as IActionWireFormat, ar as createInMemoryTofuVerifyKeyResolver, at as IInMemoryCarrier, b as isActionPayload_Request_JsonObject, bn as IActionTransportResolvers, br as ERunningActionFinishedType, bt as IExchangeAcceptorConfig, c as IActionPayload_Request_JsonObject, cn as ActionDomain, cr as decodeHandshakeMessage, ct as IInMemoryServerEndpoint, d as IActionProgress_Custom, dn as ConnectorHandler, dr as PeerLinkHandler, dt as ConnectionStateStore, en as IAcceptorHandlerOptions, er as IHandshakeEncryptionKeyMaterial, et as err_nice_transport_ws, f as IActionProgress_None, fn as createConnectorHandler, fr as ActionLocalHandler, ft as IConnectionAttachment, g as TActionPayload_Any_JsonObject, gn as IActionTransportInitialized, gr as ActionPayload_Progress, gt as createSecureAcceptorHandler, h as TActionPayload_Any_Instance, hn as IActionTransportDef, hr as RunningAction, ht as ISecureAcceptorHandlerOptions, i as IActionPayload_Base_JsonObject, in as createAcceptorHandler, ir as createClientHandshake, it as rtcDataChannelByteChannel, j as LinkTransport, jn as ITransportStatusInfo_Unsupported, jr as IRuntimeCoordinate, jt as IDuplexCarrierSource, k as plainTransport, kn as ITransportStatusInfo_Initializing, kr as TRunningActionUpdateListener, kt as isExchangeAcceptorCarrier, l as IActionPayload_Result, ln as ActionRootDomain, lr as encodeHandshakeMessage, lt as createInMemoryChannelPair, m as IActionRouteItemHandler, mn as ETransportStatus, mr as MaybePromise, mt as createConnectionStateStore, n as EActionProgressType, nn as TActionChannelFormatMessage, nr as IServerHandshakeConfig, nt as rtcCarrier, o as IActionPayload_Progress, on as createActionRootDomain, or as createServerHandshake, ot as inMemoryCarrier, p as IActionProgress_Percentage, pn as ETransportShape, pr as createLocalHandler, pt as IConnectionStateStoreOptions, q as IHttpAcceptorCarrierOptions, qn as ITransportConnectionContext, qr as ActionSchema, qt as defineChannel, r as IActionPayload_Base, rn as TActionConnectionEncoding, rr as THandshakeMessage, rt as IRtcDataChannelLike, s as IActionPayload_Progress_JsonObject, sn as ActionCore, sr as createStorageTofuVerifyKeyResolver, st as IInMemoryChannelPair, t as EActionPayloadType, tn as TAcceptorConnectionCaseFn, tr as IHandshakeResult, tt as IRtcCarrierOptions, u as IActionPayload_Result_JsonObject, un as ActionRuntime, ur as runtimeLinkId, ut as err_nice_external_client, v as TActionResultOutcome, vn as IActionTransportReadyData_Base, vr as IActionCore, vt as createActionFetchHandler, w as EErrId_NiceAction, wn as ITransportRouteActionParams, wr as IRunningActionUpdate_Progress, wt as serveChannel, x as isActionPayload_Any_JsonObject, xn as ISecureClientConfig, xr as ERunningActionState, xt as IExchangeAcceptorSecurity, y as isActionPayload_Result_JsonObject, yn as IActionTransportReadyData_Methods, yr as IActionCore_JsonObject, yt as ExchangeAcceptor, z as IActionFrameCrypto, zn as TOnResolveIncomingResponseJson, zr as IActionRootDomain, zt as IAcceptChannelOptions } from "./ActionPayload.types-snDlSIF-.cjs";
|
|
2
|
+
export { AcceptorHandler, ActionCore, ActionDomain, ActionLocalHandler, type ActionPayload_Progress, type ActionPayload_Request, type ActionPayload_Result, ActionRootDomain, ActionRuntime, ActionSchema, ConnectionStateStore, ConnectorHandler, EActionPayloadType, EActionProgressType, EActionResponseMode, EErrId_NiceAction, EErrId_NiceTransport, EErrId_NiceTransport_WebSocket, EHandshakeMessageType, ERunningActionFinishedType, ERunningActionState, ERunningActionUpdateType, ESecurityLevel, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, type IAcceptChannelOptions, type IAcceptorConnectionBinding, type IAcceptorHandlerOptions, type IAcceptorHibernation, type IActionChannel, IActionCore, IActionCore_JsonObject, type IActionDomain, type IActionDomainChildOptions, type IActionFetchHandlerOptions, type IActionFrameCrypto, type IActionFrameCryptoConfig, type IActionFrameDecoder, IActionPayload_Base, IActionPayload_Base_JsonObject, IActionPayload_Data_Base, IActionPayload_Progress, IActionPayload_Progress_JsonObject, IActionPayload_Request_JsonObject, IActionPayload_Result, IActionPayload_Result_JsonObject, IActionProgress_Custom, IActionProgress_None, IActionProgress_Percentage, type IActionRootDomain, IActionRouteItemHandler, IActionTransportDef, IActionTransportInitialized, IActionTransportReady, IActionTransportReadyData_Base, type IActionTransportReadyData_Exchange, type IActionTransportReadyData_Link, IActionTransportReadyData_Methods, IActionTransportResolvers, type IActionWireFormat, type IBinaryWireSessionOptions, type IChannelServer, type IClientHandshakeConfig, type IClientVerifyKeyResolveInput, type IClientVerifyKeyResolver, type IConnectChannelOptions, type IConnectionAttachment, type IConnectionStateStoreOptions, type IDuplexAcceptorCarrier, type IDuplexCarrier, type IDuplexCarrierSource, type IDuplexConnectionRouter, type IExchangeAcceptorCarrier, type IExchangeAcceptorConfig, type IExchangeAcceptorSecurity, type IExchangeCarrier, type IExchangeCarrierSource, type IExchangeTransportOptions, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type IHibernatableWsServerAdapterOptions, type IHttpAcceptorCarrierOptions, type IHttpCarrierOptions, type IHttpCarrierRequest, type IInMemoryCarrier, type IInMemoryChannelPair, type IInMemoryServerEndpoint, type ILinkTransportOptions, type IPlainTransportOptions, type IRtcCarrierOptions, type IRtcDataChannelLike, type IRunningActionUpdate_Abort, type IRunningActionUpdate_Progress, type IRunningActionUpdate_Started, type IRunningActionUpdate_Success, IRuntimeCoordinate, IRuntimeCoordinateSpecifics, IRuntimeFullCoordinates, type ISecureAcceptorHandlerOptions, type ISecureChannel, ISecureClientConfig, type ISecureTransportOptions, type IServeChannelOptions, type IServerHandshakeConfig, type ITransportConnectionContext, ITransportDispatchAction, ITransportMethod_SendActionData_Input, ITransportRouteActionParams, ITransportRouteClientParams, ITransportRouteInfo, ITransportStatusInfo_Base, ITransportStatusInfo_Failed, ITransportStatusInfo_Initializing, ITransportStatusInfo_Ready, ITransportStatusInfo_Unsupported, IUpdateActionRunConfig_Output, type IWsAcceptorCarrierOptions, type IWsCarrierOptions, LinkTransport, MaybePromise, PeerLinkHandler, RunningAction, RuntimeCoordinate, type TAcceptorCarrier, type TAcceptorConnectionCaseFn, type TActionChannelFormatMessage, type TActionConnectionEncoding, type TActionDomainChildDef, type TActionDomainSchema, TActionPayload_Any_Instance, TActionPayload_Any_JsonObject, TActionProgress, TActionResultOutcome, type TActionSchemaOptions, type TActionSerializationDefinition, type TCarrier, type TCarrierFetch, type TChannelAcceptorCases, type TChannelPushHandlers, type TDomainActionId, type TFrame, TGetTransportFn, type THandshakeMessage, type TInferActionError, type TInferInputFromSchema, type TInferOutputFromSchema, type TLinkFormatMessage, TOnResolveAnyIncomingActionData, TOnResolveAnyIncomingActionData_Json, TOnResolveIncomingRequest, TOnResolveIncomingRequestJson, TOnResolveIncomingResponse, TOnResolveIncomingResponseJson, type TPossibleDomainId, type TPossibleDomainIdList, type TRunningActionUpdate, type TRunningActionUpdateFinished, type TRunningActionUpdateListener, TRuntimeCoordinateEnvId, TRuntimeCoordinateStringId, TSendActionDataMethod, TSendReturnDataMethod, TTransportCache, TTransportInitializationFinishedInfo, TTransportStatusInfo, TTransportStatusInfo_GetTransport_Output, type TTransportedValue, TUpdateActionRunConfig, Transport, acceptChannel, acceptChannelConnections, actionSchema, connectChannel, createAcceptorHandler, createActionFetchHandler, createActionFrameCrypto, createActionRootDomain, createBinaryWireAdapter, createBinaryWireSessionFactory, createClientHandshake, createConnectionStateStore, createConnectorHandler, createHibernatableWsServerAdapter, createInMemoryChannelPair, createInMemoryTofuVerifyKeyResolver, createLocalHandler, createSecureAcceptorHandler, createServerHandshake, createStorageTofuVerifyKeyResolver, decodeActionFrame, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeHandshakeMessage, err_nice_action, err_nice_external_client, err_nice_transport, err_nice_transport_ws, httpAcceptorCarrier, httpCarrier, inMemoryCarrier, isActionPayload_Any_JsonObject, isActionPayload_Request_JsonObject, isActionPayload_Result_JsonObject, isExchangeAcceptorCarrier, plainTransport, rtcCarrier, rtcDataChannelByteChannel, runtimeLinkId, secureTransport, serveChannel, wsAcceptorCarrier, wsCarrier };
|
package/build/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AcceptorHandler, ActionCore, ActionDomain, ActionLocalHandler, type ActionPayload_Progress, type ActionPayload_Request, type ActionPayload_Result, ActionRootDomain, ActionRuntime, ActionSchema, ConnectionStateStore, ConnectorHandler, EActionPayloadType, EActionProgressType, EActionResponseMode, EErrId_NiceAction, EErrId_NiceTransport, EErrId_NiceTransport_WebSocket, EHandshakeMessageType, ERunningActionFinishedType, ERunningActionState, ERunningActionUpdateType, ESecurityLevel, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, type IAcceptChannelOptions, type IAcceptorConnectionBinding, type IAcceptorHandlerOptions, type IActionChannel, IActionCore, IActionCore_JsonObject, type IActionDomain, type IActionDomainChildOptions, type IActionFetchHandlerOptions, type IActionFrameCrypto, type IActionFrameCryptoConfig, type IActionFrameDecoder, IActionPayload_Base, IActionPayload_Base_JsonObject, IActionPayload_Data_Base, IActionPayload_Progress, IActionPayload_Progress_JsonObject, IActionPayload_Request_JsonObject, IActionPayload_Result, IActionPayload_Result_JsonObject, IActionProgress_Custom, IActionProgress_None, IActionProgress_Percentage, type IActionRootDomain, IActionRouteItemHandler, IActionTransportDef, IActionTransportInitialized, IActionTransportReady, IActionTransportReadyData_Base, type IActionTransportReadyData_Exchange, type IActionTransportReadyData_Link, IActionTransportReadyData_Methods, IActionTransportResolvers, type IActionWireFormat, type IBinaryWireSessionOptions, type IClientHandshakeConfig, type IClientVerifyKeyResolveInput, type IClientVerifyKeyResolver, type IConnectChannelOptions, type IConnectionAttachment, type IConnectionStateStoreOptions, type IDuplexCarrier, type IDuplexCarrierSource, type IExchangeAcceptorConfig, type IExchangeAcceptorSecurity, type IExchangeCarrier, type IExchangeCarrierSource, type IExchangeTransportOptions, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type
|
|
1
|
+
import { $ as EErrId_NiceTransport_WebSocket, $n as IClientVerifyKeyResolver, $r as TTransportedValue, $t as IAcceptorConnectionBinding, A as ILinkTransportOptions, An as ITransportStatusInfo_Ready, Ar as ActionPayload_Result, At as IDuplexCarrier, B as IActionFrameCryptoConfig, Bn as TSendActionDataMethod, Br as TActionDomainChildDef, Bt as IActionChannel, C as decodeActionFrame, Cn as ITransportMethod_SendActionData_Input, Cr as IRunningActionUpdate_Abort, Ct as IServeChannelOptions, D as secureTransport, Dn as ITransportStatusInfo_Base, Dr as TRunningActionUpdate, Dt as IExchangeAcceptorCarrier, E as ISecureTransportOptions, En as ITransportRouteInfo, Er as IRunningActionUpdate_Success, Et as IDuplexAcceptorCarrier, F as err_nice_transport, Fn as TOnResolveAnyIncomingActionData_Json, Fr as TRuntimeCoordinateEnvId, Ft as TFrame, G as TCarrierFetch, Gn as TTransportStatusInfo_GetTransport_Output, Gr as TPossibleDomainId, Gt as acceptChannelConnections, H as createBinaryWireAdapter, Hn as TTransportCache, Hr as TDomainActionId, Ht as TChannelAcceptorCases, I as ExchangeTransport, In as TOnResolveIncomingRequest, Ir as TRuntimeCoordinateStringId, It as IDuplexConnectionRouter, J as httpAcceptorCarrier, Jn as Transport, Jr as EActionResponseMode, Jt as ISecureChannel, K as httpCarrier, Kn as TUpdateActionRunConfig, Kr as TPossibleDomainIdList, Kt as connectChannel, L as IExchangeTransportOptions, Ln as TOnResolveIncomingRequestJson, Lr as IActionDomain, Lt as IHibernatableWsServerAdapterOptions, M as IActionTransportReadyData_Link, Mn as IUpdateActionRunConfig_Output, Mr as IRuntimeCoordinateSpecifics, Mt as IExchangeCarrier, N as TLinkFormatMessage, Nn as TGetTransportFn, Nr as IRuntimeFullCoordinates, Nt as IExchangeCarrierSource, O as IPlainTransportOptions, On as ITransportStatusInfo_Failed, Or as TRunningActionUpdateFinished, Ot as TAcceptorCarrier, P as EErrId_NiceTransport, Pn as TOnResolveAnyIncomingActionData, Pr as RuntimeCoordinate, Pt as TCarrier, Q as wsAcceptorCarrier, Qn as IClientVerifyKeyResolveInput, Qr as TActionSerializationDefinition, Qt as AcceptorHandler, R as IActionTransportReadyData_Exchange, Rn as TOnResolveIncomingResponse, Rr as IActionDomainChildOptions, Rt as createHibernatableWsServerAdapter, S as IActionFrameDecoder, Sn as ITransportDispatchAction, Sr as ERunningActionUpdateType, St as IChannelServer, T as err_nice_action, Tn as ITransportRouteClientParams, Tr as IRunningActionUpdate_Started, Tt as IAcceptorHibernation, U as IHttpCarrierOptions, Un as TTransportInitializationFinishedInfo, Ur as TInferInputFromSchema, Ut as TChannelPushHandlers, V as createActionFrameCrypto, Vn as TSendReturnDataMethod, Vr as TActionDomainSchema, Vt as IConnectChannelOptions, W as IHttpCarrierRequest, Wn as TTransportStatusInfo, Wr as TInferOutputFromSchema, Wt as acceptChannel, X as wsCarrier, Xn as ESecurityLevel, Xr as actionSchema, Xt as IBinaryWireSessionOptions, Y as IWsCarrierOptions, Yn as EHandshakeMessageType, Yr as TInferActionError, Yt as defineSecureChannel, Z as IWsAcceptorCarrierOptions, Zn as IClientHandshakeConfig, Zr as TActionSchemaOptions, Zt as createBinaryWireSessionFactory, _ as TActionProgress, _n as IActionTransportReady, _r as ActionPayload_Request, _t as IActionFetchHandlerOptions, a as IActionPayload_Data_Base, an as IActionWireFormat, ar as createInMemoryTofuVerifyKeyResolver, at as IInMemoryCarrier, b as isActionPayload_Request_JsonObject, bn as IActionTransportResolvers, br as ERunningActionFinishedType, bt as IExchangeAcceptorConfig, c as IActionPayload_Request_JsonObject, cn as ActionDomain, cr as decodeHandshakeMessage, ct as IInMemoryServerEndpoint, d as IActionProgress_Custom, dn as ConnectorHandler, dr as PeerLinkHandler, dt as ConnectionStateStore, en as IAcceptorHandlerOptions, er as IHandshakeEncryptionKeyMaterial, et as err_nice_transport_ws, f as IActionProgress_None, fn as createConnectorHandler, fr as ActionLocalHandler, ft as IConnectionAttachment, g as TActionPayload_Any_JsonObject, gn as IActionTransportInitialized, gr as ActionPayload_Progress, gt as createSecureAcceptorHandler, h as TActionPayload_Any_Instance, hn as IActionTransportDef, hr as RunningAction, ht as ISecureAcceptorHandlerOptions, i as IActionPayload_Base_JsonObject, in as createAcceptorHandler, ir as createClientHandshake, it as rtcDataChannelByteChannel, j as LinkTransport, jn as ITransportStatusInfo_Unsupported, jr as IRuntimeCoordinate, jt as IDuplexCarrierSource, k as plainTransport, kn as ITransportStatusInfo_Initializing, kr as TRunningActionUpdateListener, kt as isExchangeAcceptorCarrier, l as IActionPayload_Result, ln as ActionRootDomain, lr as encodeHandshakeMessage, lt as createInMemoryChannelPair, m as IActionRouteItemHandler, mn as ETransportStatus, mr as MaybePromise, mt as createConnectionStateStore, n as EActionProgressType, nn as TActionChannelFormatMessage, nr as IServerHandshakeConfig, nt as rtcCarrier, o as IActionPayload_Progress, on as createActionRootDomain, or as createServerHandshake, ot as inMemoryCarrier, p as IActionProgress_Percentage, pn as ETransportShape, pr as createLocalHandler, pt as IConnectionStateStoreOptions, q as IHttpAcceptorCarrierOptions, qn as ITransportConnectionContext, qr as ActionSchema, qt as defineChannel, r as IActionPayload_Base, rn as TActionConnectionEncoding, rr as THandshakeMessage, rt as IRtcDataChannelLike, s as IActionPayload_Progress_JsonObject, sn as ActionCore, sr as createStorageTofuVerifyKeyResolver, st as IInMemoryChannelPair, t as EActionPayloadType, tn as TAcceptorConnectionCaseFn, tr as IHandshakeResult, tt as IRtcCarrierOptions, u as IActionPayload_Result_JsonObject, un as ActionRuntime, ur as runtimeLinkId, ut as err_nice_external_client, v as TActionResultOutcome, vn as IActionTransportReadyData_Base, vr as IActionCore, vt as createActionFetchHandler, w as EErrId_NiceAction, wn as ITransportRouteActionParams, wr as IRunningActionUpdate_Progress, wt as serveChannel, x as isActionPayload_Any_JsonObject, xn as ISecureClientConfig, xr as ERunningActionState, xt as IExchangeAcceptorSecurity, y as isActionPayload_Result_JsonObject, yn as IActionTransportReadyData_Methods, yr as IActionCore_JsonObject, yt as ExchangeAcceptor, z as IActionFrameCrypto, zn as TOnResolveIncomingResponseJson, zr as IActionRootDomain, zt as IAcceptChannelOptions } from "./ActionPayload.types-BchJrBIX.mjs";
|
|
2
|
+
export { AcceptorHandler, ActionCore, ActionDomain, ActionLocalHandler, type ActionPayload_Progress, type ActionPayload_Request, type ActionPayload_Result, ActionRootDomain, ActionRuntime, ActionSchema, ConnectionStateStore, ConnectorHandler, EActionPayloadType, EActionProgressType, EActionResponseMode, EErrId_NiceAction, EErrId_NiceTransport, EErrId_NiceTransport_WebSocket, EHandshakeMessageType, ERunningActionFinishedType, ERunningActionState, ERunningActionUpdateType, ESecurityLevel, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, type IAcceptChannelOptions, type IAcceptorConnectionBinding, type IAcceptorHandlerOptions, type IAcceptorHibernation, type IActionChannel, IActionCore, IActionCore_JsonObject, type IActionDomain, type IActionDomainChildOptions, type IActionFetchHandlerOptions, type IActionFrameCrypto, type IActionFrameCryptoConfig, type IActionFrameDecoder, IActionPayload_Base, IActionPayload_Base_JsonObject, IActionPayload_Data_Base, IActionPayload_Progress, IActionPayload_Progress_JsonObject, IActionPayload_Request_JsonObject, IActionPayload_Result, IActionPayload_Result_JsonObject, IActionProgress_Custom, IActionProgress_None, IActionProgress_Percentage, type IActionRootDomain, IActionRouteItemHandler, IActionTransportDef, IActionTransportInitialized, IActionTransportReady, IActionTransportReadyData_Base, type IActionTransportReadyData_Exchange, type IActionTransportReadyData_Link, IActionTransportReadyData_Methods, IActionTransportResolvers, type IActionWireFormat, type IBinaryWireSessionOptions, type IChannelServer, type IClientHandshakeConfig, type IClientVerifyKeyResolveInput, type IClientVerifyKeyResolver, type IConnectChannelOptions, type IConnectionAttachment, type IConnectionStateStoreOptions, type IDuplexAcceptorCarrier, type IDuplexCarrier, type IDuplexCarrierSource, type IDuplexConnectionRouter, type IExchangeAcceptorCarrier, type IExchangeAcceptorConfig, type IExchangeAcceptorSecurity, type IExchangeCarrier, type IExchangeCarrierSource, type IExchangeTransportOptions, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type IHibernatableWsServerAdapterOptions, type IHttpAcceptorCarrierOptions, type IHttpCarrierOptions, type IHttpCarrierRequest, type IInMemoryCarrier, type IInMemoryChannelPair, type IInMemoryServerEndpoint, type ILinkTransportOptions, type IPlainTransportOptions, type IRtcCarrierOptions, type IRtcDataChannelLike, type IRunningActionUpdate_Abort, type IRunningActionUpdate_Progress, type IRunningActionUpdate_Started, type IRunningActionUpdate_Success, IRuntimeCoordinate, IRuntimeCoordinateSpecifics, IRuntimeFullCoordinates, type ISecureAcceptorHandlerOptions, type ISecureChannel, ISecureClientConfig, type ISecureTransportOptions, type IServeChannelOptions, type IServerHandshakeConfig, type ITransportConnectionContext, ITransportDispatchAction, ITransportMethod_SendActionData_Input, ITransportRouteActionParams, ITransportRouteClientParams, ITransportRouteInfo, ITransportStatusInfo_Base, ITransportStatusInfo_Failed, ITransportStatusInfo_Initializing, ITransportStatusInfo_Ready, ITransportStatusInfo_Unsupported, IUpdateActionRunConfig_Output, type IWsAcceptorCarrierOptions, type IWsCarrierOptions, LinkTransport, MaybePromise, PeerLinkHandler, RunningAction, RuntimeCoordinate, type TAcceptorCarrier, type TAcceptorConnectionCaseFn, type TActionChannelFormatMessage, type TActionConnectionEncoding, type TActionDomainChildDef, type TActionDomainSchema, TActionPayload_Any_Instance, TActionPayload_Any_JsonObject, TActionProgress, TActionResultOutcome, type TActionSchemaOptions, type TActionSerializationDefinition, type TCarrier, type TCarrierFetch, type TChannelAcceptorCases, type TChannelPushHandlers, type TDomainActionId, type TFrame, TGetTransportFn, type THandshakeMessage, type TInferActionError, type TInferInputFromSchema, type TInferOutputFromSchema, type TLinkFormatMessage, TOnResolveAnyIncomingActionData, TOnResolveAnyIncomingActionData_Json, TOnResolveIncomingRequest, TOnResolveIncomingRequestJson, TOnResolveIncomingResponse, TOnResolveIncomingResponseJson, type TPossibleDomainId, type TPossibleDomainIdList, type TRunningActionUpdate, type TRunningActionUpdateFinished, type TRunningActionUpdateListener, TRuntimeCoordinateEnvId, TRuntimeCoordinateStringId, TSendActionDataMethod, TSendReturnDataMethod, TTransportCache, TTransportInitializationFinishedInfo, TTransportStatusInfo, TTransportStatusInfo_GetTransport_Output, type TTransportedValue, TUpdateActionRunConfig, Transport, acceptChannel, acceptChannelConnections, actionSchema, connectChannel, createAcceptorHandler, createActionFetchHandler, createActionFrameCrypto, createActionRootDomain, createBinaryWireAdapter, createBinaryWireSessionFactory, createClientHandshake, createConnectionStateStore, createConnectorHandler, createHibernatableWsServerAdapter, createInMemoryChannelPair, createInMemoryTofuVerifyKeyResolver, createLocalHandler, createSecureAcceptorHandler, createServerHandshake, createStorageTofuVerifyKeyResolver, decodeActionFrame, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeHandshakeMessage, err_nice_action, err_nice_external_client, err_nice_transport, err_nice_transport_ws, httpAcceptorCarrier, httpCarrier, inMemoryCarrier, isActionPayload_Any_JsonObject, isActionPayload_Request_JsonObject, isActionPayload_Result_JsonObject, isExchangeAcceptorCarrier, plainTransport, rtcCarrier, rtcDataChannelByteChannel, runtimeLinkId, secureTransport, serveChannel, wsAcceptorCarrier, wsCarrier };
|
package/build/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as ERunningActionState, r as ERunningActionUpdateType, t as ERunningActionFinishedType } from "./RunningAction.types-C176rqHG.mjs";
|
|
2
|
+
import { i as ETransportStatus, n as isExchangeAcceptorCarrier, r as ETransportShape, t as wsAcceptorCarrier } from "./wsAcceptorCarrier-CXGlQU_f.mjs";
|
|
2
3
|
import { nanoid } from "nanoid";
|
|
3
4
|
import { NiceError, castNiceError, err, err_nice, isNiceErrorObject } from "@nice-code/error";
|
|
4
5
|
import { extractMessageFromStandardSchema } from "@nice-code/common-errors";
|
|
@@ -851,32 +852,6 @@ const err_nice_transport = err_nice_external_client.createChildDomain({
|
|
|
851
852
|
}
|
|
852
853
|
});
|
|
853
854
|
//#endregion
|
|
854
|
-
//#region src/ActionRuntime/Transport/Transport.types.ts
|
|
855
|
-
/**
|
|
856
|
-
* Carrier-shape class identity: the one carrier-invariant trait the selection layer reasons about —
|
|
857
|
-
* whether a carrier can push unsolicited frames (`duplex`: WS/WebRTC/BLE/in-memory) or only answers a
|
|
858
|
-
* request with a single correlated reply (`exchange`: HTTP). The concrete carrier kind ("ws", "webrtc",
|
|
859
|
-
* "http", …) is a free-form {@link ITransportRouteInfo.carrierLabel} for display, not a class tag.
|
|
860
|
-
*/
|
|
861
|
-
let ETransportShape = /* @__PURE__ */ function(ETransportShape) {
|
|
862
|
-
ETransportShape["duplex"] = "duplex";
|
|
863
|
-
ETransportShape["exchange"] = "exchange";
|
|
864
|
-
return ETransportShape;
|
|
865
|
-
}({});
|
|
866
|
-
/**
|
|
867
|
-
*
|
|
868
|
-
* TRANSPORT READINESS RESPONSE
|
|
869
|
-
*
|
|
870
|
-
*/
|
|
871
|
-
let ETransportStatus = /* @__PURE__ */ function(ETransportStatus) {
|
|
872
|
-
ETransportStatus["uninitialized"] = "uninitialized";
|
|
873
|
-
ETransportStatus["unsupported"] = "unsupported";
|
|
874
|
-
ETransportStatus["initializing"] = "initializing";
|
|
875
|
-
ETransportStatus["ready"] = "ready";
|
|
876
|
-
ETransportStatus["failed"] = "failed";
|
|
877
|
-
return ETransportStatus;
|
|
878
|
-
}({});
|
|
879
|
-
//#endregion
|
|
880
855
|
//#region src/ActionRuntime/Transport/ConnectionTransportManager.ts
|
|
881
856
|
var ConnectionTransportManager = class {
|
|
882
857
|
_cache;
|
|
@@ -1196,6 +1171,16 @@ var PeerLinkHandler = class extends ActionHandler {
|
|
|
1196
1171
|
_emitIncoming(json) {
|
|
1197
1172
|
for (const listener of this._incomingActionDataListeners) listener(json);
|
|
1198
1173
|
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Whether this handler currently holds a *live* connection bound to `origin`. The runtime's return-path
|
|
1176
|
+
* dispatch ({@link ActionRuntime.getReturnHandlerForOrigin}) prefers a handler that owns the origin's
|
|
1177
|
+
* connection over a mere coordinate match, so with several duplex acceptors a result/push routes back
|
|
1178
|
+
* over the carrier the client connected on. Defaults to `false`; an acceptor overrides it from its
|
|
1179
|
+
* connection registry.
|
|
1180
|
+
*/
|
|
1181
|
+
ownsLiveConnectionFor(_origin) {
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1199
1184
|
/** Release any long-lived connections this handler owns (a teardown). No-op by default. */
|
|
1200
1185
|
clearTransportCache() {}
|
|
1201
1186
|
};
|
|
@@ -1506,11 +1491,19 @@ var ActionRuntime = class {
|
|
|
1506
1491
|
* Find the best registered external handler that can reach `originClient` directly.
|
|
1507
1492
|
* Used to locate the return-path channel for dispatching results back to the action origin.
|
|
1508
1493
|
* Returns `undefined` if no handler matches (score > 0 required, i.e. at least id must match).
|
|
1494
|
+
*
|
|
1495
|
+
* A handler that currently holds the origin's *live* connection always wins over a mere coordinate
|
|
1496
|
+
* match — so with several duplex acceptors (e.g. WS + WebRTC) a result/push routes back over the carrier
|
|
1497
|
+
* the client actually connected on, never a same-coordinate sibling that lacks the socket. Only when no
|
|
1498
|
+
* handler owns a live connection do we fall back to the plain best-coordinate-score pick (the
|
|
1499
|
+
* single-acceptor and connector-only cases, unchanged).
|
|
1509
1500
|
*/
|
|
1510
1501
|
getReturnHandlerForOrigin(originClient) {
|
|
1511
1502
|
if (originClient.envId === "_unset_") return void 0;
|
|
1512
1503
|
let bestScore = -1;
|
|
1513
1504
|
let bestHandler;
|
|
1505
|
+
let bestOwnedScore = -1;
|
|
1506
|
+
let bestOwnedHandler;
|
|
1514
1507
|
for (const handler of this._registeredPeerHandlers) {
|
|
1515
1508
|
if (!handler.canPush) continue;
|
|
1516
1509
|
const score = originClient.similarityLevel(handler.peerClient);
|
|
@@ -1518,7 +1511,12 @@ var ActionRuntime = class {
|
|
|
1518
1511
|
bestScore = score;
|
|
1519
1512
|
bestHandler = handler;
|
|
1520
1513
|
}
|
|
1514
|
+
if (score > bestOwnedScore && handler.ownsLiveConnectionFor(originClient)) {
|
|
1515
|
+
bestOwnedScore = score;
|
|
1516
|
+
bestOwnedHandler = handler;
|
|
1517
|
+
}
|
|
1521
1518
|
}
|
|
1519
|
+
if (bestOwnedHandler != null && bestOwnedScore > 0) return bestOwnedHandler;
|
|
1522
1520
|
return bestScore > 0 ? bestHandler : void 0;
|
|
1523
1521
|
}
|
|
1524
1522
|
resetRuntime() {
|
|
@@ -2778,6 +2776,14 @@ var AcceptorHandler = class extends PeerLinkHandler {
|
|
|
2778
2776
|
getConnectionForClient(client) {
|
|
2779
2777
|
return this._connByClient.get(client.stringId);
|
|
2780
2778
|
}
|
|
2779
|
+
/** This acceptor owns the origin's return path when it currently holds a live connection bound to it. */
|
|
2780
|
+
ownsLiveConnectionFor(origin) {
|
|
2781
|
+
return this._connByClient.has(origin.stringId);
|
|
2782
|
+
}
|
|
2783
|
+
/** Whether this acceptor currently tracks `connection` — used to pick the owning handler among several. */
|
|
2784
|
+
hasConnection(connection) {
|
|
2785
|
+
return this._clientByConn.has(connection);
|
|
2786
|
+
}
|
|
2781
2787
|
/**
|
|
2782
2788
|
* Send (and optionally await) a server-initiated action to a specific connected client. Pass the
|
|
2783
2789
|
* connection token directly (e.g. the `ws`) or a client `RuntimeCoordinate` to look one up.
|
|
@@ -2925,7 +2931,7 @@ const createAcceptorHandler = (options) => {
|
|
|
2925
2931
|
//#endregion
|
|
2926
2932
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/createSecureActionServer.ts
|
|
2927
2933
|
/** Default accepted set: negotiate per connection to whatever the client picks. */
|
|
2928
|
-
const DEFAULT_SERVER_SECURITY_LEVELS = [
|
|
2934
|
+
const DEFAULT_SERVER_SECURITY_LEVELS$1 = [
|
|
2929
2935
|
"none",
|
|
2930
2936
|
"authenticated",
|
|
2931
2937
|
"encrypted"
|
|
@@ -2940,7 +2946,7 @@ const DEFAULT_SERVER_SECURITY_LEVELS = [
|
|
|
2940
2946
|
* {@link createHibernatableWsServerAdapter} to wire persistence + replay.
|
|
2941
2947
|
*/
|
|
2942
2948
|
function createSecureAcceptorHandler(options) {
|
|
2943
|
-
const link = new ClientCryptoKeyLink({ storageAdapter: options.storageAdapter });
|
|
2949
|
+
const link = options.link ?? new ClientCryptoKeyLink({ storageAdapter: options.storageAdapter });
|
|
2944
2950
|
return new AcceptorHandler({
|
|
2945
2951
|
clientEnv: options.clientEnv,
|
|
2946
2952
|
createFormatMessage: options.channel.createCodec,
|
|
@@ -2948,7 +2954,7 @@ function createSecureAcceptorHandler(options) {
|
|
|
2948
2954
|
runtime: options.runtime,
|
|
2949
2955
|
defaultTimeout: options.defaultTimeout,
|
|
2950
2956
|
security: {
|
|
2951
|
-
securityLevel: options.securityLevel ?? DEFAULT_SERVER_SECURITY_LEVELS,
|
|
2957
|
+
securityLevel: options.securityLevel ?? DEFAULT_SERVER_SECURITY_LEVELS$1,
|
|
2952
2958
|
link,
|
|
2953
2959
|
localCoordinate: options.runtime.coordinate.toJsonObject(),
|
|
2954
2960
|
dictionaryVersion: options.channel.dictionaryVersion,
|
|
@@ -3020,6 +3026,7 @@ function acceptChannel(runtime, channel, options) {
|
|
|
3020
3026
|
runtime,
|
|
3021
3027
|
clientEnv: options.clientEnv,
|
|
3022
3028
|
storageAdapter: options.storageAdapter,
|
|
3029
|
+
link: options.link,
|
|
3023
3030
|
send: options.send,
|
|
3024
3031
|
securityLevel: options.securityLevel,
|
|
3025
3032
|
verifyKeyResolver: options.verifyKeyResolver,
|
|
@@ -3508,7 +3515,8 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
3508
3515
|
return async (request) => {
|
|
3509
3516
|
if (request.method === "OPTIONS") return withCors(new Response(null, { status: 204 }));
|
|
3510
3517
|
const url = new URL(request.url);
|
|
3511
|
-
|
|
3518
|
+
const isWebSocketUpgrade = options.isWebSocketUpgrade ?? ((req, u) => req.headers.get("Upgrade") === "websocket" && isWebSocketPath(u));
|
|
3519
|
+
if (options.onWebSocketUpgrade != null && isWebSocketUpgrade(request, url)) return options.onWebSocketUpgrade(request, url);
|
|
3512
3520
|
if (request.method === "POST" && isActionPath(url)) {
|
|
3513
3521
|
if (exchangeAcceptor != null) {
|
|
3514
3522
|
const reply = await exchangeAcceptor.handlePost(await request.text());
|
|
@@ -3523,6 +3531,151 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
3523
3531
|
};
|
|
3524
3532
|
}
|
|
3525
3533
|
//#endregion
|
|
3534
|
+
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/createHibernatableWsServerAdapter.ts
|
|
3535
|
+
/**
|
|
3536
|
+
* Wire the hibernation lifecycle for an acceptor handler on a transport whose connections outlive process
|
|
3537
|
+
* eviction (e.g. a Durable Object's hibernatable WebSockets). It owns persistence end to end:
|
|
3538
|
+
* registers `setAttachment` as the handler's connection-bound callback and immediately replays every
|
|
3539
|
+
* live connection's stored binding via `getAttachment`, so results/pushes still route after a wake.
|
|
3540
|
+
*
|
|
3541
|
+
* Layered on top of the generic {@link AcceptorHandler} — it touches only the handler's neutral
|
|
3542
|
+
* `setOnConnectionBound` / `rehydrateConnection` / `receive` / `dropConnection` surface, so no
|
|
3543
|
+
* hibernation concern leaks into the handler itself.
|
|
3544
|
+
*
|
|
3545
|
+
* Construct it once when the handler is built, then forward connection events:
|
|
3546
|
+
* ```ts
|
|
3547
|
+
* const duplex = createHibernatableWsServerAdapter({ handler, getConnections, getAttachment, setAttachment });
|
|
3548
|
+
* // webSocketMessage(ws, msg) => duplex.receive(ws, msg);
|
|
3549
|
+
* // webSocketClose/Error(ws) => duplex.drop(ws);
|
|
3550
|
+
* ```
|
|
3551
|
+
*/
|
|
3552
|
+
function createHibernatableWsServerAdapter(options) {
|
|
3553
|
+
const { handler, getConnections, getAttachment, setAttachment } = options;
|
|
3554
|
+
handler.setOnConnectionBound(setAttachment);
|
|
3555
|
+
for (const connection of getConnections()) {
|
|
3556
|
+
const binding = getAttachment(connection);
|
|
3557
|
+
if (binding != null) handler.rehydrateConnection(connection, binding);
|
|
3558
|
+
}
|
|
3559
|
+
return {
|
|
3560
|
+
receive: (connection, frame) => handler.receive(connection, frame),
|
|
3561
|
+
drop: (connection) => handler.dropConnection(connection)
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3564
|
+
//#endregion
|
|
3565
|
+
//#region src/ActionRuntime/Channel/serveChannel.ts
|
|
3566
|
+
/** Default accepted set, shared by every carrier: negotiate per connection to whatever the client picks. */
|
|
3567
|
+
const DEFAULT_SERVER_SECURITY_LEVELS = [
|
|
3568
|
+
"none",
|
|
3569
|
+
"authenticated",
|
|
3570
|
+
"encrypted"
|
|
3571
|
+
];
|
|
3572
|
+
/**
|
|
3573
|
+
* Serve a secure channel over one or more carriers from a single call — the accept-in dual of
|
|
3574
|
+
* `connectChannel`. It builds the crypto identity (a {@link ClientCryptoKeyLink} + a storage-backed TOFU
|
|
3575
|
+
* resolver) and the security block (coordinate, dictionary version, accepted levels) *once* from
|
|
3576
|
+
* `(runtime, channel)` and fans them across every carrier, so the WebSocket and the secure-HTTP endpoint
|
|
3577
|
+
* can never drift apart. It registers your handlers (plus the duplex acceptor it builds) on the runtime,
|
|
3578
|
+
* wires hibernation when the duplex carrier declares it, and returns a single {@link IChannelServer} whose
|
|
3579
|
+
* `fetch` / `duplex` / `pushToClient` you forward straight to the host:
|
|
3580
|
+
* ```ts
|
|
3581
|
+
* const server = serveChannel(runtime, channel, {
|
|
3582
|
+
* clientEnv, storage,
|
|
3583
|
+
* carriers: [wsAcceptorCarrier({ send, upgrade, hibernation }), httpAcceptorCarrier()],
|
|
3584
|
+
* handlers: [localHandler],
|
|
3585
|
+
* });
|
|
3586
|
+
* // fetch(req) => server.fetch(req)
|
|
3587
|
+
* // webSocketMessage(conn, m) => server.duplex?.receive(conn, m)
|
|
3588
|
+
* // webSocketClose/Error(conn) => server.duplex?.drop(conn)
|
|
3589
|
+
* ```
|
|
3590
|
+
*
|
|
3591
|
+
* `TConn` (the live-connection token a duplex carrier hands back through `send`/`receive`/`drop`) is
|
|
3592
|
+
* inferred from the carriers — `WebSocket` for `wsAcceptorCarrier`, the data-channel type for a WebRTC
|
|
3593
|
+
* carrier, and so on — so it stays carrier-agnostic.
|
|
3594
|
+
*/
|
|
3595
|
+
function serveChannel(runtime, channel, options) {
|
|
3596
|
+
const duplexCarriers = options.carriers.filter((carrier) => !isExchangeAcceptorCarrier(carrier));
|
|
3597
|
+
const exchangeCarriers = options.carriers.filter(isExchangeAcceptorCarrier);
|
|
3598
|
+
if (exchangeCarriers.length > 1) throw new Error("serveChannel: at most one exchange carrier is supported");
|
|
3599
|
+
const exchangeCarrier = exchangeCarriers[0];
|
|
3600
|
+
const exchangeSecure = exchangeCarrier != null && (exchangeCarrier.secure ?? true);
|
|
3601
|
+
const anyDuplexSecure = duplexCarriers.some((carrier) => carrier.secure ?? true);
|
|
3602
|
+
const securityLevel = options.securityLevel ?? DEFAULT_SERVER_SECURITY_LEVELS;
|
|
3603
|
+
let secure;
|
|
3604
|
+
if (anyDuplexSecure || exchangeSecure) {
|
|
3605
|
+
const storage = options.storage;
|
|
3606
|
+
if (storage == null) throw new Error("serveChannel: a secure carrier requires `storage`. Pass it, or set `secure: false` on the carrier for a plain endpoint.");
|
|
3607
|
+
secure = {
|
|
3608
|
+
storage,
|
|
3609
|
+
link: options.link ?? new ClientCryptoKeyLink({ storageAdapter: storage }),
|
|
3610
|
+
verifyKeyResolver: options.verifyKeyResolver ?? createStorageTofuVerifyKeyResolver(storage)
|
|
3611
|
+
};
|
|
3612
|
+
}
|
|
3613
|
+
const handlers = [];
|
|
3614
|
+
for (const carrier of duplexCarriers) {
|
|
3615
|
+
const handler = (carrier.secure ?? true) && secure != null ? acceptChannel(runtime, channel, {
|
|
3616
|
+
clientEnv: options.clientEnv,
|
|
3617
|
+
storageAdapter: secure.storage,
|
|
3618
|
+
link: secure.link,
|
|
3619
|
+
verifyKeyResolver: secure.verifyKeyResolver,
|
|
3620
|
+
securityLevel,
|
|
3621
|
+
send: carrier.send,
|
|
3622
|
+
defaultTimeout: options.defaultTimeout
|
|
3623
|
+
}) : createAcceptorHandler({
|
|
3624
|
+
clientEnv: options.clientEnv,
|
|
3625
|
+
createFormatMessage: channel.createCodec,
|
|
3626
|
+
send: carrier.send,
|
|
3627
|
+
runtime,
|
|
3628
|
+
defaultTimeout: options.defaultTimeout
|
|
3629
|
+
});
|
|
3630
|
+
const router = carrier.hibernation != null ? createHibernatableWsServerAdapter({
|
|
3631
|
+
handler,
|
|
3632
|
+
...carrier.hibernation
|
|
3633
|
+
}) : {
|
|
3634
|
+
receive: (connection, frame) => handler.receive(connection, frame),
|
|
3635
|
+
drop: (connection) => handler.dropConnection(connection)
|
|
3636
|
+
};
|
|
3637
|
+
carrier._activate(router);
|
|
3638
|
+
handlers.push(handler);
|
|
3639
|
+
}
|
|
3640
|
+
runtime.addHandlers([...options.handlers ?? [], ...handlers]);
|
|
3641
|
+
const exchangeSecurity = exchangeSecure && secure != null ? {
|
|
3642
|
+
link: secure.link,
|
|
3643
|
+
verifyKeyResolver: secure.verifyKeyResolver,
|
|
3644
|
+
localCoordinate: runtime.coordinate.toJsonObject(),
|
|
3645
|
+
dictionaryVersion: channel.dictionaryVersion,
|
|
3646
|
+
securityLevel
|
|
3647
|
+
} : void 0;
|
|
3648
|
+
const defaultIsUpgrade = (request) => request.headers.get("Upgrade") === "websocket";
|
|
3649
|
+
const upgraders = [];
|
|
3650
|
+
for (const carrier of duplexCarriers) {
|
|
3651
|
+
if (carrier.upgrade == null) continue;
|
|
3652
|
+
upgraders.push({
|
|
3653
|
+
isUpgrade: carrier.isUpgrade ?? defaultIsUpgrade,
|
|
3654
|
+
upgrade: carrier.upgrade
|
|
3655
|
+
});
|
|
3656
|
+
}
|
|
3657
|
+
const fetch = createActionFetchHandler(runtime, {
|
|
3658
|
+
cors: exchangeCarrier?.cors,
|
|
3659
|
+
onWebSocketUpgrade: upgraders.length === 0 ? void 0 : (request, url) => (upgraders.find((u) => u.isUpgrade(request, url)) ?? upgraders[0]).upgrade(request, url),
|
|
3660
|
+
isWebSocketUpgrade: upgraders.length === 0 ? void 0 : (request, url) => upgraders.some((u) => u.isUpgrade(request, url)),
|
|
3661
|
+
isActionPath: exchangeCarrier != null ? exchangeCarrier.isActionPath ?? (() => true) : () => false,
|
|
3662
|
+
security: exchangeSecurity,
|
|
3663
|
+
useErrorStatus: exchangeCarrier?.useErrorStatus
|
|
3664
|
+
});
|
|
3665
|
+
const duplex = duplexCarriers.length === 1 ? duplexCarriers[0] : void 0;
|
|
3666
|
+
const pushToClient = (target, request, pushOptions) => {
|
|
3667
|
+
const owner = target instanceof RuntimeCoordinate ? handlers.find((handler) => handler.ownsLiveConnectionFor(target)) : handlers.find((handler) => handler.hasConnection(target));
|
|
3668
|
+
if (owner == null) throw new Error("serveChannel: no duplex carrier holds a connection for the push target");
|
|
3669
|
+
return owner.pushToClient(runtime, target, request, pushOptions);
|
|
3670
|
+
};
|
|
3671
|
+
return {
|
|
3672
|
+
handlers,
|
|
3673
|
+
fetch,
|
|
3674
|
+
duplex,
|
|
3675
|
+
pushToClient
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
//#endregion
|
|
3526
3679
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/ConnectionStateStore.ts
|
|
3527
3680
|
/**
|
|
3528
3681
|
* A typed per-connection state store that co-owns the app state and the acceptor handler's routing
|
|
@@ -3630,37 +3783,6 @@ function createConnectionStateStore(handler, options) {
|
|
|
3630
3783
|
return store;
|
|
3631
3784
|
}
|
|
3632
3785
|
//#endregion
|
|
3633
|
-
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/createHibernatableWsServerAdapter.ts
|
|
3634
|
-
/**
|
|
3635
|
-
* Wire the hibernation lifecycle for an acceptor handler on a transport whose sockets outlive process
|
|
3636
|
-
* eviction (e.g. a Durable Object's hibernatable WebSockets). It owns persistence end to end:
|
|
3637
|
-
* registers `setAttachment` as the handler's connection-bound callback and immediately replays every
|
|
3638
|
-
* live connection's stored binding via `getAttachment`, so results/pushes still route after a wake.
|
|
3639
|
-
*
|
|
3640
|
-
* Layered on top of the generic {@link AcceptorHandler} — it touches only the handler's neutral
|
|
3641
|
-
* `setOnConnectionBound` / `rehydrateConnection` / `receive` / `dropConnection` surface, so no
|
|
3642
|
-
* hibernation concern leaks into the handler itself.
|
|
3643
|
-
*
|
|
3644
|
-
* Construct it once when the handler is built, then forward socket events:
|
|
3645
|
-
* ```ts
|
|
3646
|
-
* const wsServer = createHibernatableWsServerAdapter({ handler, getWebSockets, getAttachment, setAttachment });
|
|
3647
|
-
* // webSocketMessage(ws, msg) => wsServer.receive(ws, msg);
|
|
3648
|
-
* // webSocketClose/Error(ws) => wsServer.drop(ws);
|
|
3649
|
-
* ```
|
|
3650
|
-
*/
|
|
3651
|
-
function createHibernatableWsServerAdapter(options) {
|
|
3652
|
-
const { handler, getWebSockets, getAttachment, setAttachment } = options;
|
|
3653
|
-
handler.setOnConnectionBound(setAttachment);
|
|
3654
|
-
for (const connection of getWebSockets()) {
|
|
3655
|
-
const binding = getAttachment(connection);
|
|
3656
|
-
if (binding != null) handler.rehydrateConnection(connection, binding);
|
|
3657
|
-
}
|
|
3658
|
-
return {
|
|
3659
|
-
receive: (connection, frame) => handler.receive(connection, frame),
|
|
3660
|
-
drop: (connection) => handler.dropConnection(connection)
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
//#endregion
|
|
3664
3786
|
//#region src/ActionRuntime/Transport/Carrier/duplex/inMemory/createInMemoryChannel.ts
|
|
3665
3787
|
/**
|
|
3666
3788
|
* Two cross-wired in-process byte channels — a loopback carrier with no socket. The client end is a
|
|
@@ -3818,6 +3940,22 @@ function rtcCarrier(dataChannel, options = {}) {
|
|
|
3818
3940
|
};
|
|
3819
3941
|
}
|
|
3820
3942
|
//#endregion
|
|
3943
|
+
//#region src/ActionRuntime/Transport/Carrier/duplex/ws/err_nice_transport_ws.ts
|
|
3944
|
+
let EErrId_NiceTransport_WebSocket = /* @__PURE__ */ function(EErrId_NiceTransport_WebSocket) {
|
|
3945
|
+
EErrId_NiceTransport_WebSocket["ws_disconnected"] = "ws_disconnected";
|
|
3946
|
+
EErrId_NiceTransport_WebSocket["ws_create_failed"] = "ws_create_failed";
|
|
3947
|
+
EErrId_NiceTransport_WebSocket["ws_error"] = "ws_error";
|
|
3948
|
+
return EErrId_NiceTransport_WebSocket;
|
|
3949
|
+
}({});
|
|
3950
|
+
const err_nice_transport_ws = err_nice_transport.createChildDomain({
|
|
3951
|
+
domain: "ws_transport",
|
|
3952
|
+
schema: {
|
|
3953
|
+
["ws_disconnected"]: err({ message: () => `WebSocket transport disconnected.` }),
|
|
3954
|
+
["ws_create_failed"]: err({ message: ({ originalError }) => `Failed to create WebSocket transport.${originalError ? ` Original error: ${originalError.message}` : ""}` }),
|
|
3955
|
+
["ws_error"]: err({ message: ({ originalError }) => `WebSocket transport error.${originalError ? ` Original error: ${originalError.message}` : ""}` })
|
|
3956
|
+
}
|
|
3957
|
+
});
|
|
3958
|
+
//#endregion
|
|
3821
3959
|
//#region src/ActionRuntime/Transport/Carrier/duplex/ws/ws_util.ts
|
|
3822
3960
|
/**
|
|
3823
3961
|
* Send a text or binary frame over a socket. A binary formatter may hand back a `Uint8Array` whose
|
|
@@ -3930,6 +4068,25 @@ function defaultWebSocket(url) {
|
|
|
3930
4068
|
return ws;
|
|
3931
4069
|
}
|
|
3932
4070
|
//#endregion
|
|
4071
|
+
//#region src/ActionRuntime/Transport/Carrier/exchange/http/httpAcceptorCarrier.ts
|
|
4072
|
+
/**
|
|
4073
|
+
* An HTTP {@link IExchangeAcceptorCarrier}: the accept-in dual of {@link httpCarrier}. It serves the
|
|
4074
|
+
* secure exchange protocol (handshake → token session → encrypted frames) over web-standard
|
|
4075
|
+
* `Request`/`Response`. The crypto identity, runtime coordinate, dictionary version, and accepted security
|
|
4076
|
+
* levels are all supplied centrally by `serveChannel`, so this only needs to say which requests carry an
|
|
4077
|
+
* action envelope and how to answer CORS.
|
|
4078
|
+
*/
|
|
4079
|
+
function httpAcceptorCarrier(options = {}) {
|
|
4080
|
+
return {
|
|
4081
|
+
shape: "exchange",
|
|
4082
|
+
carrierLabel: options.carrierLabel ?? "http",
|
|
4083
|
+
secure: options.secure,
|
|
4084
|
+
isActionPath: options.isActionPath,
|
|
4085
|
+
cors: options.cors,
|
|
4086
|
+
useErrorStatus: options.useErrorStatus
|
|
4087
|
+
};
|
|
4088
|
+
}
|
|
4089
|
+
//#endregion
|
|
3933
4090
|
//#region src/ActionRuntime/Transport/Carrier/exchange/http/httpCarrier.ts
|
|
3934
4091
|
function shortPath(url) {
|
|
3935
4092
|
try {
|
|
@@ -4395,22 +4552,6 @@ var ExchangeTransport = class ExchangeTransport extends Transport {
|
|
|
4395
4552
|
}
|
|
4396
4553
|
};
|
|
4397
4554
|
//#endregion
|
|
4398
|
-
//#region src/ActionRuntime/Transport/Carrier/duplex/ws/err_nice_transport_ws.ts
|
|
4399
|
-
let EErrId_NiceTransport_WebSocket = /* @__PURE__ */ function(EErrId_NiceTransport_WebSocket) {
|
|
4400
|
-
EErrId_NiceTransport_WebSocket["ws_disconnected"] = "ws_disconnected";
|
|
4401
|
-
EErrId_NiceTransport_WebSocket["ws_create_failed"] = "ws_create_failed";
|
|
4402
|
-
EErrId_NiceTransport_WebSocket["ws_error"] = "ws_error";
|
|
4403
|
-
return EErrId_NiceTransport_WebSocket;
|
|
4404
|
-
}({});
|
|
4405
|
-
const err_nice_transport_ws = err_nice_transport.createChildDomain({
|
|
4406
|
-
domain: "ws_transport",
|
|
4407
|
-
schema: {
|
|
4408
|
-
["ws_disconnected"]: err({ message: () => `WebSocket transport disconnected.` }),
|
|
4409
|
-
["ws_create_failed"]: err({ message: ({ originalError }) => `Failed to create WebSocket transport.${originalError ? ` Original error: ${originalError.message}` : ""}` }),
|
|
4410
|
-
["ws_error"]: err({ message: ({ originalError }) => `WebSocket transport error.${originalError ? ` Original error: ${originalError.message}` : ""}` })
|
|
4411
|
-
}
|
|
4412
|
-
});
|
|
4413
|
-
//#endregion
|
|
4414
4555
|
//#region src/ActionRuntime/Transport/helpers/createUnsetTransportResolvers.ts
|
|
4415
4556
|
const createUnsetTransportResolvers = (transportLabel) => ({ onIncomingActionDataJson: (json) => {
|
|
4416
4557
|
console.warn(`Received incoming action JSON [${json.domain}:${json.id}] on Transport [${transportLabel}] but no incoming data listener has been set.`);
|
|
@@ -4718,6 +4859,6 @@ function secureTransport(options) {
|
|
|
4718
4859
|
});
|
|
4719
4860
|
}
|
|
4720
4861
|
//#endregion
|
|
4721
|
-
export { AcceptorHandler, ActionCore, ActionDomain, ActionLocalHandler, ActionRootDomain, ActionRuntime, ActionSchema, ConnectionStateStore, ConnectorHandler, EActionPayloadType, EActionProgressType, EActionResponseMode, EErrId_NiceAction, EErrId_NiceTransport, EErrId_NiceTransport_WebSocket, EHandshakeMessageType, ERunningActionFinishedType, ERunningActionState, ERunningActionUpdateType, ESecurityLevel, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, LinkTransport, PeerLinkHandler, RunningAction, RuntimeCoordinate, Transport, acceptChannel, acceptChannelConnections, actionSchema, connectChannel, createAcceptorHandler, createActionFetchHandler, createActionFrameCrypto, createActionRootDomain, createBinaryWireAdapter, createBinaryWireSessionFactory, createClientHandshake, createConnectionStateStore, createConnectorHandler, createHibernatableWsServerAdapter, createInMemoryChannelPair, createInMemoryTofuVerifyKeyResolver, createLocalHandler, createSecureAcceptorHandler, createServerHandshake, createStorageTofuVerifyKeyResolver, decodeActionFrame, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeHandshakeMessage, err_nice_action, err_nice_external_client, err_nice_transport, err_nice_transport_ws, httpCarrier, inMemoryCarrier, isActionPayload_Any_JsonObject, isActionPayload_Request_JsonObject, isActionPayload_Result_JsonObject, plainTransport, rtcCarrier, rtcDataChannelByteChannel, runtimeLinkId, secureTransport, wsCarrier };
|
|
4862
|
+
export { AcceptorHandler, ActionCore, ActionDomain, ActionLocalHandler, ActionRootDomain, ActionRuntime, ActionSchema, ConnectionStateStore, ConnectorHandler, EActionPayloadType, EActionProgressType, EActionResponseMode, EErrId_NiceAction, EErrId_NiceTransport, EErrId_NiceTransport_WebSocket, EHandshakeMessageType, ERunningActionFinishedType, ERunningActionState, ERunningActionUpdateType, ESecurityLevel, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, LinkTransport, PeerLinkHandler, RunningAction, RuntimeCoordinate, Transport, acceptChannel, acceptChannelConnections, actionSchema, connectChannel, createAcceptorHandler, createActionFetchHandler, createActionFrameCrypto, createActionRootDomain, createBinaryWireAdapter, createBinaryWireSessionFactory, createClientHandshake, createConnectionStateStore, createConnectorHandler, createHibernatableWsServerAdapter, createInMemoryChannelPair, createInMemoryTofuVerifyKeyResolver, createLocalHandler, createSecureAcceptorHandler, createServerHandshake, createStorageTofuVerifyKeyResolver, decodeActionFrame, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeHandshakeMessage, err_nice_action, err_nice_external_client, err_nice_transport, err_nice_transport_ws, httpAcceptorCarrier, httpCarrier, inMemoryCarrier, isActionPayload_Any_JsonObject, isActionPayload_Request_JsonObject, isActionPayload_Result_JsonObject, isExchangeAcceptorCarrier, plainTransport, rtcCarrier, rtcDataChannelByteChannel, runtimeLinkId, secureTransport, serveChannel, wsAcceptorCarrier, wsCarrier };
|
|
4722
4863
|
|
|
4723
4864
|
//# sourceMappingURL=index.mjs.map
|