@nice-code/action 0.19.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 -666
- package/build/{ActionDevtoolsCore-CCZXQBAo.d.cts → ActionDevtoolsCore-D_JvgPmz.d.mts} +2 -2
- package/build/{ActionDevtoolsCore-bjYQ8O2_.d.mts → ActionDevtoolsCore-dV-IVPcP.d.cts} +2 -2
- package/build/{ActionPayload.types-Bmkzw2df.d.mts → ActionPayload.types-CnfWlkA1.d.cts} +161 -106
- package/build/{ActionPayload.types-CdHOGGZK.d.cts → ActionPayload.types-D0DM-g65.d.mts} +161 -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 +147 -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 +147 -138
- 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 httpAcceptorCarrier, $n 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 httpAcceptorCarrier, $n 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";
|
|
@@ -3535,6 +3535,113 @@ function createActionFetchHandler(runtime, options = {}) {
|
|
|
3535
3535
|
};
|
|
3536
3536
|
}
|
|
3537
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
|
|
3538
3645
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/createHibernatableWsServerAdapter.ts
|
|
3539
3646
|
/**
|
|
3540
3647
|
* Wire the hibernation lifecycle for an acceptor handler on a transport whose connections outlive process
|
|
@@ -3573,34 +3680,14 @@ const DEFAULT_SERVER_SECURITY_LEVELS = [
|
|
|
3573
3680
|
"authenticated",
|
|
3574
3681
|
"encrypted"
|
|
3575
3682
|
];
|
|
3576
|
-
/**
|
|
3577
|
-
* Serve a secure channel over one or more carriers from a single call — the accept-in dual of
|
|
3578
|
-
* `connectChannel`. It builds the crypto identity (a {@link ClientCryptoKeyLink} + a storage-backed TOFU
|
|
3579
|
-
* resolver) and the security block (coordinate, dictionary version, accepted levels) *once* from
|
|
3580
|
-
* `(runtime, channel)` and fans them across every carrier, so the WebSocket and the secure-HTTP endpoint
|
|
3581
|
-
* can never drift apart. It registers your handlers (plus the duplex acceptor it builds) on the runtime,
|
|
3582
|
-
* wires hibernation when the duplex carrier declares it, and returns a single {@link IChannelServer} whose
|
|
3583
|
-
* `fetch` / `duplex` / `pushToClient` you forward straight to the host:
|
|
3584
|
-
* ```ts
|
|
3585
|
-
* const server = serveChannel(runtime, channel, {
|
|
3586
|
-
* clientEnv, storage,
|
|
3587
|
-
* carriers: [wsAcceptorCarrier({ send, upgrade, hibernation }), httpAcceptorCarrier()],
|
|
3588
|
-
* handlers: [localHandler],
|
|
3589
|
-
* });
|
|
3590
|
-
* // fetch(req) => server.fetch(req)
|
|
3591
|
-
* // webSocketMessage(conn, m) => server.duplex?.receive(conn, m)
|
|
3592
|
-
* // webSocketClose/Error(conn) => server.duplex?.drop(conn)
|
|
3593
|
-
* ```
|
|
3594
|
-
*
|
|
3595
|
-
* `TConn` (the live-connection token a duplex carrier hands back through `send`/`receive`/`drop`) is
|
|
3596
|
-
* inferred from the carriers — `WebSocket` for `wsAcceptorCarrier`, the data-channel type for a WebRTC
|
|
3597
|
-
* carrier, and so on — so it stays carrier-agnostic.
|
|
3598
|
-
*/
|
|
3599
3683
|
function serveChannel(runtime, channel, options) {
|
|
3600
3684
|
const duplexCarriers = options.carriers.filter((carrier) => !isExchangeAcceptorCarrier(carrier));
|
|
3601
3685
|
const exchangeCarriers = options.carriers.filter(isExchangeAcceptorCarrier);
|
|
3602
3686
|
if (exchangeCarriers.length > 1) throw new Error("serveChannel: at most one exchange carrier is supported");
|
|
3603
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");
|
|
3604
3691
|
const exchangeSecure = exchangeCarrier != null && (exchangeCarrier.secure ?? true);
|
|
3605
3692
|
const anyDuplexSecure = duplexCarriers.some((carrier) => carrier.secure ?? true);
|
|
3606
3693
|
const securityLevel = options.securityLevel ?? DEFAULT_SERVER_SECURITY_LEVELS;
|
|
@@ -3614,7 +3701,13 @@ function serveChannel(runtime, channel, options) {
|
|
|
3614
3701
|
verifyKeyResolver: options.verifyKeyResolver ?? createStorageTofuVerifyKeyResolver(storage)
|
|
3615
3702
|
};
|
|
3616
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 : {};
|
|
3617
3709
|
const handlers = [];
|
|
3710
|
+
let connections;
|
|
3618
3711
|
for (const carrier of duplexCarriers) {
|
|
3619
3712
|
const handler = (carrier.secure ?? true) && secure != null ? acceptChannel(runtime, channel, {
|
|
3620
3713
|
clientEnv: options.clientEnv,
|
|
@@ -3631,17 +3724,31 @@ function serveChannel(runtime, channel, options) {
|
|
|
3631
3724
|
runtime,
|
|
3632
3725
|
defaultTimeout: options.defaultTimeout
|
|
3633
3726
|
});
|
|
3634
|
-
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({
|
|
3635
3739
|
handler,
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
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
|
+
});
|
|
3641
3747
|
carrier._activate(router);
|
|
3642
3748
|
handlers.push(handler);
|
|
3643
3749
|
}
|
|
3644
3750
|
runtime.addHandlers([...options.handlers ?? [], ...handlers]);
|
|
3751
|
+
if (options.channelCases != null) runtime.addHandlers([acceptChannelConnections(handlers[0], channel, options.channelCases)]);
|
|
3645
3752
|
const exchangeSecurity = exchangeSecure && secure != null ? {
|
|
3646
3753
|
link: secure.link,
|
|
3647
3754
|
verifyKeyResolver: secure.verifyKeyResolver,
|
|
@@ -3672,121 +3779,23 @@ function serveChannel(runtime, channel, options) {
|
|
|
3672
3779
|
if (owner == null) throw new Error("serveChannel: no duplex carrier holds a connection for the push target");
|
|
3673
3780
|
return owner.pushToClient(runtime, target, request, pushOptions);
|
|
3674
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
|
+
};
|
|
3675
3789
|
return {
|
|
3676
3790
|
handlers,
|
|
3677
3791
|
fetch,
|
|
3678
3792
|
duplex,
|
|
3679
|
-
pushToClient
|
|
3793
|
+
pushToClient,
|
|
3794
|
+
broadcast,
|
|
3795
|
+
connections
|
|
3680
3796
|
};
|
|
3681
3797
|
}
|
|
3682
3798
|
//#endregion
|
|
3683
|
-
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/Hibernation/ConnectionStateStore.ts
|
|
3684
|
-
/**
|
|
3685
|
-
* A typed per-connection state store that co-owns the app state and the acceptor handler's routing
|
|
3686
|
-
* binding in one attachment, so neither the consumer nor the handler has to hand-merge the two. Create
|
|
3687
|
-
* it through {@link createConnectionStateStore} (which also wires binding persistence and replays
|
|
3688
|
-
* surviving connections after a wake), then `get`/`set`/`clearApp` the app state directly.
|
|
3689
|
-
*
|
|
3690
|
-
* The mechanism is carrier-neutral — it only needs read/write/enumerate callbacks for the connection's
|
|
3691
|
-
* attachment — but it pays off on transports whose connections outlive process eviction (e.g. a
|
|
3692
|
-
* Durable Object's hibernatable WebSockets), which is why it lives beside the hibernation adapter.
|
|
3693
|
-
*
|
|
3694
|
-
* ```ts
|
|
3695
|
-
* const players = createConnectionStateStore(serverHandler, {
|
|
3696
|
-
* schema: vs_player,
|
|
3697
|
-
* read: (ws) => ws.deserializeAttachment(),
|
|
3698
|
-
* write: (ws, v) => ws.serializeAttachment(v),
|
|
3699
|
-
* getConnections: () => ctx.getWebSockets(),
|
|
3700
|
-
* });
|
|
3701
|
-
* players.set(ws, player); // binding is preserved automatically
|
|
3702
|
-
* const player = players.get(ws);
|
|
3703
|
-
* ```
|
|
3704
|
-
*/
|
|
3705
|
-
var ConnectionStateStore = class {
|
|
3706
|
-
options;
|
|
3707
|
-
constructor(options) {
|
|
3708
|
-
this.options = options;
|
|
3709
|
-
}
|
|
3710
|
-
/** The validated app state for a connection, or `null` if unset / invalid. */
|
|
3711
|
-
get(connection) {
|
|
3712
|
-
return this._readAttachment(connection).app ?? null;
|
|
3713
|
-
}
|
|
3714
|
-
/** Set the app state, preserving the runtime binding already pinned to the connection. */
|
|
3715
|
-
set(connection, app) {
|
|
3716
|
-
const existing = this._readAttachment(connection);
|
|
3717
|
-
this.options.write(connection, {
|
|
3718
|
-
app,
|
|
3719
|
-
binding: existing.binding
|
|
3720
|
-
});
|
|
3721
|
-
}
|
|
3722
|
-
/** Clear the app state but keep the binding (e.g. a spectator that stopped watching). */
|
|
3723
|
-
clearApp(connection) {
|
|
3724
|
-
const existing = this._readAttachment(connection);
|
|
3725
|
-
this.options.write(connection, { binding: existing.binding });
|
|
3726
|
-
}
|
|
3727
|
-
/** Every live connection paired with its (validated) app state — for rebuilding in-memory state after a wake. */
|
|
3728
|
-
entries() {
|
|
3729
|
-
return this.options.getConnections().map((connection) => [connection, this._readAttachment(connection).app ?? null]);
|
|
3730
|
-
}
|
|
3731
|
-
/** @internal Persist a freshly-bound connection's binding, preserving any app state already stored. */
|
|
3732
|
-
_persistBinding(connection, binding) {
|
|
3733
|
-
const existing = this._readAttachment(connection);
|
|
3734
|
-
this.options.write(connection, {
|
|
3735
|
-
app: existing.app,
|
|
3736
|
-
binding
|
|
3737
|
-
});
|
|
3738
|
-
}
|
|
3739
|
-
/** @internal The persisted binding for a connection, if any (used to replay routing after a wake). */
|
|
3740
|
-
_readBinding(connection) {
|
|
3741
|
-
return this._readAttachment(connection).binding;
|
|
3742
|
-
}
|
|
3743
|
-
_readAttachment(connection) {
|
|
3744
|
-
try {
|
|
3745
|
-
const raw = this.options.read(connection);
|
|
3746
|
-
if (typeof raw !== "object" || raw === null) return {};
|
|
3747
|
-
const attachment = raw;
|
|
3748
|
-
const result = {};
|
|
3749
|
-
if (attachment.binding != null) result.binding = attachment.binding;
|
|
3750
|
-
if (attachment.app !== void 0) {
|
|
3751
|
-
const app = this._validateApp(attachment.app);
|
|
3752
|
-
if (app !== void 0) result.app = app;
|
|
3753
|
-
}
|
|
3754
|
-
return result;
|
|
3755
|
-
} catch {
|
|
3756
|
-
return {};
|
|
3757
|
-
}
|
|
3758
|
-
}
|
|
3759
|
-
_validateApp(value) {
|
|
3760
|
-
const schema = this.options.schema;
|
|
3761
|
-
if (schema == null) return value;
|
|
3762
|
-
const result = schema["~standard"].validate(value);
|
|
3763
|
-
if (result instanceof Promise) return void 0;
|
|
3764
|
-
if (result.issues != null) return void 0;
|
|
3765
|
-
return result.value;
|
|
3766
|
-
}
|
|
3767
|
-
};
|
|
3768
|
-
/**
|
|
3769
|
-
* Build a per-connection {@link ConnectionStateStore} bound to an {@link AcceptorHandler}: it registers
|
|
3770
|
-
* itself as the handler's connection-bound persistence callback (so bindings are written without
|
|
3771
|
-
* overwriting app state) and immediately replays every live connection's stored binding via
|
|
3772
|
-
* {@link AcceptorHandler.rehydrateConnection} — so on a transport that resumes after eviction (e.g. a
|
|
3773
|
-
* Durable Object waking from hibernation) both the app identity and the action routing come back from a
|
|
3774
|
-
* single attachment, with no storage reads and no hand-rolled merge.
|
|
3775
|
-
*
|
|
3776
|
-
* Lives outside the handler so the generic {@link AcceptorHandler} stays free of any attachment/
|
|
3777
|
-
* hibernation concern — it exposes only the neutral `setOnConnectionBound` + `rehydrateConnection`
|
|
3778
|
-
* hooks this builder drives.
|
|
3779
|
-
*/
|
|
3780
|
-
function createConnectionStateStore(handler, options) {
|
|
3781
|
-
const store = new ConnectionStateStore(options);
|
|
3782
|
-
handler.setOnConnectionBound((connection, binding) => store._persistBinding(connection, binding));
|
|
3783
|
-
for (const connection of options.getConnections()) {
|
|
3784
|
-
const binding = store._readBinding(connection);
|
|
3785
|
-
if (binding != null) handler.rehydrateConnection(connection, binding);
|
|
3786
|
-
}
|
|
3787
|
-
return store;
|
|
3788
|
-
}
|
|
3789
|
-
//#endregion
|
|
3790
3799
|
//#region src/ActionRuntime/Transport/Carrier/duplex/inMemory/createInMemoryChannel.ts
|
|
3791
3800
|
/**
|
|
3792
3801
|
* Two cross-wired in-process byte channels — a loopback carrier with no socket. The client end is a
|