trpc-nuxt-module 4.3.1 → 4.3.3
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/index.d.ts +0 -2
- package/dist/index.js +1 -2
- package/dist/models/ExportReference.d.ts +1 -3
- package/dist/models/ModuleOptions.d.ts +1 -3
- package/dist/models/TrpcServerFetch.d.ts +1 -3
- package/dist/models/WebSocketOptions.d.ts +1 -3
- package/dist/runtime/client/createTRPCNuxtClient.d.ts +1 -3
- package/dist/runtime/client/createTRPCNuxtClient.js +1 -2
- package/dist/runtime/client/getMutationKey.d.ts +1 -3
- package/dist/runtime/client/getMutationKey.js +1 -2
- package/dist/runtime/client/getQueryKey.d.ts +1 -3
- package/dist/runtime/client/getQueryKey.js +1 -2
- package/dist/runtime/client/httpBatchLink.d.ts +1 -3
- package/dist/runtime/client/httpBatchLink.js +1 -2
- package/dist/runtime/client/httpLink.d.ts +1 -3
- package/dist/runtime/client/httpLink.js +1 -2
- package/dist/runtime/client/models/DecoratedMutation.d.ts +1 -3
- package/dist/runtime/client/models/DecoratedProcedure.d.ts +1 -3
- package/dist/runtime/client/models/DecoratedQuery.d.ts +1 -3
- package/dist/runtime/client/models/DecoratedRouterRecord.d.ts +1 -3
- package/dist/runtime/client/models/DecoratedSubscription.d.ts +1 -3
- package/dist/runtime/client/models/KeysOf.d.ts +1 -3
- package/dist/runtime/client/models/PickFrom.d.ts +1 -3
- package/dist/runtime/client/models/ProcedureNode.d.ts +1 -3
- package/dist/runtime/client/models/ProcedurePath.d.ts +1 -3
- package/dist/runtime/client/models/QueryAsyncData.d.ts +1 -3
- package/dist/runtime/client/models/QueryError.d.ts +1 -3
- package/dist/runtime/client/models/SubscriptionStatus.d.ts +1 -3
- package/dist/runtime/client/models/SubscriptionStatus.js +1 -2
- package/dist/runtime/client/models/TRPCNuxtClient.d.ts +1 -3
- package/dist/runtime/client/models/UseMutationOptions.d.ts +1 -3
- package/dist/runtime/client/models/UseMutationReturn.d.ts +1 -3
- package/dist/runtime/client/models/UseQuery.d.ts +1 -3
- package/dist/runtime/client/models/UseQueryOptions.d.ts +1 -3
- package/dist/runtime/client/models/UseSubscriptionOptions.d.ts +1 -3
- package/dist/runtime/client/models/UseSubscriptionReturn.d.ts +1 -3
- package/dist/runtime/client/services/getLinkFetch.d.ts +1 -3
- package/dist/runtime/client/services/getLinkFetch.js +1 -2
- package/dist/runtime/client/services/getProcedureKey.d.ts +1 -3
- package/dist/runtime/client/services/getProcedureKey.js +1 -2
- package/dist/runtime/client/services/mergeSignals.d.ts +1 -3
- package/dist/runtime/client/services/mergeSignals.js +1 -2
- package/dist/runtime/client/services/useProcedureMutation.d.ts +1 -3
- package/dist/runtime/client/services/useProcedureMutation.js +1 -2
- package/dist/runtime/client/services/useProcedureQuery.d.ts +1 -3
- package/dist/runtime/client/services/useProcedureQuery.js +1 -2
- package/dist/runtime/client/services/useProcedureSubscription.d.ts +1 -3
- package/dist/runtime/client/services/useProcedureSubscription.js +1 -2
- package/dist/runtime/client/services/useTrpcServerFetch.d.ts +1 -3
- package/dist/runtime/client/services/useTrpcServerFetch.js +1 -2
- package/dist/runtime/constants.d.ts +1 -3
- package/dist/runtime/constants.js +1 -2
- package/dist/runtime/server/createTRPCEventHandler.d.ts +1 -3
- package/dist/runtime/server/createTRPCEventHandler.js +1 -2
- package/dist/runtime/server/createTRPCWebSocketHandler.d.ts +1 -3
- package/dist/runtime/server/createTRPCWebSocketHandler.js +1 -2
- package/dist/runtime/server/models/PeerWebSocketAdapter.d.ts +1 -3
- package/dist/runtime/server/models/PeerWebSocketAdapter.js +1 -2
- package/dist/runtime/server/models/TRPCEventHandlerOptions.d.ts +1 -3
- package/dist/runtime/server/models/TRPCWebSocketConnection.d.ts +1 -3
- package/dist/runtime/server/models/TRPCWebSocketHandler.d.ts +1 -3
- package/dist/runtime/server/models/TRPCWebSocketHandlerOptions.d.ts +1 -3
- package/dist/runtime/server/models/WebSocketServerAdapter.d.ts +1 -3
- package/dist/runtime/server/models/WebSocketServerAdapter.js +1 -2
- package/dist/runtime/server/services/toIncomingMessage.d.ts +1 -3
- package/dist/runtime/server/services/toIncomingMessage.js +1 -2
- package/dist/services/getEventHandlerTemplate.js +1 -2
- package/dist/services/getImportStatement.js +1 -2
- package/dist/services/getWebSocketHandlerTemplate.js +1 -2
- package/dist/services/getWebSocketHooksTypeTemplate.js +1 -2
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ModuleOptions } from "./models/ModuleOptions.js";
|
|
2
2
|
import { NuxtModule } from "@nuxt/schema";
|
|
3
|
-
//#region src/module.d.ts
|
|
4
3
|
declare module "@nuxt/schema" {
|
|
5
4
|
interface NuxtConfig {
|
|
6
5
|
trpc?: Partial<ModuleOptions>;
|
|
7
6
|
}
|
|
8
7
|
}
|
|
9
8
|
declare const trpcNuxtModule: NuxtModule<ModuleOptions>;
|
|
10
|
-
//#endregion
|
|
11
9
|
export { type ModuleOptions, trpcNuxtModule as default };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getEventHandlerTemplate } from "./services/getEventHandlerTemplate.js";
|
|
|
3
3
|
import { getWebSocketHandlerTemplate } from "./services/getWebSocketHandlerTemplate.js";
|
|
4
4
|
import { getWebSocketHooksTypeTemplate } from "./services/getWebSocketHooksTypeTemplate.js";
|
|
5
5
|
import { addImports, addServerHandler, addServerTemplate, addTypeTemplate, defineNuxtModule, resolvePath } from "@nuxt/kit";
|
|
6
|
-
|
|
6
|
+
// src/module.ts
|
|
7
7
|
const CLIENT_IMPORTS = [
|
|
8
8
|
"createTRPCNuxtClient",
|
|
9
9
|
"getMutationKey",
|
|
@@ -69,5 +69,4 @@ const trpcNuxtModule = defineNuxtModule({
|
|
|
69
69
|
})));
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
//#endregion
|
|
73
72
|
export { trpcNuxtModule as default };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ExportReference } from "./ExportReference.js";
|
|
2
2
|
import { WebSocketOptions } from "./WebSocketOptions.js";
|
|
3
|
-
//#region src/models/ModuleOptions.d.ts
|
|
4
3
|
export interface ModuleOptions {
|
|
5
4
|
createContext?: ExportReference;
|
|
6
5
|
endpoint: string;
|
|
7
6
|
router: ExportReference;
|
|
8
7
|
webSocket?: WebSocketOptions;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
8
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
2
2
|
import { WSSHandlerOptions } from "@trpc/server/adapters/ws";
|
|
3
|
-
//#region src/models/WebSocketOptions.d.ts
|
|
4
3
|
export interface WebSocketOptions {
|
|
5
4
|
endpoint: string;
|
|
6
5
|
keepAlive?: WSSHandlerOptions<AnyTRPCRouter>["keepAlive"];
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
6
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { TRPCNuxtClient } from "./models/TRPCNuxtClient.js";
|
|
2
2
|
import { CreateTRPCClientOptions } from "@trpc/client";
|
|
3
3
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
4
|
-
|
|
5
|
-
export declare const createTRPCNuxtClient: <TRouter extends AnyTRPCRouter>(options: CreateTRPCClientOptions<TRouter>) => TRPCNuxtClient<TRouter>;
|
|
6
|
-
//#endregion
|
|
4
|
+
export declare const createTRPCNuxtClient: <TRouter extends AnyTRPCRouter>(options: CreateTRPCClientOptions<TRouter>) => TRPCNuxtClient<TRouter>;
|
|
@@ -3,7 +3,7 @@ import { useProcedureQuery } from "./services/useProcedureQuery.js";
|
|
|
3
3
|
import { useProcedureSubscription } from "./services/useProcedureSubscription.js";
|
|
4
4
|
import { createTRPCUntypedClient } from "@trpc/client";
|
|
5
5
|
import { createTRPCRecursiveProxy } from "@trpc/server";
|
|
6
|
-
|
|
6
|
+
// src/runtime/client/createTRPCNuxtClient.ts
|
|
7
7
|
const createTRPCNuxtClient = (options) => {
|
|
8
8
|
const client = createTRPCUntypedClient(options);
|
|
9
9
|
return createTRPCRecursiveProxy(({ args: [first, second], path }) => {
|
|
@@ -25,5 +25,4 @@ const createTRPCNuxtClient = (options) => {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { createTRPCNuxtClient };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { ProcedureNode } from "./models/ProcedureNode.js";
|
|
2
|
-
|
|
3
|
-
export declare const getMutationKey: (procedure: ProcedureNode) => string;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare const getMutationKey: (procedure: ProcedureNode) => string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getProcedureKey } from "./services/getProcedureKey.js";
|
|
2
|
-
|
|
2
|
+
// src/runtime/client/getMutationKey.ts
|
|
3
3
|
const getMutationKey = (procedure) => getProcedureKey(procedure._def().path.join("."));
|
|
4
|
-
//#endregion
|
|
5
4
|
export { getMutationKey };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { ProcedureNode } from "./models/ProcedureNode.js";
|
|
2
|
-
|
|
3
|
-
export declare const getQueryKey: (procedure: ProcedureNode, input?: unknown) => string;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare const getQueryKey: (procedure: ProcedureNode, input?: unknown) => string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getProcedureKey } from "./services/getProcedureKey.js";
|
|
2
|
-
|
|
2
|
+
// src/runtime/client/getQueryKey.ts
|
|
3
3
|
const getQueryKey = (procedure, input) => getProcedureKey(procedure._def().path.join("."), input);
|
|
4
|
-
//#endregion
|
|
5
4
|
export { getQueryKey };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { HTTPBatchLinkOptions, TRPCLink } from "@trpc/client";
|
|
2
2
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
3
|
-
|
|
4
|
-
export declare const httpBatchLink: <TRouter extends AnyTRPCRouter>(options: HTTPBatchLinkOptions<TRouter["_def"]["_config"]["$types"]>) => TRPCLink<TRouter>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const httpBatchLink: <TRouter extends AnyTRPCRouter>(options: HTTPBatchLinkOptions<TRouter["_def"]["_config"]["$types"]>) => TRPCLink<TRouter>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getLinkFetch } from "./services/getLinkFetch.js";
|
|
2
2
|
import { httpBatchLink as httpBatchLink$1 } from "@trpc/client";
|
|
3
|
-
|
|
3
|
+
// src/runtime/client/httpBatchLink.ts
|
|
4
4
|
const httpBatchLink = (options) => httpBatchLink$1({
|
|
5
5
|
fetch: getLinkFetch(),
|
|
6
6
|
...options
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { httpBatchLink };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { HTTPLinkOptions, TRPCLink } from "@trpc/client";
|
|
2
2
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
3
|
-
|
|
4
|
-
export declare const httpLink: <TRouter extends AnyTRPCRouter>(options: HTTPLinkOptions<TRouter["_def"]["_config"]["$types"]>) => TRPCLink<TRouter>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const httpLink: <TRouter extends AnyTRPCRouter>(options: HTTPLinkOptions<TRouter["_def"]["_config"]["$types"]>) => TRPCLink<TRouter>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getLinkFetch } from "./services/getLinkFetch.js";
|
|
2
2
|
import { httpLink as httpLink$1 } from "@trpc/client";
|
|
3
|
-
|
|
3
|
+
// src/runtime/client/httpLink.ts
|
|
4
4
|
const httpLink = (options) => httpLink$1({
|
|
5
5
|
fetch: getLinkFetch(),
|
|
6
6
|
...options
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { httpLink };
|
|
@@ -3,9 +3,7 @@ import { ProcedureNode } from "./ProcedureNode.js";
|
|
|
3
3
|
import { UseMutationOptions } from "./UseMutationOptions.js";
|
|
4
4
|
import { UseMutationReturn } from "./UseMutationReturn.js";
|
|
5
5
|
import { Resolver, TRPCResolverDef } from "@trpc/client";
|
|
6
|
-
//#region src/runtime/client/models/DecoratedMutation.d.ts
|
|
7
6
|
export interface DecoratedMutation<TDefinition extends TRPCResolverDef> extends ProcedureNode {
|
|
8
7
|
mutate: Resolver<TDefinition>;
|
|
9
8
|
useMutation: <TData = TDefinition["output"], TPickKeys extends KeysOf<TData> = KeysOf<TData>, TDefault = undefined>(options?: UseMutationOptions<TDefinition, TData, TPickKeys, TDefault>) => UseMutationReturn<TDefinition, TData, TPickKeys, TDefault>;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
9
|
+
}
|
|
@@ -3,6 +3,4 @@ import { DecoratedQuery } from "./DecoratedQuery.js";
|
|
|
3
3
|
import { DecoratedSubscription } from "./DecoratedSubscription.js";
|
|
4
4
|
import { TRPCResolverDef } from "@trpc/client";
|
|
5
5
|
import { TRPCProcedureType } from "@trpc/server";
|
|
6
|
-
|
|
7
|
-
export type DecoratedProcedure<TType extends TRPCProcedureType, TDefinition extends TRPCResolverDef> = TType extends "query" ? DecoratedQuery<TDefinition> : TType extends "mutation" ? DecoratedMutation<TDefinition> : DecoratedSubscription<TDefinition>;
|
|
8
|
-
//#endregion
|
|
6
|
+
export type DecoratedProcedure<TType extends TRPCProcedureType, TDefinition extends TRPCResolverDef> = TType extends "query" ? DecoratedQuery<TDefinition> : TType extends "mutation" ? DecoratedMutation<TDefinition> : DecoratedSubscription<TDefinition>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ProcedureNode } from "./ProcedureNode.js";
|
|
2
2
|
import { UseQuery } from "./UseQuery.js";
|
|
3
3
|
import { Resolver, TRPCResolverDef } from "@trpc/client";
|
|
4
|
-
//#region src/runtime/client/models/DecoratedQuery.d.ts
|
|
5
4
|
export interface DecoratedQuery<TDefinition extends TRPCResolverDef> extends ProcedureNode {
|
|
6
5
|
query: Resolver<TDefinition>;
|
|
7
6
|
useLazyQuery: UseQuery<TDefinition>;
|
|
8
7
|
useQuery: UseQuery<TDefinition>;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
8
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ProcedureNode } from "./ProcedureNode.js";
|
|
2
2
|
import { DecoratedProcedure } from "./DecoratedProcedure.js";
|
|
3
3
|
import { AnyTRPCProcedure, AnyTRPCRootTypes, TRPCRouterRecord, inferProcedureInput, inferTransformedProcedureOutput } from "@trpc/server";
|
|
4
|
-
//#region src/runtime/client/models/DecoratedRouterRecord.d.ts
|
|
5
4
|
export type DecoratedRouterRecord<TRoot extends AnyTRPCRootTypes, TRecord extends TRPCRouterRecord> = ProcedureNode & { readonly [TKey in keyof TRecord]: TRecord[TKey] extends AnyTRPCProcedure ? DecoratedProcedure<TRecord[TKey]["_def"]["type"], {
|
|
6
5
|
errorShape: TRoot["errorShape"];
|
|
7
6
|
input: inferProcedureInput<TRecord[TKey]>;
|
|
8
7
|
output: inferTransformedProcedureOutput<TRoot, TRecord[TKey]>;
|
|
9
8
|
transformer: TRoot["transformer"];
|
|
10
|
-
}> : TRecord[TKey] extends TRPCRouterRecord ? DecoratedRouterRecord<TRoot, TRecord[TKey]> : never; };
|
|
11
|
-
//#endregion
|
|
9
|
+
}> : TRecord[TKey] extends TRPCRouterRecord ? DecoratedRouterRecord<TRoot, TRecord[TKey]> : never; };
|
|
@@ -2,9 +2,7 @@ import { UseSubscriptionOptions } from "./UseSubscriptionOptions.js";
|
|
|
2
2
|
import { UseSubscriptionReturn } from "./UseSubscriptionReturn.js";
|
|
3
3
|
import { MaybeRefOrGetter } from "vue";
|
|
4
4
|
import { SubscriptionResolver, TRPCClientError, TRPCResolverDef } from "@trpc/client";
|
|
5
|
-
//#region src/runtime/client/models/DecoratedSubscription.d.ts
|
|
6
5
|
export interface DecoratedSubscription<TDefinition extends TRPCResolverDef> {
|
|
7
6
|
subscribe: SubscriptionResolver<TDefinition>;
|
|
8
7
|
useSubscription: (input: MaybeRefOrGetter<TDefinition["input"]>, options?: UseSubscriptionOptions<TDefinition>) => UseSubscriptionReturn<Parameters<NonNullable<UseSubscriptionOptions<TDefinition>["onData"]>>[0], TRPCClientError<TDefinition>>;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
8
|
+
}
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type PickFrom<T, TKeys extends string[]> = T extends unknown[] ? T : T extends Record<string, unknown> ? keyof T extends TKeys[number] ? T : TKeys[number] extends never ? T : Pick<T, TKeys[number]> : T;
|
|
3
|
-
//#endregion
|
|
1
|
+
export type PickFrom<T, TKeys extends string[]> = T extends unknown[] ? T : T extends Record<string, unknown> ? keyof T extends TKeys[number] ? T : TKeys[number] extends never ? T : Pick<T, TKeys[number]> : T;
|
|
@@ -3,6 +3,4 @@ import { PickFrom } from "./PickFrom.js";
|
|
|
3
3
|
import { QueryError } from "./QueryError.js";
|
|
4
4
|
import { AsyncData } from "nuxt/app";
|
|
5
5
|
import { TRPCResolverDef } from "@trpc/client";
|
|
6
|
-
|
|
7
|
-
export type QueryAsyncData<TDefinition extends TRPCResolverDef, TData, TPickKeys extends KeysOf<TData>, TDefault> = AsyncData<PickFrom<TData, TPickKeys> | TDefault, QueryError<TDefinition> | undefined>;
|
|
8
|
-
//#endregion
|
|
6
|
+
export type QueryAsyncData<TDefinition extends TRPCResolverDef, TData, TPickKeys extends KeysOf<TData>, TDefault> = AsyncData<PickFrom<TData, TPickKeys> | TDefault, QueryError<TDefinition> | undefined>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { NuxtError } from "nuxt/app";
|
|
2
2
|
import { TRPCClientErrorLike, TRPCResolverDef } from "@trpc/client";
|
|
3
|
-
|
|
4
|
-
export type QueryError<TDefinition extends TRPCResolverDef> = NuxtError<TRPCClientErrorLike<TDefinition>["data"]>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export type QueryError<TDefinition extends TRPCResolverDef> = NuxtError<TRPCClientErrorLike<TDefinition>["data"]>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/runtime/client/models/SubscriptionStatus.d.ts
|
|
2
1
|
export declare const SubscriptionStatus: {
|
|
3
2
|
readonly Connecting: "connecting";
|
|
4
3
|
readonly Error: "error";
|
|
5
4
|
readonly Idle: "idle";
|
|
6
5
|
readonly Pending: "pending";
|
|
7
6
|
};
|
|
8
|
-
export type SubscriptionStatus = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
|
|
9
|
-
//#endregion
|
|
7
|
+
export type SubscriptionStatus = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/client/models/SubscriptionStatus.ts
|
|
2
2
|
const SubscriptionStatus = {
|
|
3
3
|
Connecting: "connecting",
|
|
4
4
|
Error: "error",
|
|
5
5
|
Idle: "idle",
|
|
6
6
|
Pending: "pending"
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { SubscriptionStatus };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { DecoratedRouterRecord } from "./DecoratedRouterRecord.js";
|
|
2
2
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
3
|
-
|
|
4
|
-
export type TRPCNuxtClient<TRouter extends AnyTRPCRouter> = DecoratedRouterRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export type TRPCNuxtClient<TRouter extends AnyTRPCRouter> = DecoratedRouterRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>;
|
|
@@ -2,9 +2,7 @@ import { KeysOf } from "./KeysOf.js";
|
|
|
2
2
|
import { AsyncDataOptions } from "nuxt/app";
|
|
3
3
|
import { TRPCRequestOptions, TRPCResolverDef } from "@trpc/client";
|
|
4
4
|
import { Except } from "type-fest";
|
|
5
|
-
//#region src/runtime/client/models/UseMutationOptions.d.ts
|
|
6
5
|
export type UseMutationOptions<TDefinition extends TRPCResolverDef, TData = TDefinition["output"], TPickKeys extends KeysOf<TData> = KeysOf<TData>, TDefault = undefined> = Except<AsyncDataOptions<TDefinition["output"], TData, TPickKeys, TDefault>, "enabled" | "immediate" | "lazy" | "server" | "watch"> & {
|
|
7
6
|
mutationKey?: string;
|
|
8
7
|
trpc?: TRPCRequestOptions;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
8
|
+
};
|
|
@@ -2,8 +2,6 @@ import { KeysOf } from "./KeysOf.js";
|
|
|
2
2
|
import { PickFrom } from "./PickFrom.js";
|
|
3
3
|
import { QueryAsyncData } from "./QueryAsyncData.js";
|
|
4
4
|
import { TRPCResolverDef } from "@trpc/client";
|
|
5
|
-
//#region src/runtime/client/models/UseMutationReturn.d.ts
|
|
6
5
|
export type UseMutationReturn<TDefinition extends TRPCResolverDef, TData, TPickKeys extends KeysOf<TData>, TDefault> = QueryAsyncData<TDefinition, TData, TPickKeys, TDefault> & {
|
|
7
6
|
mutate: (input: TDefinition["input"]) => Promise<PickFrom<TData, TPickKeys> | TDefault>;
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
7
|
+
};
|
|
@@ -3,6 +3,4 @@ import { QueryAsyncData } from "./QueryAsyncData.js";
|
|
|
3
3
|
import { UseQueryOptions } from "./UseQueryOptions.js";
|
|
4
4
|
import { MaybeRefOrGetter } from "vue";
|
|
5
5
|
import { TRPCResolverDef } from "@trpc/client";
|
|
6
|
-
|
|
7
|
-
export type UseQuery<TDefinition extends TRPCResolverDef> = <TData = TDefinition["output"], TPickKeys extends KeysOf<TData> = KeysOf<TData>, TDefault = undefined>(input: MaybeRefOrGetter<TDefinition["input"]>, options?: UseQueryOptions<TDefinition, TData, TPickKeys, TDefault>) => QueryAsyncData<TDefinition, TData, TPickKeys, TDefault>;
|
|
8
|
-
//#endregion
|
|
6
|
+
export type UseQuery<TDefinition extends TRPCResolverDef> = <TData = TDefinition["output"], TPickKeys extends KeysOf<TData> = KeysOf<TData>, TDefault = undefined>(input: MaybeRefOrGetter<TDefinition["input"]>, options?: UseQueryOptions<TDefinition, TData, TPickKeys, TDefault>) => QueryAsyncData<TDefinition, TData, TPickKeys, TDefault>;
|
|
@@ -2,10 +2,8 @@ import { KeysOf } from "./KeysOf.js";
|
|
|
2
2
|
import { AsyncDataOptions } from "nuxt/app";
|
|
3
3
|
import { TRPCRequestOptions, TRPCResolverDef } from "@trpc/client";
|
|
4
4
|
import { Except } from "type-fest";
|
|
5
|
-
//#region src/runtime/client/models/UseQueryOptions.d.ts
|
|
6
5
|
export type UseQueryOptions<TDefinition extends TRPCResolverDef, TData = TDefinition["output"], TPickKeys extends KeysOf<TData> = KeysOf<TData>, TDefault = undefined> = Except<AsyncDataOptions<TDefinition["output"], TData, TPickKeys, TDefault>, "watch"> & {
|
|
7
6
|
queryKey?: string;
|
|
8
7
|
trpc?: TRPCRequestOptions;
|
|
9
8
|
watch?: false | NonNullable<AsyncDataOptions<TDefinition["output"], TData, TPickKeys, TDefault>["watch"]>;
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
9
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { MaybeRefOrGetter } from "vue";
|
|
2
2
|
import { SubscriptionResolver, TRPCResolverDef } from "@trpc/client";
|
|
3
|
-
//#region src/runtime/client/models/UseSubscriptionOptions.d.ts
|
|
4
3
|
export type UseSubscriptionOptions<TDefinition extends TRPCResolverDef> = Parameters<SubscriptionResolver<TDefinition>>[1] & {
|
|
5
4
|
enabled?: MaybeRefOrGetter<boolean>;
|
|
6
|
-
};
|
|
7
|
-
//#endregion
|
|
5
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { SubscriptionStatus } from "./SubscriptionStatus.js";
|
|
2
2
|
import { ShallowRef } from "vue";
|
|
3
|
-
//#region src/runtime/client/models/UseSubscriptionReturn.d.ts
|
|
4
3
|
export interface UseSubscriptionReturn<TData, TError> {
|
|
5
4
|
data: ShallowRef<TData | undefined>;
|
|
6
5
|
error: ShallowRef<TError | undefined>;
|
|
7
6
|
reset: () => void;
|
|
8
7
|
status: ShallowRef<SubscriptionStatus>;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
8
|
+
}
|
|
@@ -2,7 +2,7 @@ import { useTrpcServerFetch } from "./useTrpcServerFetch.js";
|
|
|
2
2
|
import { useRequestEvent } from "nuxt/app";
|
|
3
3
|
import { checkIsServer } from "@esposter/shared";
|
|
4
4
|
import { fetchWithEvent, getProxyRequestHeaders } from "nitro/h3";
|
|
5
|
-
|
|
5
|
+
// src/runtime/client/services/getLinkFetch.ts
|
|
6
6
|
const getLinkFetch = () => {
|
|
7
7
|
if (checkIsServer()) {
|
|
8
8
|
const event = useRequestEvent();
|
|
@@ -21,5 +21,4 @@ const getLinkFetch = () => {
|
|
|
21
21
|
}
|
|
22
22
|
return (input, init) => fetch(new URL(input, window.location.href), init);
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
export { getLinkFetch };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { hash } from "ohash";
|
|
2
|
-
|
|
2
|
+
// src/runtime/client/services/getProcedureKey.ts
|
|
3
3
|
const getProcedureKey = (path, input) => input === void 0 ? path : `${path}-${hash(input)}`;
|
|
4
|
-
//#endregion
|
|
5
4
|
export { getProcedureKey };
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const mergeSignals: (signal: AbortSignal, callerSignal?: AbortSignal) => AbortSignal;
|
|
3
|
-
//#endregion
|
|
1
|
+
export declare const mergeSignals: (signal: AbortSignal, callerSignal?: AbortSignal) => AbortSignal;
|
|
@@ -3,6 +3,4 @@ import { UseMutationOptions } from "../models/UseMutationOptions.js";
|
|
|
3
3
|
import { UseMutationReturn } from "../models/UseMutationReturn.js";
|
|
4
4
|
import { TRPCResolverDef, TRPCUntypedClient } from "@trpc/client";
|
|
5
5
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
6
|
-
|
|
7
|
-
export declare const useProcedureMutation: (client: TRPCUntypedClient<AnyTRPCRouter>, path: string, { mutationKey, trpc, ...options }?: UseMutationOptions<TRPCResolverDef>) => UseMutationReturn<TRPCResolverDef, unknown, KeysOf<unknown>, undefined>;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare const useProcedureMutation: (client: TRPCUntypedClient<AnyTRPCRouter>, path: string, { mutationKey, trpc, ...options }?: UseMutationOptions<TRPCResolverDef>) => UseMutationReturn<TRPCResolverDef, unknown, KeysOf<unknown>, undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getProcedureKey } from "./getProcedureKey.js";
|
|
2
2
|
import { mergeSignals } from "./mergeSignals.js";
|
|
3
3
|
import { useAsyncData } from "nuxt/app";
|
|
4
|
-
|
|
4
|
+
// src/runtime/client/services/useProcedureMutation.ts
|
|
5
5
|
const useProcedureMutation = (client, path, { mutationKey = getProcedureKey(path), trpc, ...options } = {}) => {
|
|
6
6
|
let mutationInput;
|
|
7
7
|
const asyncData = useAsyncData(mutationKey, (_nuxtApp, { signal }) => client.mutation(path, mutationInput, {
|
|
@@ -19,5 +19,4 @@ const useProcedureMutation = (client, path, { mutationKey = getProcedureKey(path
|
|
|
19
19
|
else return asyncData.data.value;
|
|
20
20
|
} });
|
|
21
21
|
};
|
|
22
|
-
//#endregion
|
|
23
22
|
export { useProcedureMutation };
|
|
@@ -4,6 +4,4 @@ import { UseQueryOptions } from "../models/UseQueryOptions.js";
|
|
|
4
4
|
import { MaybeRefOrGetter } from "vue";
|
|
5
5
|
import { TRPCResolverDef, TRPCUntypedClient } from "@trpc/client";
|
|
6
6
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
7
|
-
|
|
8
|
-
export declare const useProcedureQuery: (client: TRPCUntypedClient<AnyTRPCRouter>, path: string, input: MaybeRefOrGetter<unknown>, { queryKey, trpc, watch, ...options }?: UseQueryOptions<TRPCResolverDef>) => QueryAsyncData<TRPCResolverDef, unknown, KeysOf<unknown>, undefined>;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare const useProcedureQuery: (client: TRPCUntypedClient<AnyTRPCRouter>, path: string, input: MaybeRefOrGetter<unknown>, { queryKey, trpc, watch, ...options }?: UseQueryOptions<TRPCResolverDef>) => QueryAsyncData<TRPCResolverDef, unknown, KeysOf<unknown>, undefined>;
|
|
@@ -2,7 +2,7 @@ import { getProcedureKey } from "./getProcedureKey.js";
|
|
|
2
2
|
import { mergeSignals } from "./mergeSignals.js";
|
|
3
3
|
import { useAsyncData } from "nuxt/app";
|
|
4
4
|
import { toValue } from "vue";
|
|
5
|
-
|
|
5
|
+
// src/runtime/client/services/useProcedureQuery.ts
|
|
6
6
|
const useProcedureQuery = (client, path, input, { queryKey, trpc, watch, ...options } = {}) => useAsyncData(() => queryKey ?? getProcedureKey(path, toValue(input)), (_nuxtApp, { signal }) => client.query(path, toValue(input), {
|
|
7
7
|
...trpc,
|
|
8
8
|
signal: mergeSignals(signal, trpc?.signal)
|
|
@@ -10,5 +10,4 @@ const useProcedureQuery = (client, path, input, { queryKey, trpc, watch, ...opti
|
|
|
10
10
|
...options,
|
|
11
11
|
watch: watch === false ? void 0 : queryKey === void 0 ? watch : [...watch ?? [], () => toValue(input)]
|
|
12
12
|
});
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useProcedureQuery };
|
|
@@ -3,6 +3,4 @@ import { UseSubscriptionReturn } from "../models/UseSubscriptionReturn.js";
|
|
|
3
3
|
import { MaybeRefOrGetter } from "vue";
|
|
4
4
|
import { TRPCClientError, TRPCResolverDef, TRPCUntypedClient } from "@trpc/client";
|
|
5
5
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
6
|
-
|
|
7
|
-
export declare const useProcedureSubscription: (client: TRPCUntypedClient<AnyTRPCRouter>, path: string, input: MaybeRefOrGetter<unknown>, { enabled, ...options }?: UseSubscriptionOptions<TRPCResolverDef>) => UseSubscriptionReturn<unknown, TRPCClientError<AnyTRPCRouter>>;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare const useProcedureSubscription: (client: TRPCUntypedClient<AnyTRPCRouter>, path: string, input: MaybeRefOrGetter<unknown>, { enabled, ...options }?: UseSubscriptionOptions<TRPCResolverDef>) => UseSubscriptionReturn<unknown, TRPCClientError<AnyTRPCRouter>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SubscriptionStatus } from "../models/SubscriptionStatus.js";
|
|
2
2
|
import { getCurrentScope, onScopeDispose, shallowRef, toValue, watch } from "vue";
|
|
3
3
|
import { checkIsServer } from "@esposter/shared";
|
|
4
|
-
|
|
4
|
+
// src/runtime/client/services/useProcedureSubscription.ts
|
|
5
5
|
const ConnectionStateSubscriptionStatusMap = {
|
|
6
6
|
connecting: SubscriptionStatus.Connecting,
|
|
7
7
|
idle: SubscriptionStatus.Idle,
|
|
@@ -64,5 +64,4 @@ const useProcedureSubscription = (client, path, input, { enabled = true, ...opti
|
|
|
64
64
|
status
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
//#endregion
|
|
68
67
|
export { useProcedureSubscription };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { TrpcServerFetch } from "../../../models/TrpcServerFetch.js";
|
|
2
|
-
|
|
3
|
-
export declare const useTrpcServerFetch: () => TrpcServerFetch;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare const useTrpcServerFetch: () => TrpcServerFetch;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/client/services/useTrpcServerFetch.ts
|
|
2
2
|
const useTrpcServerFetch = () => async (resource, init, context) => {
|
|
3
3
|
if (!import.meta.server) throw new TypeError("The in-process tRPC fetch exists on the server only");
|
|
4
4
|
const { serverFetch } = await import("nitro/app");
|
|
5
5
|
return serverFetch(resource, init, context);
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { useTrpcServerFetch };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//#region src/runtime/constants.d.ts
|
|
2
1
|
export declare const DEFAULT_ENDPOINT = "/api/trpc";
|
|
3
2
|
export declare const MODULE_NAME = "trpc-nuxt-module";
|
|
4
3
|
export declare const WEBSOCKET_CLOSE_HOOK: `${typeof MODULE_NAME}:webSocket:close`;
|
|
5
|
-
export declare const WEBSOCKET_OPEN_HOOK: `${typeof MODULE_NAME}:webSocket:open`;
|
|
6
|
-
//#endregion
|
|
4
|
+
export declare const WEBSOCKET_OPEN_HOOK: `${typeof MODULE_NAME}:webSocket:open`;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/constants.ts
|
|
2
2
|
const DEFAULT_ENDPOINT = "/api/trpc";
|
|
3
3
|
const MODULE_NAME = "trpc-nuxt-module";
|
|
4
4
|
const WEBSOCKET_CLOSE_HOOK = `${MODULE_NAME}:webSocket:close`;
|
|
5
5
|
const WEBSOCKET_OPEN_HOOK = `${MODULE_NAME}:webSocket:open`;
|
|
6
|
-
//#endregion
|
|
7
6
|
export { DEFAULT_ENDPOINT, MODULE_NAME, WEBSOCKET_CLOSE_HOOK, WEBSOCKET_OPEN_HOOK };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { TRPCEventHandlerOptions } from "./models/TRPCEventHandlerOptions.js";
|
|
2
2
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
3
3
|
import { EventHandler } from "nitro/h3";
|
|
4
|
-
|
|
5
|
-
export declare const createTRPCEventHandler: <TRouter extends AnyTRPCRouter>({ createContext, endpoint, ...options }: TRPCEventHandlerOptions<TRouter>) => EventHandler;
|
|
6
|
-
//#endregion
|
|
4
|
+
export declare const createTRPCEventHandler: <TRouter extends AnyTRPCRouter>({ createContext, endpoint, ...options }: TRPCEventHandlerOptions<TRouter>) => EventHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_ENDPOINT } from "../constants.js";
|
|
2
2
|
import { defineHandler } from "nitro/h3";
|
|
3
3
|
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/createTRPCEventHandler.ts
|
|
5
5
|
const NULL_BODY_STATUSES = /* @__PURE__ */ new Set([
|
|
6
6
|
204,
|
|
7
7
|
205,
|
|
@@ -27,5 +27,4 @@ const createTRPCEventHandler = ({ createContext, endpoint = DEFAULT_ENDPOINT, ..
|
|
|
27
27
|
status
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
//#endregion
|
|
31
30
|
export { createTRPCEventHandler };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { TRPCWebSocketHandler } from "./models/TRPCWebSocketHandler.js";
|
|
2
2
|
import { TRPCWebSocketHandlerOptions } from "./models/TRPCWebSocketHandlerOptions.js";
|
|
3
3
|
import { AnyTRPCRouter } from "@trpc/server";
|
|
4
|
-
|
|
5
|
-
export declare const createTRPCWebSocketHandler: <TRouter extends AnyTRPCRouter>({ createContext, onClose, onOpen, ...options }: TRPCWebSocketHandlerOptions<TRouter>) => TRPCWebSocketHandler;
|
|
6
|
-
//#endregion
|
|
4
|
+
export declare const createTRPCWebSocketHandler: <TRouter extends AnyTRPCRouter>({ createContext, onClose, onOpen, ...options }: TRPCWebSocketHandlerOptions<TRouter>) => TRPCWebSocketHandler;
|
|
@@ -2,7 +2,7 @@ import { PeerWebSocketAdapter } from "./models/PeerWebSocketAdapter.js";
|
|
|
2
2
|
import { WebSocketServerAdapter } from "./models/WebSocketServerAdapter.js";
|
|
3
3
|
import { toIncomingMessage } from "./services/toIncomingMessage.js";
|
|
4
4
|
import { applyWSSHandler } from "@trpc/server/adapters/ws";
|
|
5
|
-
|
|
5
|
+
// src/runtime/server/createTRPCWebSocketHandler.ts
|
|
6
6
|
const createTRPCWebSocketHandler = ({ createContext, onClose, onOpen, ...options }) => {
|
|
7
7
|
const webSocketServer = new WebSocketServerAdapter();
|
|
8
8
|
const { broadcastReconnectNotification } = applyWSSHandler({
|
|
@@ -59,5 +59,4 @@ const createTRPCWebSocketHandler = ({ createContext, onClose, onOpen, ...options
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
//#endregion
|
|
63
62
|
export { createTRPCWebSocketHandler };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import { Peer } from "crossws";
|
|
3
|
-
//#region src/runtime/server/models/PeerWebSocketAdapter.d.ts
|
|
4
3
|
export declare class PeerWebSocketAdapter extends EventEmitter {
|
|
5
4
|
#private;
|
|
6
5
|
readonly CLOSED: number;
|
|
@@ -15,5 +14,4 @@ export declare class PeerWebSocketAdapter extends EventEmitter {
|
|
|
15
14
|
receiveMessage(message: string): void;
|
|
16
15
|
send(data: string): void;
|
|
17
16
|
terminate(): void;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
17
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/models/PeerWebSocketAdapter.ts
|
|
3
3
|
var PeerWebSocketAdapter = class extends EventEmitter {
|
|
4
4
|
CLOSED = WebSocket.CLOSED;
|
|
5
5
|
CLOSING = WebSocket.CLOSING;
|
|
@@ -33,5 +33,4 @@ var PeerWebSocketAdapter = class extends EventEmitter {
|
|
|
33
33
|
this.#peer.terminate();
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { PeerWebSocketAdapter };
|
|
@@ -3,9 +3,7 @@ import { H3Event } from "nitro/h3";
|
|
|
3
3
|
import { FetchCreateContextFnOptions } from "@trpc/server/adapters/fetch";
|
|
4
4
|
import { Promisable } from "type-fest";
|
|
5
5
|
import { HTTPBaseHandlerOptions } from "@trpc/server/http";
|
|
6
|
-
//#region src/runtime/server/models/TRPCEventHandlerOptions.d.ts
|
|
7
6
|
export type TRPCEventHandlerOptions<TRouter extends AnyTRPCRouter> = HTTPBaseHandlerOptions<TRouter, Request> & {
|
|
8
7
|
createContext?: (event: H3Event, options: FetchCreateContextFnOptions) => Promisable<inferRouterContext<TRouter>>;
|
|
9
8
|
endpoint?: string;
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
9
|
+
};
|
|
@@ -4,10 +4,8 @@ import { IncomingMessage } from "node:http";
|
|
|
4
4
|
import { CreateWSSContextFnOptions, WSSHandlerOptions } from "@trpc/server/adapters/ws";
|
|
5
5
|
import { Promisable } from "type-fest";
|
|
6
6
|
import { BaseHandlerOptions } from "@trpc/server/http";
|
|
7
|
-
//#region src/runtime/server/models/TRPCWebSocketHandlerOptions.d.ts
|
|
8
7
|
export type TRPCWebSocketHandlerOptions<TRouter extends AnyTRPCRouter> = BaseHandlerOptions<TRouter, IncomingMessage> & Pick<WSSHandlerOptions<TRouter>, "dangerouslyDisablePong" | "experimental_encoder" | "keepAlive" | "prefix"> & {
|
|
9
8
|
createContext: (options: CreateWSSContextFnOptions) => Promisable<inferRouterContext<TRouter>>;
|
|
10
9
|
onClose?: (connection: TRPCWebSocketConnection<inferRouterContext<TRouter>>) => Promisable<void>;
|
|
11
10
|
onOpen?: (connection: TRPCWebSocketConnection<inferRouterContext<TRouter>>) => Promisable<void>;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
11
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import { IncomingMessage } from "node:http";
|
|
3
|
-
//#region src/runtime/server/models/WebSocketServerAdapter.d.ts
|
|
4
3
|
export declare class WebSocketServerAdapter<TClient extends EventEmitter> extends EventEmitter {
|
|
5
4
|
readonly clients: Set<TClient>;
|
|
6
5
|
addConnection(client: TClient, request: IncomingMessage): void;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
6
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/models/WebSocketServerAdapter.ts
|
|
3
3
|
var WebSocketServerAdapter = class extends EventEmitter {
|
|
4
4
|
clients = /* @__PURE__ */ new Set();
|
|
5
5
|
addConnection(client, request) {
|
|
@@ -10,5 +10,4 @@ var WebSocketServerAdapter = class extends EventEmitter {
|
|
|
10
10
|
this.emit("connection", client, request);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
//#endregion
|
|
14
13
|
export { WebSocketServerAdapter };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { IncomingMessage } from "node:http";
|
|
2
2
|
import { Peer } from "crossws";
|
|
3
|
-
|
|
4
|
-
export declare const toIncomingMessage: ({ request }: Peer) => IncomingMessage;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const toIncomingMessage: ({ request }: Peer) => IncomingMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage } from "node:http";
|
|
2
2
|
import { Socket } from "node:net";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/services/toIncomingMessage.ts
|
|
4
4
|
const toIncomingMessage = ({ request }) => {
|
|
5
5
|
const incomingMessage = new IncomingMessage(new Socket());
|
|
6
6
|
const { pathname, search } = new URL(request.url);
|
|
@@ -8,5 +8,4 @@ const toIncomingMessage = ({ request }) => {
|
|
|
8
8
|
incomingMessage.headers = Object.fromEntries(request.headers);
|
|
9
9
|
return incomingMessage;
|
|
10
10
|
};
|
|
11
|
-
//#endregion
|
|
12
11
|
export { toIncomingMessage };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MODULE_NAME } from "../runtime/constants.js";
|
|
2
2
|
import { getImportStatement } from "./getImportStatement.js";
|
|
3
|
-
|
|
3
|
+
// src/services/getEventHandlerTemplate.ts
|
|
4
4
|
const getEventHandlerTemplate = (router, endpoint, createContext) => [
|
|
5
5
|
`import { createTRPCEventHandler } from "${MODULE_NAME}/runtime/server/createTRPCEventHandler";`,
|
|
6
6
|
getImportStatement(router, "router"),
|
|
7
7
|
...createContext ? [getImportStatement(createContext, "createContext")] : [],
|
|
8
8
|
`export default createTRPCEventHandler({ ${createContext ? "createContext, " : ""}endpoint: ${JSON.stringify(endpoint)}, router });`
|
|
9
9
|
].join("\n");
|
|
10
|
-
//#endregion
|
|
11
10
|
export { getEventHandlerTemplate };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MODULE_NAME } from "../runtime/constants.js";
|
|
2
2
|
import { getImportStatement } from "./getImportStatement.js";
|
|
3
|
-
|
|
3
|
+
// src/services/getWebSocketHandlerTemplate.ts
|
|
4
4
|
const getWebSocketHandlerTemplate = (router, { keepAlive }, createContext) => [
|
|
5
5
|
`import { useNitroHooks } from "nitro/app";`,
|
|
6
6
|
`import { defineWebSocketHandler } from "nitro/h3";`,
|
|
@@ -19,5 +19,4 @@ const getWebSocketHandlerTemplate = (router, { keepAlive }, createContext) => [
|
|
|
19
19
|
`nitroHooks.hook("close", broadcastReconnectNotification);`,
|
|
20
20
|
`export default defineWebSocketHandler(hooks);`
|
|
21
21
|
].join("\n");
|
|
22
|
-
//#endregion
|
|
23
22
|
export { getWebSocketHandlerTemplate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MODULE_NAME, WEBSOCKET_CLOSE_HOOK, WEBSOCKET_OPEN_HOOK } from "../runtime/constants.js";
|
|
2
|
-
|
|
2
|
+
// src/services/getWebSocketHooksTypeTemplate.ts
|
|
3
3
|
const getWebSocketHooksTypeTemplate = ({ from, name }) => {
|
|
4
4
|
const connectionType = `TRPCWebSocketConnection<inferRouterContext<typeof import(${JSON.stringify(from)})[${JSON.stringify(name)}]>>`;
|
|
5
5
|
return [
|
|
@@ -14,5 +14,4 @@ const getWebSocketHooksTypeTemplate = ({ from, name }) => {
|
|
|
14
14
|
`export {};`
|
|
15
15
|
].join("\n");
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { getWebSocketHooksTypeTemplate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trpc-nuxt-module",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.3",
|
|
4
4
|
"description": "tRPC for Nuxt — a Nuxt module that registers your router's HTTP and WebSocket handlers, fetches through the request event during SSR, and decorates the typed client with useQuery, useMutation and useSubscription over useAsyncData.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nitro",
|
|
@@ -80,15 +80,15 @@
|
|
|
80
80
|
"typecheck": "tsc"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@esposter/shared": "4.3.
|
|
83
|
+
"@esposter/shared": "4.3.3",
|
|
84
84
|
"@nuxt/kit": "npm:@nuxt/kit-nightly@5x",
|
|
85
85
|
"@nuxt/schema": "npm:@nuxt/schema-nightly@5x",
|
|
86
86
|
"ohash": "^2.0.12",
|
|
87
87
|
"type-fest": "^5.10.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@esposter/configuration": "4.3.
|
|
91
|
-
"@esposter/shared-node": "4.3.
|
|
90
|
+
"@esposter/configuration": "4.3.3",
|
|
91
|
+
"@esposter/shared-node": "4.3.3",
|
|
92
92
|
"@nuxt/nitro-server": "npm:@nuxt/nitro-server-nightly@5x",
|
|
93
93
|
"@nuxt/test-utils": "^4.3.4",
|
|
94
94
|
"@types/node": "^26.6.5",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"nuxt": "npm:nuxt-nightly@5x",
|
|
106
106
|
"vue": "^3.5.44"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "955bbc130ad9b28877fd4ae8efc73a045141ce01"
|
|
109
109
|
}
|