@nmtjs/protocol 0.6.5 → 0.7.1
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/dist/client/events.js +29 -26
- package/dist/client/events.js.map +1 -1
- package/dist/client/format.js +1 -2
- package/dist/client/format.js.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/protocol.js +331 -336
- package/dist/client/protocol.js.map +1 -1
- package/dist/client/stream.js +79 -92
- package/dist/client/stream.js.map +1 -1
- package/dist/common/binary.js +20 -20
- package/dist/common/binary.js.map +1 -1
- package/dist/common/blob.js +36 -40
- package/dist/common/blob.js.map +1 -1
- package/dist/common/enums.js +44 -44
- package/dist/common/enums.js.map +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/common/types.js +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/server/api.js +1 -1
- package/dist/server/api.js.map +1 -1
- package/dist/server/connection.js +18 -18
- package/dist/server/connection.js.map +1 -1
- package/dist/server/constants.js +1 -1
- package/dist/server/constants.js.map +1 -1
- package/dist/server/format.js +42 -45
- package/dist/server/format.js.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/injectables.js +18 -18
- package/dist/server/injectables.js.map +1 -1
- package/dist/server/protocol.js +282 -296
- package/dist/server/protocol.js.map +1 -1
- package/dist/server/registry.js +2 -19
- package/dist/server/registry.js.map +1 -1
- package/dist/server/stream.js +24 -26
- package/dist/server/stream.js.map +1 -1
- package/dist/server/transport.js +6 -6
- package/dist/server/transport.js.map +1 -1
- package/dist/server/utils.js +9 -9
- package/dist/server/utils.js.map +1 -1
- package/package.json +12 -16
- package/{lib → src}/client/protocol.ts +4 -3
- package/{lib → src}/client/stream.ts +18 -26
- package/{lib → src}/server/connection.ts +1 -1
- package/{lib → src}/server/protocol.ts +18 -8
- package/src/server/registry.ts +3 -0
- package/lib/server/registry.ts +0 -24
- /package/{lib → src}/client/events.ts +0 -0
- /package/{lib → src}/client/format.ts +0 -0
- /package/{lib → src}/client/index.ts +0 -0
- /package/{lib → src}/common/binary.ts +0 -0
- /package/{lib → src}/common/blob.ts +0 -0
- /package/{lib → src}/common/enums.ts +0 -0
- /package/{lib → src}/common/index.ts +0 -0
- /package/{lib → src}/common/types.ts +0 -0
- /package/{lib → src}/server/api.ts +0 -0
- /package/{lib → src}/server/constants.ts +0 -0
- /package/{lib → src}/server/format.ts +0 -0
- /package/{lib → src}/server/index.ts +0 -0
- /package/{lib → src}/server/injectables.ts +0 -0
- /package/{lib → src}/server/stream.ts +0 -0
- /package/{lib → src}/server/transport.ts +0 -0
- /package/{lib → src}/server/utils.ts +0 -0
package/dist/common/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"","names":[],"sources":["src/common/types.ts"],"sourcesContent":["import type { ProtocolServerBlobStream } from '../client/stream.ts'\nimport type {\n ProtocolBlob,\n ProtocolBlobInterface,\n ProtocolBlobMetadata,\n} from './blob.ts'\n\nexport type ProtocolRPC = {\n callId: number\n namespace: string\n procedure: string\n payload: any\n}\n\nexport type ProtocolRPCResponse =\n | {\n callId: number\n error: any\n payload?: never\n }\n | {\n callId: number\n payload: any\n error?: never\n }\n\nexport interface EncodeRPCContext {\n getStream: (id: number) => any\n addStream: (blob: ProtocolBlob) => {\n id: number\n metadata: ProtocolBlobMetadata\n }\n}\n\nexport interface DecodeRPCContext {\n getStream: (id: number) => any\n addStream: (id: number, metadata: ProtocolBlobMetadata) => any\n}\n\nexport interface BaseClientDecoder {\n decode(buffer: ArrayBuffer): any\n decodeRPC(buffer: ArrayBuffer, context: DecodeRPCContext): ProtocolRPCResponse\n}\n\nexport interface BaseClientEncoder {\n encode(data: any): ArrayBuffer\n encodeRPC(rpc: ProtocolRPC, context: EncodeRPCContext): ArrayBuffer\n}\n\nexport type InputType<T> = T extends any[]\n ? InputType<T[number]>[]\n : T extends ProtocolBlobInterface\n ? ProtocolBlob\n : T extends object\n ? { [K in keyof T]: InputType<T[K]> }\n : T\n\nexport type OutputType<T> = T extends any[]\n ? OutputType<T[number]>[]\n : T extends ProtocolBlobInterface\n ? ProtocolServerBlobStream\n : T extends object\n ? { [K in keyof T]: OutputType<T[K]> }\n : T\n"],"version":3}
|
package/dist/server/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
package/dist/server/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"","names":[],"sources":["src/server/api.ts"],"sourcesContent":["import type { Container } from '@nmtjs/core'\nimport type { Hook } from '@nmtjs/core'\nimport type { Connection } from './connection.ts'\n\nexport type ProtocolApiCallOptions = {\n connection: Connection\n namespace: string\n procedure: string\n container: Container\n payload: any\n signal: AbortSignal\n}\n\nexport type ProtocolAnyIterable<T> =\n | (() => AsyncGenerator<T>)\n | AsyncIterable<T>\n\nexport interface ProtocolApiCallBaseResult {\n output: unknown\n}\nexport interface ProtocolApiCallSubscriptionResult\n extends ProtocolApiCallBaseResult {\n subscription: never\n}\n\nexport interface ProtocolApiCallIterableResult\n extends ProtocolApiCallBaseResult {\n iterable: ProtocolAnyIterable<unknown>\n onFinish?: () => void\n}\n\nexport type ProtocolApiCallResult =\n | ProtocolApiCallBaseResult\n | ProtocolApiCallSubscriptionResult\n | ProtocolApiCallIterableResult\n\nexport interface ProtocolApi {\n call(options: ProtocolApiCallOptions): Promise<ProtocolApiCallResult>\n}\n\ndeclare module '@nmtjs/core' {\n export interface HookType {\n [Hook.OnConnect]: (connection: Connection) => any\n [Hook.OnDisconnect]: (connection: Connection) => any\n }\n}\n"],"version":3}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { randomUUID } from
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
2
|
export class Connection {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
id;
|
|
4
|
+
data;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.id = options.id ?? randomUUID();
|
|
7
|
+
this.data = options.data;
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
10
|
export class ConnectionContext {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
streamId = 1;
|
|
12
|
+
calls = new Map();
|
|
13
|
+
clientStreams = new Map();
|
|
14
|
+
serverStreams = new Map();
|
|
15
|
+
rpcStreams = new Map();
|
|
16
|
+
container;
|
|
17
|
+
format;
|
|
18
|
+
constructor(container, format) {
|
|
19
|
+
this.container = container;
|
|
20
|
+
this.format = format;
|
|
21
|
+
}
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"AAAA,SAAS,kBAAkB,aAAa;AAYxC,OAAO,MAAM,WAA2B;CACtC,AAAS;CACT,AAAS;CAET,YAAYA,SAAkC;AAC5C,OAAK,KAAK,QAAQ,MAAM,YAAY;AACpC,OAAK,OAAO,QAAQ;CACrB;AACF;AAMD,OAAO,MAAM,kBAAkB;CAC7B,WAAW;CACX,QAAQ,IAAI;CACZ,gBAAgB,IAAI;CACpB,gBAAgB,IAAI;CACpB,aAAa,IAAI;CACjB;CACA;CAKA,YACEC,WACAC,QACA;AACA,OAAK,YAAY;AACjB,OAAK,SAAS;CACf;AACF","names":["options: ConnectionOptions<Data>","container: ConnectionContext['container']","format: ConnectionContext['format']"],"sources":["src/server/connection.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\nimport type { Container } from '@nmtjs/core'\nimport type { InteractivePromise } from '../../../common/src/index.ts'\nimport type { ProtocolApiCallResult } from './api.ts'\nimport type { BaseServerDecoder, BaseServerEncoder } from './format.ts'\nimport type { ProtocolClientStream, ProtocolServerStream } from './stream.ts'\n\nexport type ConnectionOptions<Data = unknown> = {\n id?: string\n data: Data\n}\n\nexport class Connection<Data = unknown> {\n readonly id: string\n readonly data: Data\n\n constructor(options: ConnectionOptions<Data>) {\n this.id = options.id ?? randomUUID()\n this.data = options.data\n }\n}\n\nexport type ConnectionCall<T = unknown> = InteractivePromise<T> & {\n abort: AbortController['abort']\n}\n\nexport class ConnectionContext {\n streamId = 1\n calls = new Map<number, ConnectionCall<ProtocolApiCallResult>>()\n clientStreams = new Map<number, ProtocolClientStream>()\n serverStreams = new Map<number, ProtocolServerStream>()\n rpcStreams = new Map<number, AbortController>()\n container: Container\n format: {\n encoder: BaseServerEncoder\n decoder: BaseServerDecoder\n }\n\n constructor(\n container: ConnectionContext['container'],\n format: ConnectionContext['format'],\n ) {\n this.container = container\n this.format = format\n }\n}\n"],"version":3}
|
package/dist/server/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const kTransportPlugin = Symbol.for(
|
|
1
|
+
export const kTransportPlugin = Symbol.for("neemata:TransportPluginKey");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"AAAA,OAAO,MAAMA,mBAAkC,OAAO,IACpD,6BACD","names":["kTransportPlugin: unique symbol"],"sources":["src/server/constants.ts"],"sourcesContent":["export const kTransportPlugin: unique symbol = Symbol.for(\n 'neemata:TransportPluginKey',\n)\nexport type kTransportPlugin = typeof kTransportPlugin\n"],"version":3}
|
package/dist/server/format.js
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
import { match } from
|
|
2
|
-
export class BaseServerFormat {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (b.type === '*/*') return -1;
|
|
18
|
-
return b.q - a.q ? -1 : 1;
|
|
19
|
-
}).map((t)=>t.type);
|
|
1
|
+
import { match } from "@nmtjs/core";
|
|
2
|
+
export class BaseServerFormat {}
|
|
3
|
+
export const parseContentTypes = (types) => {
|
|
4
|
+
if (types === "*/*") return ["*/*"];
|
|
5
|
+
return types.split(",").map((t) => {
|
|
6
|
+
const [type, ...rest] = t.split(";");
|
|
7
|
+
const params = new Map(rest.map((p) => p.trim().split("=").slice(0, 2).map((p) => p.trim())));
|
|
8
|
+
return {
|
|
9
|
+
type,
|
|
10
|
+
q: params.has("q") ? Number.parseFloat(params.get("q")) : 1
|
|
11
|
+
};
|
|
12
|
+
}).sort((a, b) => {
|
|
13
|
+
if (a.type === "*/*") return 1;
|
|
14
|
+
if (b.type === "*/*") return -1;
|
|
15
|
+
return b.q - a.q ? -1 : 1;
|
|
16
|
+
}).map((t) => t.type);
|
|
20
17
|
};
|
|
21
18
|
export class Format {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
19
|
+
decoders = new Map();
|
|
20
|
+
encoders = new Map();
|
|
21
|
+
constructor(formats) {
|
|
22
|
+
for (const format of formats) {
|
|
23
|
+
this.encoders.set(format.contentType, format);
|
|
24
|
+
for (const acceptType of format.accept) {
|
|
25
|
+
this.decoders.set(acceptType, format);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
supportsDecoder(contentType, throwIfUnsupported = false) {
|
|
30
|
+
return this.supports(this.decoders, contentType, throwIfUnsupported);
|
|
31
|
+
}
|
|
32
|
+
supportsEncoder(contentType, throwIfUnsupported = false) {
|
|
33
|
+
return this.supports(this.encoders, contentType, throwIfUnsupported);
|
|
34
|
+
}
|
|
35
|
+
supports(formats, contentType, throwIfUnsupported = false) {
|
|
36
|
+
const types = parseContentTypes(contentType);
|
|
37
|
+
for (const type of types) {
|
|
38
|
+
for (const [pattern, format] of formats) {
|
|
39
|
+
if (type === "*/*" || match(type, pattern)) return format;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (throwIfUnsupported) throw new Error(`No supported format found: ${contentType}`);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
48
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"AAAA,SAAS,aAA2B,aAAa;AAoBjD,OAAO,MAAe,iBAEtB,CAcC;AAED,OAAO,MAAM,oBAAoB,CAACA,UAAkB;AAClD,KAAI,UAAU,MAAO,QAAO,CAAC,KAAM;AACnC,QAAO,MACJ,MAAM,IAAI,CACV,IAAI,CAAC,MAAM;EACV,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,EAAE,MAAM,IAAI;EACpC,MAAM,SAAS,IAAI,IACjB,KAAK,IAAI,CAAC,MACR,EACG,MAAM,CACN,MAAM,IAAI,CACV,MAAM,GAAG,EAAE,CACX,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CACxB;AAEH,SAAO;GACL;GACA,GAAG,OAAO,IAAI,IAAI,GAAG,OAAO,WAAW,OAAO,IAAI,IAAI,CAAE,GAAG;EAC5D;CACF,EAAC,CACD,KAAK,CAAC,GAAG,MAAM;AACd,MAAI,EAAE,SAAS,MAAO,QAAO;AAC7B,MAAI,EAAE,SAAS,MAAO,SAAQ;AAC9B,SAAO,EAAE,IAAI,EAAE,KAAK,IAAI;CACzB,EAAC,CACD,IAAI,CAAC,MAAM,EAAE,KAAK;AACtB;AAED,OAAO,MAAM,OAAO;CAClB,WAAW,IAAI;CACf,WAAW,IAAI;CAEf,YAAYC,SAA6B;AACvC,OAAK,MAAM,UAAU,SAAS;AAC5B,QAAK,SAAS,IAAI,OAAO,aAAa,OAAO;AAC7C,QAAK,MAAM,cAAc,OAAO,QAAQ;AACtC,SAAK,SAAS,IAAI,YAAY,OAAO;GACtC;EACF;CACF;CAED,gBAAgBC,aAAqB,qBAAqB,OAAO;AAC/D,SAAO,KAAK,SAAS,KAAK,UAAU,aAAa,mBAAmB;CACrE;CAED,gBAAgBA,aAAqB,qBAAqB,OAAO;AAC/D,SAAO,KAAK,SAAS,KAAK,UAAU,aAAa,mBAAmB;CACrE;CAED,AAAQ,SACNC,SACAD,aACA,qBAAqB,OACX;EAEV,MAAM,QAAQ,kBAAkB,YAAY;AAE5C,OAAK,MAAM,QAAQ,OAAO;AACxB,QAAK,MAAM,CAAC,SAAS,OAAO,IAAI,SAAS;AACvC,QAAI,SAAS,SAAS,MAAM,MAAM,QAAQ,CAAE,QAAO;GACpD;EACF;AAED,MAAI,mBACF,OAAM,IAAI,OAAO,6BAA6B,YAAY;AAE5D,SAAO;CACR;AACF","names":["types: string","formats: BaseServerFormat[]","contentType: string","formats: Map<Pattern, T>"],"sources":["src/server/format.ts"],"sourcesContent":["import { match, type Pattern } from '@nmtjs/core'\nimport type {\n DecodeRPCContext,\n EncodeRPCContext,\n ProtocolRPC,\n ProtocolRPCResponse,\n} from '../common/types.ts'\n\nexport interface BaseServerDecoder {\n accept: Pattern[]\n decode(buffer: ArrayBuffer): any\n decodeRPC(buffer: ArrayBuffer, context: DecodeRPCContext): ProtocolRPC\n}\n\nexport interface BaseServerEncoder {\n contentType: string\n encode(data: any): ArrayBuffer\n encodeRPC(rpc: ProtocolRPCResponse, context: EncodeRPCContext): ArrayBuffer\n}\n\nexport abstract class BaseServerFormat\n implements BaseServerDecoder, BaseServerEncoder\n{\n abstract accept: Pattern[]\n abstract contentType: string\n\n abstract encode(data: any): ArrayBuffer\n abstract encodeRPC(\n rpc: ProtocolRPCResponse,\n context: EncodeRPCContext,\n ): ArrayBuffer\n abstract decode(buffer: ArrayBuffer): any\n abstract decodeRPC(\n buffer: ArrayBuffer,\n context: DecodeRPCContext,\n ): ProtocolRPC\n}\n\nexport const parseContentTypes = (types: string) => {\n if (types === '*/*') return ['*/*']\n return types\n .split(',')\n .map((t) => {\n const [type, ...rest] = t.split(';')\n const params = new Map(\n rest.map((p) =>\n p\n .trim()\n .split('=')\n .slice(0, 2)\n .map((p) => p.trim()),\n ) as [string, string][],\n )\n return {\n type,\n q: params.has('q') ? Number.parseFloat(params.get('q')!) : 1,\n }\n })\n .sort((a, b) => {\n if (a.type === '*/*') return 1\n if (b.type === '*/*') return -1\n return b.q - a.q ? -1 : 1\n })\n .map((t) => t.type)\n}\n\nexport class Format {\n decoders = new Map<Pattern, BaseServerDecoder>()\n encoders = new Map<Pattern, BaseServerEncoder>()\n\n constructor(formats: BaseServerFormat[]) {\n for (const format of formats) {\n this.encoders.set(format.contentType, format)\n for (const acceptType of format.accept) {\n this.decoders.set(acceptType, format)\n }\n }\n }\n\n supportsDecoder(contentType: string, throwIfUnsupported = false) {\n return this.supports(this.decoders, contentType, throwIfUnsupported)\n }\n\n supportsEncoder(contentType: string, throwIfUnsupported = false) {\n return this.supports(this.encoders, contentType, throwIfUnsupported)\n }\n\n private supports<T extends BaseServerEncoder | BaseServerDecoder>(\n formats: Map<Pattern, T>,\n contentType: string,\n throwIfUnsupported = false,\n ): T | null {\n // TODO: Use node:utils.MIMEType (not implemented yet in Deno and Bun yet)\n const types = parseContentTypes(contentType)\n\n for (const type of types) {\n for (const [pattern, format] of formats) {\n if (type === '*/*' || match(type, pattern)) return format\n }\n }\n\n if (throwIfUnsupported)\n throw new Error(`No supported format found: ${contentType}`)\n\n return null\n }\n}\n"],"version":3}
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","names":[],"sources":["src/server/index.ts"],"sourcesContent":["export * from './api.ts'\nexport * from './connection.ts'\nexport * from './constants.ts'\nexport * from './format.ts'\nexport * from './injectables.ts'\nexport * from './protocol.ts'\nexport * from './registry.ts'\nexport * from './stream.ts'\nexport * from './transport.ts'\nexport * from './utils.ts'\n"],"version":3}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { createFactoryInjectable, createLazyInjectable, Scope } from
|
|
2
|
-
const connection = createLazyInjectable(Scope.Connection,
|
|
1
|
+
import { createFactoryInjectable, createLazyInjectable, Scope } from "@nmtjs/core";
|
|
2
|
+
const connection = createLazyInjectable(Scope.Connection, "RPC connection");
|
|
3
3
|
const connectionData = createLazyInjectable(Scope.Connection, "RPC connection's data");
|
|
4
|
-
const transportStopSignal = createLazyInjectable(Scope.Global,
|
|
5
|
-
const rpcClientAbortSignal = createLazyInjectable(Scope.Call,
|
|
6
|
-
const rpcTimeoutSignal = createLazyInjectable(Scope.Call,
|
|
4
|
+
const transportStopSignal = createLazyInjectable(Scope.Global, "Transport stop signal");
|
|
5
|
+
const rpcClientAbortSignal = createLazyInjectable(Scope.Call, "RPC client abort signal");
|
|
6
|
+
const rpcTimeoutSignal = createLazyInjectable(Scope.Call, "RPC timeout signal");
|
|
7
7
|
const rpcAbortSignal = createFactoryInjectable({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
8
|
+
dependencies: {
|
|
9
|
+
rpcTimeoutSignal,
|
|
10
|
+
rpcClientAbortSignal,
|
|
11
|
+
transportStopSignal
|
|
12
|
+
},
|
|
13
|
+
factory: (ctx) => AbortSignal.any(Object.values(ctx))
|
|
14
|
+
}, "Any RPC abort signal");
|
|
15
15
|
export const ProtocolInjectables = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
connection,
|
|
17
|
+
connectionData,
|
|
18
|
+
transportStopSignal,
|
|
19
|
+
rpcClientAbortSignal,
|
|
20
|
+
rpcTimeoutSignal,
|
|
21
|
+
rpcAbortSignal
|
|
22
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"mappings":"AAAA,SACE,yBACA,sBACA,aACK,aAAa;AAGpB,MAAM,aAAa,qBACjB,MAAM,YACN,iBACD;AAED,MAAM,iBAAiB,qBACrB,MAAM,YACN,wBACD;AAED,MAAM,sBAAsB,qBAC1B,MAAM,QACN,wBACD;AAED,MAAM,uBAAuB,qBAC3B,MAAM,MACN,0BACD;AAED,MAAM,mBAAmB,qBACvB,MAAM,MACN,qBACD;AAED,MAAM,iBAAiB,wBACrB;CACE,cAAc;EACZ;EACA;EACA;CACD;CACD,SAAS,CAAC,QAAQ,YAAY,IAAI,OAAO,OAAO,IAAI,CAAC;AACtD,GACD,uBACD;AAED,OAAO,MAAM,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;AACD","names":[],"sources":["src/server/injectables.ts"],"sourcesContent":["import {\n createFactoryInjectable,\n createLazyInjectable,\n Scope,\n} from '@nmtjs/core'\nimport type { Connection } from './connection.ts'\n\nconst connection = createLazyInjectable<Connection, Scope.Connection>(\n Scope.Connection,\n 'RPC connection',\n)\n\nconst connectionData = createLazyInjectable<any, Scope.Connection>(\n Scope.Connection,\n \"RPC connection's data\",\n)\n\nconst transportStopSignal = createLazyInjectable<AbortSignal>(\n Scope.Global,\n 'Transport stop signal',\n)\n\nconst rpcClientAbortSignal = createLazyInjectable<AbortSignal, Scope.Call>(\n Scope.Call,\n 'RPC client abort signal',\n)\n\nconst rpcTimeoutSignal = createLazyInjectable<AbortSignal, Scope.Call>(\n Scope.Call,\n 'RPC timeout signal',\n)\n\nconst rpcAbortSignal = createFactoryInjectable(\n {\n dependencies: {\n rpcTimeoutSignal,\n rpcClientAbortSignal,\n transportStopSignal,\n },\n factory: (ctx) => AbortSignal.any(Object.values(ctx)),\n },\n 'Any RPC abort signal',\n)\n\nexport const ProtocolInjectables = {\n connection,\n connectionData,\n transportStopSignal,\n rpcClientAbortSignal,\n rpcTimeoutSignal,\n rpcAbortSignal,\n} as const\n"],"version":3}
|