trpc-nuxt-module 4.0.0 → 4.1.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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
//#region src/runtime/client/models/SubscriptionStatus.d.ts
|
|
2
|
-
export declare
|
|
3
|
-
Connecting
|
|
4
|
-
Error
|
|
5
|
-
Idle
|
|
6
|
-
Pending
|
|
7
|
-
}
|
|
2
|
+
export declare const SubscriptionStatus: {
|
|
3
|
+
readonly Connecting: "connecting";
|
|
4
|
+
readonly Error: "error";
|
|
5
|
+
readonly Idle: "idle";
|
|
6
|
+
readonly Pending: "pending";
|
|
7
|
+
};
|
|
8
|
+
export type SubscriptionStatus = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
|
|
8
9
|
//#endregion
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
//#region src/runtime/client/models/SubscriptionStatus.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}({});
|
|
2
|
+
const SubscriptionStatus = {
|
|
3
|
+
Connecting: "connecting",
|
|
4
|
+
Error: "error",
|
|
5
|
+
Idle: "idle",
|
|
6
|
+
Pending: "pending"
|
|
7
|
+
};
|
|
9
8
|
//#endregion
|
|
10
9
|
export { SubscriptionStatus };
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import "../models/SubscriptionStatus.js";
|
|
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
|
//#region src/runtime/client/services/useProcedureSubscription.ts
|
|
5
5
|
const ConnectionStateSubscriptionStatusMap = {
|
|
6
|
-
connecting:
|
|
7
|
-
idle:
|
|
8
|
-
pending:
|
|
6
|
+
connecting: SubscriptionStatus.Connecting,
|
|
7
|
+
idle: SubscriptionStatus.Idle,
|
|
8
|
+
pending: SubscriptionStatus.Pending
|
|
9
9
|
};
|
|
10
10
|
const useProcedureSubscription = (client, path, input, { enabled = true, ...options } = {}) => {
|
|
11
11
|
const data = shallowRef();
|
|
12
12
|
const error = shallowRef();
|
|
13
|
-
const status = shallowRef(
|
|
13
|
+
const status = shallowRef(SubscriptionStatus.Idle);
|
|
14
14
|
let unsubscribable;
|
|
15
15
|
const unsubscribe = () => {
|
|
16
16
|
unsubscribable?.unsubscribe();
|
|
17
17
|
unsubscribable = void 0;
|
|
18
|
-
status.value =
|
|
18
|
+
status.value = SubscriptionStatus.Idle;
|
|
19
19
|
};
|
|
20
20
|
const subscribe = () => {
|
|
21
21
|
unsubscribable?.unsubscribe();
|
|
22
22
|
error.value = void 0;
|
|
23
|
-
status.value =
|
|
23
|
+
status.value = SubscriptionStatus.Connecting;
|
|
24
24
|
unsubscribable = client.subscription(path, toValue(input), {
|
|
25
25
|
...options,
|
|
26
26
|
onComplete: () => {
|
|
27
|
-
status.value =
|
|
27
|
+
status.value = SubscriptionStatus.Idle;
|
|
28
28
|
options.onComplete?.();
|
|
29
29
|
},
|
|
30
30
|
onConnectionStateChange: (state) => {
|
|
31
|
-
status.value = state.error ?
|
|
31
|
+
status.value = state.error ? SubscriptionStatus.Error : ConnectionStateSubscriptionStatusMap[state.state];
|
|
32
32
|
options.onConnectionStateChange?.(state);
|
|
33
33
|
},
|
|
34
34
|
onData: (value) => {
|
|
@@ -37,11 +37,11 @@ const useProcedureSubscription = (client, path, input, { enabled = true, ...opti
|
|
|
37
37
|
},
|
|
38
38
|
onError: (newError) => {
|
|
39
39
|
error.value = newError;
|
|
40
|
-
status.value =
|
|
40
|
+
status.value = SubscriptionStatus.Error;
|
|
41
41
|
options.onError?.(newError);
|
|
42
42
|
},
|
|
43
43
|
onStarted: (startedOptions) => {
|
|
44
|
-
status.value =
|
|
44
|
+
status.value = SubscriptionStatus.Pending;
|
|
45
45
|
options.onStarted?.(startedOptions);
|
|
46
46
|
}
|
|
47
47
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trpc-nuxt-module",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
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",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"typecheck": "tsc"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@esposter/shared": "4.
|
|
85
|
+
"@esposter/shared": "4.1.0",
|
|
86
86
|
"@nuxt/kit": "npm:@nuxt/kit-nightly@5x",
|
|
87
87
|
"@nuxt/schema": "npm:@nuxt/schema-nightly@5x",
|
|
88
88
|
"ohash": "^2.0.12",
|
|
@@ -90,17 +90,17 @@
|
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@arethetypeswrong/core": "^0.18.5",
|
|
93
|
-
"@esposter/configuration": "4.
|
|
94
|
-
"@esposter/shared-node": "4.
|
|
93
|
+
"@esposter/configuration": "4.1.0",
|
|
94
|
+
"@esposter/shared-node": "4.1.0",
|
|
95
95
|
"@nuxt/nitro-server": "npm:@nuxt/nitro-server-nightly@5x",
|
|
96
96
|
"@nuxt/test-utils": "^4.3.3",
|
|
97
|
-
"@types/node": "^26.6.
|
|
98
|
-
"happy-dom": "^
|
|
97
|
+
"@types/node": "^26.6.5",
|
|
98
|
+
"happy-dom": "^21.0.1",
|
|
99
99
|
"publint": "^0.3.25",
|
|
100
100
|
"superjson": "^2.2.6",
|
|
101
|
-
"tsdown": "^0.23.
|
|
102
|
-
"vitest": "^5.0.
|
|
103
|
-
"zod": "^4.6.
|
|
101
|
+
"tsdown": "^0.23.1",
|
|
102
|
+
"vitest": "^5.0.4",
|
|
103
|
+
"zod": "^4.6.7"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"@trpc/client": "^11.19.0",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"crossws": "^0.4.15",
|
|
109
109
|
"nitro": "npm:nitro-nightly@latest",
|
|
110
110
|
"nuxt": "npm:nuxt-nightly@5x",
|
|
111
|
-
"vue": "^3.5.
|
|
111
|
+
"vue": "^3.5.44"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "68de4c22fa7591bf6f6cc0fab2c9a906d8c4d71a"
|
|
114
114
|
}
|