11import { RpcMessageFormat } from '../constants' ;
2- import { RpcError , RpcErrorCodes } from '../../rpc/caller/error' ;
2+ import { RpcError , RpcErrorCodes } from '../../rpc/caller/error/RpcError ' ;
33import * as msg from '../../messages' ;
44import { CompactMessageType } from './constants' ;
55import { RpcValue } from '../../messages/Value' ;
6+ import { TypedRpcError } from '../../rpc/caller/error/typed' ;
67import type { JsonEncoder } from '@jsonjoy.com/json-pack/lib/json/JsonEncoder' ;
78import type { RpcMessageCodec } from '../types' ;
89import type { JsonValueCodec } from '@jsonjoy.com/json-pack/lib/codecs/types' ;
@@ -47,7 +48,7 @@ const fromJson = (arr: unknown | unknown[] | types.CompactMessage): msg.Reactive
4748 return new msg . NotificationMessage ( arr [ 1 ] , new RpcValue ( arr [ 2 ] , undefined ) ) ;
4849 }
4950 }
50- throw RpcError . value ( RpcError . validation ( 'Unknown message type' ) ) ;
51+ throw TypedRpcError . value ( RpcError . validation ( 'Unknown message type' ) ) ;
5152} ;
5253
5354const encodeCompactWithNameAndPayload = (
@@ -68,7 +69,10 @@ const encodeCompactWithNameAndPayload = (
6869 if ( value . type ) value . type . encoder ( codec . format ) ( value . data , encoder ) ;
6970 else encoder . writeAny ( value . data ) ;
7071 }
71- } else if ( typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' && typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function' ) {
72+ } else if (
73+ typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' &&
74+ typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function'
75+ ) {
7276 const jsonEncoder = encoder as any as JsonEncoder ;
7377 const value = msg . value ;
7478 jsonEncoder . writeStartArr ( ) ;
@@ -105,7 +109,10 @@ const encodeCompactWithPayload = (
105109 value . type . encoder ( codec . format ) ( value . data , encoder ) ;
106110 } else encoder . writeAny ( value . data ) ;
107111 }
108- } else if ( typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' && typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function' ) {
112+ } else if (
113+ typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' &&
114+ typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function'
115+ ) {
109116 const jsonEncoder = encoder as any as JsonEncoder ;
110117 const value = msg . value ;
111118 jsonEncoder . writeStartArr ( ) ;
@@ -140,7 +147,10 @@ export class CompactRpcMessageCodec implements RpcMessageCodec {
140147 if ( value . type ) value . type . encoder ( codec . format ) ( value . data , encoder ) ;
141148 else encoder . writeAny ( value . data ) ;
142149 }
143- } else if ( typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' && typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function' ) {
150+ } else if (
151+ typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' &&
152+ typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function'
153+ ) {
144154 const jsonEncoder = encoder as any as JsonEncoder ;
145155 const value = message . value ;
146156 jsonEncoder . writeStartArr ( ) ;
@@ -183,7 +193,10 @@ export class CompactRpcMessageCodec implements RpcMessageCodec {
183193 const length = batch . length ;
184194 binaryEncoder . writeArrHdr ( length ) ;
185195 for ( let i = 0 ; i < length ; i ++ ) this . encodeMessage ( jsonCodec , batch [ i ] ) ;
186- } else if ( typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' && typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function' ) {
196+ } else if (
197+ typeof ( encoder as any as JsonEncoder ) . writeStartArr === 'function' &&
198+ typeof ( encoder as any as JsonEncoder ) . writeArrSeparator === 'function'
199+ ) {
187200 const jsonEncoder = encoder as any as JsonEncoder ;
188201 const length = batch . length ;
189202 const last = length - 1 ;
0 commit comments