@nice-code/action 0.18.0 → 0.20.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 +699 -637
- package/build/{ActionDevtoolsCore-C5XrQI1K.d.mts → ActionDevtoolsCore-D_JvgPmz.d.mts} +2 -2
- package/build/{ActionDevtoolsCore-Dd1qJAwK.d.cts → ActionDevtoolsCore-dV-IVPcP.d.cts} +2 -2
- package/build/{ActionPayload.types-BchJrBIX.d.mts → ActionPayload.types-CnfWlkA1.d.cts} +252 -106
- package/build/{ActionPayload.types-snDlSIF-.d.cts → ActionPayload.types-D0DM-g65.d.mts} +252 -106
- 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 +169 -138
- 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 +167 -139
- package/build/index.mjs.map +1 -1
- package/build/platform/cloudflare/index.cjs +8 -4
- package/build/platform/cloudflare/index.cjs.map +1 -1
- package/build/platform/cloudflare/index.d.cts +8 -3
- package/build/platform/cloudflare/index.d.mts +8 -3
- package/build/platform/cloudflare/index.mjs +8 -4
- package/build/platform/cloudflare/index.mjs.map +1 -1
- package/build/react-query/index.d.cts +1 -1
- package/build/react-query/index.d.mts +1 -1
- package/build/{wsAcceptorCarrier-DHRbsY1X.cjs → wsAcceptorCarrier-BDJRIPfu.cjs} +2 -2
- package/build/wsAcceptorCarrier-BDJRIPfu.cjs.map +1 -0
- package/build/{wsAcceptorCarrier-CXGlQU_f.mjs → wsAcceptorCarrier-CW2qX25W.mjs} +2 -2
- package/build/wsAcceptorCarrier-CW2qX25W.mjs.map +1 -0
- package/package.json +4 -4
- package/build/wsAcceptorCarrier-CXGlQU_f.mjs.map +0 -1
- package/build/wsAcceptorCarrier-DHRbsY1X.cjs.map +0 -1
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
|
|
1
|
+
import { $ as httpAcceptorCarrier, $n as ITransportConnectionContext, $r as ActionSchema, $t as defineChannel, A as decodeExchangeReply, An as ITransportRouteActionParams, Ar as IRunningActionUpdate_Progress, At as TAcceptorCarrier, B as err_nice_transport, Bn as TOnResolveAnyIncomingActionData, Br as RuntimeCoordinate, Bt as createHibernatableWsServerAdapter, C as decodeActionFrame, Cn as IActionTransportReady, Cr as ActionPayload_Request, Ct as IChannelServer, D as secureTransport, Dn as ISecureClientConfig, Dr as ERunningActionState, Dt as IAcceptorAttachmentStore, E as ISecureTransportOptions, En as IActionTransportResolvers, Er as ERunningActionFinishedType, Et as serveChannel, F as ILinkTransportOptions, Fn as ITransportStatusInfo_Initializing, Fr as TRunningActionUpdateListener, Ft as IExchangeCarrierSource, G as IActionFrameCryptoConfig, Gn as TOnResolveIncomingResponseJson, Gr as IActionRootDomain, Gt as IAcceptChannelOptions, H as IExchangeTransportOptions, Hn as TOnResolveIncomingRequest, Hr as TRuntimeCoordinateStringId, Ht as IConnectionAttachment, I as LinkTransport, In as ITransportStatusInfo_Ready, Ir as ActionPayload_Result, It as TCarrier, J as IHttpCarrierOptions, Jn as TTransportCache, Jr as TDomainActionId, Jt as TChannelAcceptorCases, K as createActionFrameCrypto, Kn as TSendActionDataMethod, Kr as TActionDomainChildDef, Kt as IActionChannel, L as IActionTransportReadyData_Link, Ln as ITransportStatusInfo_Unsupported, Lr as IRuntimeCoordinate, Lt as TFrame, M as encodeExchange, Mn as ITransportRouteInfo, Mr as IRunningActionUpdate_Success, Mt as IDuplexCarrier, N as IPlainTransportOptions, Nn as ITransportStatusInfo_Base, Nr as TRunningActionUpdate, Nt as IDuplexCarrierSource, O as TExchangeReply, On as ITransportDispatchAction, Or as ERunningActionUpdateType, Ot as IDuplexAcceptorCarrier, P as plainTransport, Pn as ITransportStatusInfo_Failed, Pr as TRunningActionUpdateFinished, Pt as IExchangeCarrier, Q as IHttpAcceptorCarrierOptions, Qn as TUpdateActionRunConfig, Qr as TPossibleDomainIdList, Qt as connectChannel, R as TLinkFormatMessage, Rn as IUpdateActionRunConfig_Output, Rr as IRuntimeCoordinateSpecifics, Rt as IDuplexConnectionRouter, S as IActionFrameDecoder, Sn as IActionTransportInitialized, Sr as ActionPayload_Progress, St as IExchangeAcceptorSecurity, T as err_nice_action, Tn as IActionTransportReadyData_Methods, Tr as IActionCore_JsonObject, Tt as IServeConnectionStateOptions, U as IActionTransportReadyData_Exchange, Un as TOnResolveIncomingRequestJson, Ur as IActionDomain, Ut as IConnectionStateStoreOptions, V as ExchangeTransport, Vn as TOnResolveAnyIncomingActionData_Json, Vr as TRuntimeCoordinateEnvId, Vt as ConnectionStateStore, W as IActionFrameCrypto, Wn as TOnResolveIncomingResponse, Wr as IActionDomainChildOptions, Wt as createConnectionStateStore, X as TCarrierFetch, Xn as TTransportStatusInfo, Xr as TInferOutputFromSchema, Xt as acceptChannel, Y as IHttpCarrierRequest, Yn as TTransportInitializationFinishedInfo, Yr as TInferInputFromSchema, Yt as TChannelPushHandlers, Z as httpCarrier, Zn as TTransportStatusInfo_GetTransport_Output, Zr as TPossibleDomainId, Zt as acceptChannelConnections, _ as TActionProgress, _n as ConnectorHandler, _r as PeerLinkHandler, _t as createSecureAcceptorHandler, a as IActionPayload_Data_Base, ai as TTransportedValue, an as IAcceptorConnectionBinding, ar as IClientVerifyKeyResolver, at as err_nice_transport_ws, b as isActionPayload_Request_JsonObject, bn as ETransportStatus, br as MaybePromise, bt as ExchangeAcceptor, c as IActionPayload_Request_JsonObject, cn as TActionChannelFormatMessage, cr as IServerHandshakeConfig, ct as IRtcDataChannelLike, d as IActionProgress_Custom, dn as IActionWireFormat, dr as createInMemoryTofuVerifyKeyResolver, dt as inMemoryCarrier, ei as EActionResponseMode, en as ISecureChannel, er as Transport, et as IWsCarrierOptions, f as IActionProgress_None, fn as createActionRootDomain, fr as createServerHandshake, ft as IInMemoryChannelPair, g as TActionPayload_Any_JsonObject, gn as ActionRuntime, gr as runtimeLinkId, gt as ISecureAcceptorHandlerOptions, h as TActionPayload_Any_Instance, hn as ActionRootDomain, hr as encodeHandshakeMessage, ht as err_nice_external_client, i as IActionPayload_Base_JsonObject, ii as TActionSerializationDefinition, in as AcceptorHandler, ir as IClientVerifyKeyResolveInput, it as EErrId_NiceTransport_WebSocket, j as decodeExchangeRequest, jn as ITransportRouteClientParams, jr as IRunningActionUpdate_Started, jt as isExchangeAcceptorCarrier, k as TExchangeRequest, kn as ITransportMethod_SendActionData_Input, kr as IRunningActionUpdate_Abort, kt as IExchangeAcceptorCarrier, l as IActionPayload_Result, ln as TActionConnectionEncoding, lr as THandshakeMessage, lt as rtcDataChannelByteChannel, m as IActionRouteItemHandler, mn as ActionDomain, mr as decodeHandshakeMessage, mt as createInMemoryChannelPair, n as EActionProgressType, ni as actionSchema, nn as IBinaryWireSessionOptions, nr as ESecurityLevel, nt as IWsAcceptorCarrierOptions, o as IActionPayload_Progress, on as IAcceptorHandlerOptions, or as IHandshakeEncryptionKeyMaterial, ot as IRtcCarrierOptions, p as IActionProgress_Percentage, pn as ActionCore, pr as createStorageTofuVerifyKeyResolver, pt as IInMemoryServerEndpoint, q as createBinaryWireAdapter, qn as TSendReturnDataMethod, qr as TActionDomainSchema, qt as IConnectChannelOptions, r as IActionPayload_Base, ri as TActionSchemaOptions, rn as createBinaryWireSessionFactory, rr as IClientHandshakeConfig, rt as wsAcceptorCarrier, s as IActionPayload_Progress_JsonObject, sn as TAcceptorConnectionCaseFn, sr as IHandshakeResult, st as rtcCarrier, t as EActionPayloadType, ti as TInferActionError, tn as defineSecureChannel, tr as EHandshakeMessageType, tt as wsCarrier, u as IActionPayload_Result_JsonObject, un as createAcceptorHandler, ur as createClientHandshake, ut as IInMemoryCarrier, v as TActionResultOutcome, vn as createConnectorHandler, vr as ActionLocalHandler, vt as IActionFetchHandlerOptions, w as EErrId_NiceAction, wn as IActionTransportReadyData_Base, wr as IActionCore, wt as IServeChannelOptions, x as isActionPayload_Any_JsonObject, xn as IActionTransportDef, xr as RunningAction, xt as IExchangeAcceptorConfig, y as isActionPayload_Result_JsonObject, yn as ETransportShape, yr as createLocalHandler, yt as createActionFetchHandler, z as EErrId_NiceTransport, zn as TGetTransportFn, zr as IRuntimeFullCoordinates, zt as IHibernatableWsServerAdapterOptions } from "./ActionPayload.types-CnfWlkA1.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 IAcceptorAttachmentStore, 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 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 IServeConnectionStateOptions, 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 TExchangeReply, type TExchangeRequest, 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, decodeExchangeReply, decodeExchangeRequest, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeExchange, 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
|
|
1
|
+
import { $ as httpAcceptorCarrier, $n as ITransportConnectionContext, $r as ActionSchema, $t as defineChannel, A as decodeExchangeReply, An as ITransportRouteActionParams, Ar as IRunningActionUpdate_Progress, At as TAcceptorCarrier, B as err_nice_transport, Bn as TOnResolveAnyIncomingActionData, Br as RuntimeCoordinate, Bt as createHibernatableWsServerAdapter, C as decodeActionFrame, Cn as IActionTransportReady, Cr as ActionPayload_Request, Ct as IChannelServer, D as secureTransport, Dn as ISecureClientConfig, Dr as ERunningActionState, Dt as IAcceptorAttachmentStore, E as ISecureTransportOptions, En as IActionTransportResolvers, Er as ERunningActionFinishedType, Et as serveChannel, F as ILinkTransportOptions, Fn as ITransportStatusInfo_Initializing, Fr as TRunningActionUpdateListener, Ft as IExchangeCarrierSource, G as IActionFrameCryptoConfig, Gn as TOnResolveIncomingResponseJson, Gr as IActionRootDomain, Gt as IAcceptChannelOptions, H as IExchangeTransportOptions, Hn as TOnResolveIncomingRequest, Hr as TRuntimeCoordinateStringId, Ht as IConnectionAttachment, I as LinkTransport, In as ITransportStatusInfo_Ready, Ir as ActionPayload_Result, It as TCarrier, J as IHttpCarrierOptions, Jn as TTransportCache, Jr as TDomainActionId, Jt as TChannelAcceptorCases, K as createActionFrameCrypto, Kn as TSendActionDataMethod, Kr as TActionDomainChildDef, Kt as IActionChannel, L as IActionTransportReadyData_Link, Ln as ITransportStatusInfo_Unsupported, Lr as IRuntimeCoordinate, Lt as TFrame, M as encodeExchange, Mn as ITransportRouteInfo, Mr as IRunningActionUpdate_Success, Mt as IDuplexCarrier, N as IPlainTransportOptions, Nn as ITransportStatusInfo_Base, Nr as TRunningActionUpdate, Nt as IDuplexCarrierSource, O as TExchangeReply, On as ITransportDispatchAction, Or as ERunningActionUpdateType, Ot as IDuplexAcceptorCarrier, P as plainTransport, Pn as ITransportStatusInfo_Failed, Pr as TRunningActionUpdateFinished, Pt as IExchangeCarrier, Q as IHttpAcceptorCarrierOptions, Qn as TUpdateActionRunConfig, Qr as TPossibleDomainIdList, Qt as connectChannel, R as TLinkFormatMessage, Rn as IUpdateActionRunConfig_Output, Rr as IRuntimeCoordinateSpecifics, Rt as IDuplexConnectionRouter, S as IActionFrameDecoder, Sn as IActionTransportInitialized, Sr as ActionPayload_Progress, St as IExchangeAcceptorSecurity, T as err_nice_action, Tn as IActionTransportReadyData_Methods, Tr as IActionCore_JsonObject, Tt as IServeConnectionStateOptions, U as IActionTransportReadyData_Exchange, Un as TOnResolveIncomingRequestJson, Ur as IActionDomain, Ut as IConnectionStateStoreOptions, V as ExchangeTransport, Vn as TOnResolveAnyIncomingActionData_Json, Vr as TRuntimeCoordinateEnvId, Vt as ConnectionStateStore, W as IActionFrameCrypto, Wn as TOnResolveIncomingResponse, Wr as IActionDomainChildOptions, Wt as createConnectionStateStore, X as TCarrierFetch, Xn as TTransportStatusInfo, Xr as TInferOutputFromSchema, Xt as acceptChannel, Y as IHttpCarrierRequest, Yn as TTransportInitializationFinishedInfo, Yr as TInferInputFromSchema, Yt as TChannelPushHandlers, Z as httpCarrier, Zn as TTransportStatusInfo_GetTransport_Output, Zr as TPossibleDomainId, Zt as acceptChannelConnections, _ as TActionProgress, _n as ConnectorHandler, _r as PeerLinkHandler, _t as createSecureAcceptorHandler, a as IActionPayload_Data_Base, ai as TTransportedValue, an as IAcceptorConnectionBinding, ar as IClientVerifyKeyResolver, at as err_nice_transport_ws, b as isActionPayload_Request_JsonObject, bn as ETransportStatus, br as MaybePromise, bt as ExchangeAcceptor, c as IActionPayload_Request_JsonObject, cn as TActionChannelFormatMessage, cr as IServerHandshakeConfig, ct as IRtcDataChannelLike, d as IActionProgress_Custom, dn as IActionWireFormat, dr as createInMemoryTofuVerifyKeyResolver, dt as inMemoryCarrier, ei as EActionResponseMode, en as ISecureChannel, er as Transport, et as IWsCarrierOptions, f as IActionProgress_None, fn as createActionRootDomain, fr as createServerHandshake, ft as IInMemoryChannelPair, g as TActionPayload_Any_JsonObject, gn as ActionRuntime, gr as runtimeLinkId, gt as ISecureAcceptorHandlerOptions, h as TActionPayload_Any_Instance, hn as ActionRootDomain, hr as encodeHandshakeMessage, ht as err_nice_external_client, i as IActionPayload_Base_JsonObject, ii as TActionSerializationDefinition, in as AcceptorHandler, ir as IClientVerifyKeyResolveInput, it as EErrId_NiceTransport_WebSocket, j as decodeExchangeRequest, jn as ITransportRouteClientParams, jr as IRunningActionUpdate_Started, jt as isExchangeAcceptorCarrier, k as TExchangeRequest, kn as ITransportMethod_SendActionData_Input, kr as IRunningActionUpdate_Abort, kt as IExchangeAcceptorCarrier, l as IActionPayload_Result, ln as TActionConnectionEncoding, lr as THandshakeMessage, lt as rtcDataChannelByteChannel, m as IActionRouteItemHandler, mn as ActionDomain, mr as decodeHandshakeMessage, mt as createInMemoryChannelPair, n as EActionProgressType, ni as actionSchema, nn as IBinaryWireSessionOptions, nr as ESecurityLevel, nt as IWsAcceptorCarrierOptions, o as IActionPayload_Progress, on as IAcceptorHandlerOptions, or as IHandshakeEncryptionKeyMaterial, ot as IRtcCarrierOptions, p as IActionProgress_Percentage, pn as ActionCore, pr as createStorageTofuVerifyKeyResolver, pt as IInMemoryServerEndpoint, q as createBinaryWireAdapter, qn as TSendReturnDataMethod, qr as TActionDomainSchema, qt as IConnectChannelOptions, r as IActionPayload_Base, ri as TActionSchemaOptions, rn as createBinaryWireSessionFactory, rr as IClientHandshakeConfig, rt as wsAcceptorCarrier, s as IActionPayload_Progress_JsonObject, sn as TAcceptorConnectionCaseFn, sr as IHandshakeResult, st as rtcCarrier, t as EActionPayloadType, ti as TInferActionError, tn as defineSecureChannel, tr as EHandshakeMessageType, tt as wsCarrier, u as IActionPayload_Result_JsonObject, un as createAcceptorHandler, ur as createClientHandshake, ut as IInMemoryCarrier, v as TActionResultOutcome, vn as createConnectorHandler, vr as ActionLocalHandler, vt as IActionFetchHandlerOptions, w as EErrId_NiceAction, wn as IActionTransportReadyData_Base, wr as IActionCore, wt as IServeChannelOptions, x as isActionPayload_Any_JsonObject, xn as IActionTransportDef, xr as RunningAction, xt as IExchangeAcceptorConfig, y as isActionPayload_Result_JsonObject, yn as ETransportShape, yr as createLocalHandler, yt as createActionFetchHandler, z as EErrId_NiceTransport, zn as TGetTransportFn, zr as IRuntimeFullCoordinates, zt as IHibernatableWsServerAdapterOptions } from "./ActionPayload.types-D0DM-g65.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 IAcceptorAttachmentStore, 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 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 IServeConnectionStateOptions, 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 TExchangeReply, type TExchangeRequest, 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, decodeExchangeReply, decodeExchangeRequest, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeExchange, 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,5 +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-
|
|
2
|
+
import { i as ETransportStatus, n as isExchangeAcceptorCarrier, r as ETransportShape, t as wsAcceptorCarrier } from "./wsAcceptorCarrier-CW2qX25W.mjs";
|
|
3
3
|
import { nanoid } from "nanoid";
|
|
4
4
|
import { NiceError, castNiceError, err, err_nice, isNiceErrorObject } from "@nice-code/error";
|
|
5
5
|
import { extractMessageFromStandardSchema } from "@nice-code/common-errors";
|
|
@@ -876,6 +876,10 @@ var ConnectionTransportManager = class {
|
|
|
876
876
|
const candidates = [];
|
|
877
877
|
const unavailableTransports = [];
|
|
878
878
|
for (const transport of this._transports) {
|
|
879
|
+
if (!transport.isAvailable(routeActionParams)) {
|
|
880
|
+
unavailableTransports.push(transport);
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
879
883
|
const cacheKey = transport.getCacheKey(routeActionParams);
|
|
880
884
|
if (cacheKey != null) {
|
|
881
885
|
const cached = this._cache.get(cacheKey);
|
|
@@ -3531,6 +3535,113 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
3531
3535
|
};
|
|
3532
3536
|
}
|
|
3533
3537
|
//#endregion
|
|
3538
|
+
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/ConnectionStateStore.ts
|
|
3539
|
+
/**
|
|
3540
|
+
* A typed per-connection state store that co-owns the app state and the acceptor handler's routing
|
|
3541
|
+
* binding in one attachment, so neither the consumer nor the handler has to hand-merge the two. Create
|
|
3542
|
+
* it through {@link createConnectionStateStore} (which also wires binding persistence and replays
|
|
3543
|
+
* surviving connections after a wake), then `get`/`set`/`clearApp` the app state directly.
|
|
3544
|
+
*
|
|
3545
|
+
* The mechanism is carrier-neutral — it only needs read/write/enumerate callbacks for the connection's
|
|
3546
|
+
* attachment — but it pays off on transports whose connections outlive process eviction (e.g. a
|
|
3547
|
+
* Durable Object's hibernatable WebSockets), which is why it lives beside the hibernation adapter.
|
|
3548
|
+
*
|
|
3549
|
+
* ```ts
|
|
3550
|
+
* const players = createConnectionStateStore(serverHandler, {
|
|
3551
|
+
* schema: vs_player,
|
|
3552
|
+
* read: (ws) => ws.deserializeAttachment(),
|
|
3553
|
+
* write: (ws, v) => ws.serializeAttachment(v),
|
|
3554
|
+
* getConnections: () => ctx.getWebSockets(),
|
|
3555
|
+
* });
|
|
3556
|
+
* players.set(ws, player); // binding is preserved automatically
|
|
3557
|
+
* const player = players.get(ws);
|
|
3558
|
+
* ```
|
|
3559
|
+
*/
|
|
3560
|
+
var ConnectionStateStore = class {
|
|
3561
|
+
options;
|
|
3562
|
+
constructor(options) {
|
|
3563
|
+
this.options = options;
|
|
3564
|
+
}
|
|
3565
|
+
/** The validated app state for a connection, or `null` if unset / invalid. */
|
|
3566
|
+
get(connection) {
|
|
3567
|
+
return this._readAttachment(connection).app ?? null;
|
|
3568
|
+
}
|
|
3569
|
+
/** Set the app state, preserving the runtime binding already pinned to the connection. */
|
|
3570
|
+
set(connection, app) {
|
|
3571
|
+
const existing = this._readAttachment(connection);
|
|
3572
|
+
this.options.write(connection, {
|
|
3573
|
+
app,
|
|
3574
|
+
binding: existing.binding
|
|
3575
|
+
});
|
|
3576
|
+
}
|
|
3577
|
+
/** Clear the app state but keep the binding (e.g. a spectator that stopped watching). */
|
|
3578
|
+
clearApp(connection) {
|
|
3579
|
+
const existing = this._readAttachment(connection);
|
|
3580
|
+
this.options.write(connection, { binding: existing.binding });
|
|
3581
|
+
}
|
|
3582
|
+
/** Every live connection paired with its (validated) app state — for rebuilding in-memory state after a wake. */
|
|
3583
|
+
entries() {
|
|
3584
|
+
return this.options.getConnections().map((connection) => [connection, this._readAttachment(connection).app ?? null]);
|
|
3585
|
+
}
|
|
3586
|
+
/** @internal Persist a freshly-bound connection's binding, preserving any app state already stored. */
|
|
3587
|
+
_persistBinding(connection, binding) {
|
|
3588
|
+
const existing = this._readAttachment(connection);
|
|
3589
|
+
this.options.write(connection, {
|
|
3590
|
+
app: existing.app,
|
|
3591
|
+
binding
|
|
3592
|
+
});
|
|
3593
|
+
}
|
|
3594
|
+
/** @internal The persisted binding for a connection, if any (used to replay routing after a wake). */
|
|
3595
|
+
_readBinding(connection) {
|
|
3596
|
+
return this._readAttachment(connection).binding;
|
|
3597
|
+
}
|
|
3598
|
+
_readAttachment(connection) {
|
|
3599
|
+
try {
|
|
3600
|
+
const raw = this.options.read(connection);
|
|
3601
|
+
if (typeof raw !== "object" || raw === null) return {};
|
|
3602
|
+
const attachment = raw;
|
|
3603
|
+
const result = {};
|
|
3604
|
+
if (attachment.binding != null) result.binding = attachment.binding;
|
|
3605
|
+
if (attachment.app !== void 0) {
|
|
3606
|
+
const app = this._validateApp(attachment.app);
|
|
3607
|
+
if (app !== void 0) result.app = app;
|
|
3608
|
+
}
|
|
3609
|
+
return result;
|
|
3610
|
+
} catch {
|
|
3611
|
+
return {};
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
_validateApp(value) {
|
|
3615
|
+
const schema = this.options.schema;
|
|
3616
|
+
if (schema == null) return value;
|
|
3617
|
+
const result = schema["~standard"].validate(value);
|
|
3618
|
+
if (result instanceof Promise) return void 0;
|
|
3619
|
+
if (result.issues != null) return void 0;
|
|
3620
|
+
return result.value;
|
|
3621
|
+
}
|
|
3622
|
+
};
|
|
3623
|
+
/**
|
|
3624
|
+
* Build a per-connection {@link ConnectionStateStore} bound to an {@link AcceptorHandler}: it registers
|
|
3625
|
+
* itself as the handler's connection-bound persistence callback (so bindings are written without
|
|
3626
|
+
* overwriting app state) and immediately replays every live connection's stored binding via
|
|
3627
|
+
* {@link AcceptorHandler.rehydrateConnection} — so on a transport that resumes after eviction (e.g. a
|
|
3628
|
+
* Durable Object waking from hibernation) both the app identity and the action routing come back from a
|
|
3629
|
+
* single attachment, with no storage reads and no hand-rolled merge.
|
|
3630
|
+
*
|
|
3631
|
+
* Lives outside the handler so the generic {@link AcceptorHandler} stays free of any attachment/
|
|
3632
|
+
* hibernation concern — it exposes only the neutral `setOnConnectionBound` + `rehydrateConnection`
|
|
3633
|
+
* hooks this builder drives.
|
|
3634
|
+
*/
|
|
3635
|
+
function createConnectionStateStore(handler, options) {
|
|
3636
|
+
const store = new ConnectionStateStore(options);
|
|
3637
|
+
handler.setOnConnectionBound((connection, binding) => store._persistBinding(connection, binding));
|
|
3638
|
+
for (const connection of options.getConnections()) {
|
|
3639
|
+
const binding = store._readBinding(connection);
|
|
3640
|
+
if (binding != null) handler.rehydrateConnection(connection, binding);
|
|
3641
|
+
}
|
|
3642
|
+
return store;
|
|
3643
|
+
}
|
|
3644
|
+
//#endregion
|
|
3534
3645
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/createHibernatableWsServerAdapter.ts
|
|
3535
3646
|
/**
|
|
3536
3647
|
* Wire the hibernation lifecycle for an acceptor handler on a transport whose connections outlive process
|
|
@@ -3569,34 +3680,14 @@ const DEFAULT_SERVER_SECURITY_LEVELS = [
|
|
|
3569
3680
|
"authenticated",
|
|
3570
3681
|
"encrypted"
|
|
3571
3682
|
];
|
|
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
3683
|
function serveChannel(runtime, channel, options) {
|
|
3596
3684
|
const duplexCarriers = options.carriers.filter((carrier) => !isExchangeAcceptorCarrier(carrier));
|
|
3597
3685
|
const exchangeCarriers = options.carriers.filter(isExchangeAcceptorCarrier);
|
|
3598
3686
|
if (exchangeCarriers.length > 1) throw new Error("serveChannel: at most one exchange carrier is supported");
|
|
3599
3687
|
const exchangeCarrier = exchangeCarriers[0];
|
|
3688
|
+
const singleDuplex = duplexCarriers.length === 1;
|
|
3689
|
+
if (options.connectionState != null && !singleDuplex) throw new Error("serveChannel: `connectionState` requires exactly one duplex carrier");
|
|
3690
|
+
if (options.channelCases != null && !singleDuplex) throw new Error("serveChannel: `channelCases` requires exactly one duplex carrier");
|
|
3600
3691
|
const exchangeSecure = exchangeCarrier != null && (exchangeCarrier.secure ?? true);
|
|
3601
3692
|
const anyDuplexSecure = duplexCarriers.some((carrier) => carrier.secure ?? true);
|
|
3602
3693
|
const securityLevel = options.securityLevel ?? DEFAULT_SERVER_SECURITY_LEVELS;
|
|
@@ -3610,7 +3701,13 @@ function serveChannel(runtime, channel, options) {
|
|
|
3610
3701
|
verifyKeyResolver: options.verifyKeyResolver ?? createStorageTofuVerifyKeyResolver(storage)
|
|
3611
3702
|
};
|
|
3612
3703
|
}
|
|
3704
|
+
const plainRouter = (handler) => ({
|
|
3705
|
+
receive: (connection, frame) => handler.receive(connection, frame),
|
|
3706
|
+
drop: (connection) => handler.dropConnection(connection)
|
|
3707
|
+
});
|
|
3708
|
+
const asObject = (value) => typeof value === "object" && value != null ? value : {};
|
|
3613
3709
|
const handlers = [];
|
|
3710
|
+
let connections;
|
|
3614
3711
|
for (const carrier of duplexCarriers) {
|
|
3615
3712
|
const handler = (carrier.secure ?? true) && secure != null ? acceptChannel(runtime, channel, {
|
|
3616
3713
|
clientEnv: options.clientEnv,
|
|
@@ -3627,17 +3724,31 @@ function serveChannel(runtime, channel, options) {
|
|
|
3627
3724
|
runtime,
|
|
3628
3725
|
defaultTimeout: options.defaultTimeout
|
|
3629
3726
|
});
|
|
3630
|
-
const
|
|
3727
|
+
const attach = carrier.attachmentStore;
|
|
3728
|
+
let router;
|
|
3729
|
+
if (attach == null) router = plainRouter(handler);
|
|
3730
|
+
else if (options.connectionState != null) {
|
|
3731
|
+
connections = createConnectionStateStore(handler, {
|
|
3732
|
+
schema: options.connectionState.schema,
|
|
3733
|
+
getConnections: attach.getConnections,
|
|
3734
|
+
read: attach.read,
|
|
3735
|
+
write: attach.write
|
|
3736
|
+
});
|
|
3737
|
+
router = plainRouter(handler);
|
|
3738
|
+
} else router = createHibernatableWsServerAdapter({
|
|
3631
3739
|
handler,
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3740
|
+
getConnections: attach.getConnections,
|
|
3741
|
+
getAttachment: (connection) => attach.read(connection)?.binding,
|
|
3742
|
+
setAttachment: (connection, binding) => attach.write(connection, {
|
|
3743
|
+
...asObject(attach.read(connection)),
|
|
3744
|
+
binding
|
|
3745
|
+
})
|
|
3746
|
+
});
|
|
3637
3747
|
carrier._activate(router);
|
|
3638
3748
|
handlers.push(handler);
|
|
3639
3749
|
}
|
|
3640
3750
|
runtime.addHandlers([...options.handlers ?? [], ...handlers]);
|
|
3751
|
+
if (options.channelCases != null) runtime.addHandlers([acceptChannelConnections(handlers[0], channel, options.channelCases)]);
|
|
3641
3752
|
const exchangeSecurity = exchangeSecure && secure != null ? {
|
|
3642
3753
|
link: secure.link,
|
|
3643
3754
|
verifyKeyResolver: secure.verifyKeyResolver,
|
|
@@ -3668,121 +3779,23 @@ function serveChannel(runtime, channel, options) {
|
|
|
3668
3779
|
if (owner == null) throw new Error("serveChannel: no duplex carrier holds a connection for the push target");
|
|
3669
3780
|
return owner.pushToClient(runtime, target, request, pushOptions);
|
|
3670
3781
|
};
|
|
3782
|
+
const broadcast = (makeRequest, broadcastOptions) => {
|
|
3783
|
+
if (!singleDuplex) throw new Error("serveChannel: broadcast requires exactly one duplex carrier — broadcast over a specific handlers[i] instead");
|
|
3784
|
+
handlers[0].broadcast(makeRequest, {
|
|
3785
|
+
runtime,
|
|
3786
|
+
...broadcastOptions
|
|
3787
|
+
});
|
|
3788
|
+
};
|
|
3671
3789
|
return {
|
|
3672
3790
|
handlers,
|
|
3673
3791
|
fetch,
|
|
3674
3792
|
duplex,
|
|
3675
|
-
pushToClient
|
|
3793
|
+
pushToClient,
|
|
3794
|
+
broadcast,
|
|
3795
|
+
connections
|
|
3676
3796
|
};
|
|
3677
3797
|
}
|
|
3678
3798
|
//#endregion
|
|
3679
|
-
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/ConnectionStateStore.ts
|
|
3680
|
-
/**
|
|
3681
|
-
* A typed per-connection state store that co-owns the app state and the acceptor handler's routing
|
|
3682
|
-
* binding in one attachment, so neither the consumer nor the handler has to hand-merge the two. Create
|
|
3683
|
-
* it through {@link createConnectionStateStore} (which also wires binding persistence and replays
|
|
3684
|
-
* surviving connections after a wake), then `get`/`set`/`clearApp` the app state directly.
|
|
3685
|
-
*
|
|
3686
|
-
* The mechanism is carrier-neutral — it only needs read/write/enumerate callbacks for the connection's
|
|
3687
|
-
* attachment — but it pays off on transports whose connections outlive process eviction (e.g. a
|
|
3688
|
-
* Durable Object's hibernatable WebSockets), which is why it lives beside the hibernation adapter.
|
|
3689
|
-
*
|
|
3690
|
-
* ```ts
|
|
3691
|
-
* const players = createConnectionStateStore(serverHandler, {
|
|
3692
|
-
* schema: vs_player,
|
|
3693
|
-
* read: (ws) => ws.deserializeAttachment(),
|
|
3694
|
-
* write: (ws, v) => ws.serializeAttachment(v),
|
|
3695
|
-
* getConnections: () => ctx.getWebSockets(),
|
|
3696
|
-
* });
|
|
3697
|
-
* players.set(ws, player); // binding is preserved automatically
|
|
3698
|
-
* const player = players.get(ws);
|
|
3699
|
-
* ```
|
|
3700
|
-
*/
|
|
3701
|
-
var ConnectionStateStore = class {
|
|
3702
|
-
options;
|
|
3703
|
-
constructor(options) {
|
|
3704
|
-
this.options = options;
|
|
3705
|
-
}
|
|
3706
|
-
/** The validated app state for a connection, or `null` if unset / invalid. */
|
|
3707
|
-
get(connection) {
|
|
3708
|
-
return this._readAttachment(connection).app ?? null;
|
|
3709
|
-
}
|
|
3710
|
-
/** Set the app state, preserving the runtime binding already pinned to the connection. */
|
|
3711
|
-
set(connection, app) {
|
|
3712
|
-
const existing = this._readAttachment(connection);
|
|
3713
|
-
this.options.write(connection, {
|
|
3714
|
-
app,
|
|
3715
|
-
binding: existing.binding
|
|
3716
|
-
});
|
|
3717
|
-
}
|
|
3718
|
-
/** Clear the app state but keep the binding (e.g. a spectator that stopped watching). */
|
|
3719
|
-
clearApp(connection) {
|
|
3720
|
-
const existing = this._readAttachment(connection);
|
|
3721
|
-
this.options.write(connection, { binding: existing.binding });
|
|
3722
|
-
}
|
|
3723
|
-
/** Every live connection paired with its (validated) app state — for rebuilding in-memory state after a wake. */
|
|
3724
|
-
entries() {
|
|
3725
|
-
return this.options.getConnections().map((connection) => [connection, this._readAttachment(connection).app ?? null]);
|
|
3726
|
-
}
|
|
3727
|
-
/** @internal Persist a freshly-bound connection's binding, preserving any app state already stored. */
|
|
3728
|
-
_persistBinding(connection, binding) {
|
|
3729
|
-
const existing = this._readAttachment(connection);
|
|
3730
|
-
this.options.write(connection, {
|
|
3731
|
-
app: existing.app,
|
|
3732
|
-
binding
|
|
3733
|
-
});
|
|
3734
|
-
}
|
|
3735
|
-
/** @internal The persisted binding for a connection, if any (used to replay routing after a wake). */
|
|
3736
|
-
_readBinding(connection) {
|
|
3737
|
-
return this._readAttachment(connection).binding;
|
|
3738
|
-
}
|
|
3739
|
-
_readAttachment(connection) {
|
|
3740
|
-
try {
|
|
3741
|
-
const raw = this.options.read(connection);
|
|
3742
|
-
if (typeof raw !== "object" || raw === null) return {};
|
|
3743
|
-
const attachment = raw;
|
|
3744
|
-
const result = {};
|
|
3745
|
-
if (attachment.binding != null) result.binding = attachment.binding;
|
|
3746
|
-
if (attachment.app !== void 0) {
|
|
3747
|
-
const app = this._validateApp(attachment.app);
|
|
3748
|
-
if (app !== void 0) result.app = app;
|
|
3749
|
-
}
|
|
3750
|
-
return result;
|
|
3751
|
-
} catch {
|
|
3752
|
-
return {};
|
|
3753
|
-
}
|
|
3754
|
-
}
|
|
3755
|
-
_validateApp(value) {
|
|
3756
|
-
const schema = this.options.schema;
|
|
3757
|
-
if (schema == null) return value;
|
|
3758
|
-
const result = schema["~standard"].validate(value);
|
|
3759
|
-
if (result instanceof Promise) return void 0;
|
|
3760
|
-
if (result.issues != null) return void 0;
|
|
3761
|
-
return result.value;
|
|
3762
|
-
}
|
|
3763
|
-
};
|
|
3764
|
-
/**
|
|
3765
|
-
* Build a per-connection {@link ConnectionStateStore} bound to an {@link AcceptorHandler}: it registers
|
|
3766
|
-
* itself as the handler's connection-bound persistence callback (so bindings are written without
|
|
3767
|
-
* overwriting app state) and immediately replays every live connection's stored binding via
|
|
3768
|
-
* {@link AcceptorHandler.rehydrateConnection} — so on a transport that resumes after eviction (e.g. a
|
|
3769
|
-
* Durable Object waking from hibernation) both the app identity and the action routing come back from a
|
|
3770
|
-
* single attachment, with no storage reads and no hand-rolled merge.
|
|
3771
|
-
*
|
|
3772
|
-
* Lives outside the handler so the generic {@link AcceptorHandler} stays free of any attachment/
|
|
3773
|
-
* hibernation concern — it exposes only the neutral `setOnConnectionBound` + `rehydrateConnection`
|
|
3774
|
-
* hooks this builder drives.
|
|
3775
|
-
*/
|
|
3776
|
-
function createConnectionStateStore(handler, options) {
|
|
3777
|
-
const store = new ConnectionStateStore(options);
|
|
3778
|
-
handler.setOnConnectionBound((connection, binding) => store._persistBinding(connection, binding));
|
|
3779
|
-
for (const connection of options.getConnections()) {
|
|
3780
|
-
const binding = store._readBinding(connection);
|
|
3781
|
-
if (binding != null) handler.rehydrateConnection(connection, binding);
|
|
3782
|
-
}
|
|
3783
|
-
return store;
|
|
3784
|
-
}
|
|
3785
|
-
//#endregion
|
|
3786
3799
|
//#region src/ActionRuntime/Transport/Carrier/duplex/inMemory/createInMemoryChannel.ts
|
|
3787
3800
|
/**
|
|
3788
3801
|
* Two cross-wired in-process byte channels — a loopback carrier with no socket. The client end is a
|
|
@@ -4437,6 +4450,15 @@ var TransportConnection = class {
|
|
|
4437
4450
|
if (inner == null) return null;
|
|
4438
4451
|
return `${this.transOrd}:${inner}`;
|
|
4439
4452
|
}
|
|
4453
|
+
/**
|
|
4454
|
+
* Whether this transport can serve the given action right now. Consulted by the manager before
|
|
4455
|
+
* cache-key resolution and `getTransport`; a `false` result skips this transport (treated as
|
|
4456
|
+
* `unsupported`) and the manager falls through to the next in preference order. Defaults to `true`
|
|
4457
|
+
* when the transport declares no gate.
|
|
4458
|
+
*/
|
|
4459
|
+
isAvailable(input) {
|
|
4460
|
+
return this.initialized.isAvailable?.(input) ?? true;
|
|
4461
|
+
}
|
|
4440
4462
|
getTransport(input) {
|
|
4441
4463
|
return this._processTransportStatus(input);
|
|
4442
4464
|
}
|
|
@@ -4533,6 +4555,7 @@ var ExchangeTransport = class ExchangeTransport extends Transport {
|
|
|
4533
4555
|
const options = this.options;
|
|
4534
4556
|
return new ExchangeConnection({ initialize: () => ({
|
|
4535
4557
|
getTransportCacheKey: options.getTransportCacheKey,
|
|
4558
|
+
isAvailable: options.available,
|
|
4536
4559
|
getTransport: (input) => ({
|
|
4537
4560
|
status: "ready",
|
|
4538
4561
|
readyData: {
|
|
@@ -4781,6 +4804,7 @@ var LinkTransport = class LinkTransport extends Transport {
|
|
|
4781
4804
|
const options = this.options;
|
|
4782
4805
|
return new LinkConnection({ initialize: () => ({
|
|
4783
4806
|
getTransportCacheKey: options.getTransportCacheKey,
|
|
4807
|
+
isAvailable: options.available,
|
|
4784
4808
|
getTransport: (input) => ({
|
|
4785
4809
|
status: "ready",
|
|
4786
4810
|
readyData: {
|
|
@@ -4817,6 +4841,7 @@ function plainTransport(options) {
|
|
|
4817
4841
|
if (isExchangeCarrierSource(carrier)) return ExchangeTransport.create({
|
|
4818
4842
|
openCarrier: carrier.open,
|
|
4819
4843
|
getTransportCacheKey: carrier.getCacheKey,
|
|
4844
|
+
available: options.available,
|
|
4820
4845
|
getRouteInfo: carrier.getRouteInfo,
|
|
4821
4846
|
label: options.label ?? carrier.carrierLabel,
|
|
4822
4847
|
updateRunConfig: options.updateRunConfig
|
|
@@ -4826,6 +4851,7 @@ function plainTransport(options) {
|
|
|
4826
4851
|
formatMessage: options.formatMessage,
|
|
4827
4852
|
createFormatMessage: options.createFormatMessage,
|
|
4828
4853
|
getTransportCacheKey: carrier.getCacheKey,
|
|
4854
|
+
available: options.available,
|
|
4829
4855
|
getRouteInfo: carrier.getRouteInfo,
|
|
4830
4856
|
label: options.label ?? carrier.carrierLabel,
|
|
4831
4857
|
updateRunConfig: options.updateRunConfig
|
|
@@ -4845,6 +4871,7 @@ function secureTransport(options) {
|
|
|
4845
4871
|
if (isExchangeCarrierSource(carrier)) return ExchangeTransport.create({
|
|
4846
4872
|
openCarrier: carrier.open,
|
|
4847
4873
|
getTransportCacheKey: carrier.getCacheKey,
|
|
4874
|
+
available: options.available,
|
|
4848
4875
|
getRouteInfo: carrier.getRouteInfo,
|
|
4849
4876
|
label: carrier.carrierLabel,
|
|
4850
4877
|
security
|
|
@@ -4853,12 +4880,13 @@ function secureTransport(options) {
|
|
|
4853
4880
|
openChannel: carrier.open,
|
|
4854
4881
|
createFormatMessage: options.channel.createCodec,
|
|
4855
4882
|
getTransportCacheKey: carrier.getCacheKey,
|
|
4883
|
+
available: options.available,
|
|
4856
4884
|
getRouteInfo: carrier.getRouteInfo,
|
|
4857
4885
|
label: carrier.carrierLabel,
|
|
4858
4886
|
security
|
|
4859
4887
|
});
|
|
4860
4888
|
}
|
|
4861
4889
|
//#endregion
|
|
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 };
|
|
4890
|
+
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, decodeExchangeReply, decodeExchangeRequest, decodeHandshakeMessage, defineChannel, defineSecureChannel, encodeExchange, 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 };
|
|
4863
4891
|
|
|
4864
4892
|
//# sourceMappingURL=index.mjs.map
|