gomtm 0.0.274 → 0.0.275
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.
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Message, PartialMessage } from "@bufbuild/protobuf";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
+
export declare function WithConnectHydrate<I extends Message<I>, O extends Message<O>>(props: {
|
|
5
|
+
methodSig: MethodUnaryDescriptor<I, O>;
|
|
6
|
+
input?: PartialMessage<I>;
|
|
7
|
+
} & PropsWithChildren): Promise<import("react").JSX.Element>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
import { jsx } from "react/jsx-runtime";
|
|
38
|
+
import { HydrationBoundary, QueryClient, dehydrate } from "@tanstack/react-query";
|
|
39
|
+
import { callUnaryMethod, createConnectInfiniteQueryKey } from "../connectquery";
|
|
40
|
+
import { createTransport } from "../mtmFetcher";
|
|
41
|
+
function WithConnectHydrate(props) {
|
|
42
|
+
return __async(this, null, function* () {
|
|
43
|
+
const { methodSig, input, children } = props;
|
|
44
|
+
const queryClient = new QueryClient();
|
|
45
|
+
const ts = createTransport();
|
|
46
|
+
yield queryClient.prefetchInfiniteQuery({
|
|
47
|
+
queryKey: createConnectInfiniteQueryKey(methodSig, input),
|
|
48
|
+
queryFn: (k) => {
|
|
49
|
+
return callUnaryMethod(methodSig, input, { transport: ts });
|
|
50
|
+
},
|
|
51
|
+
initialPageParam: __spreadValues({}, input)
|
|
52
|
+
});
|
|
53
|
+
const dehydratedState = dehydrate(queryClient);
|
|
54
|
+
return /* @__PURE__ */ jsx(HydrationBoundary, { state: dehydratedState, children });
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
WithConnectHydrate
|
|
59
|
+
};
|
|
@@ -99,16 +99,16 @@ function useListView() {
|
|
|
99
99
|
}
|
|
100
100
|
function CommonListView() {
|
|
101
101
|
const listView = useListView();
|
|
102
|
-
console.log("listView.params", listView.params);
|
|
103
102
|
const listQuery = useSuspenseInfiniteQuery(listView.methodList, {
|
|
104
103
|
params: {
|
|
105
104
|
params: {
|
|
106
105
|
q: listView.params.q || ""
|
|
107
106
|
}
|
|
108
107
|
},
|
|
109
|
-
pagination: {
|
|
110
|
-
|
|
111
|
-
}
|
|
108
|
+
// pagination: {
|
|
109
|
+
// page: 1
|
|
110
|
+
// }
|
|
111
|
+
pagination: void 0
|
|
112
112
|
}, {
|
|
113
113
|
pageParamKey: "pagination",
|
|
114
114
|
getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => {
|
package/dist/esm/mtmFetcher.js
CHANGED
|
@@ -102,6 +102,10 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
102
102
|
if (!init) {
|
|
103
103
|
init = {};
|
|
104
104
|
}
|
|
105
|
+
if (init.body instanceof Uint8Array) {
|
|
106
|
+
const decoder = new TextDecoder();
|
|
107
|
+
init.body = decoder.decode(init.body);
|
|
108
|
+
}
|
|
105
109
|
init = __spreadValues(__spreadValues({}, init), {
|
|
106
110
|
headers: __spreadValues({
|
|
107
111
|
// ...init.headers,
|
|
@@ -119,7 +123,6 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
119
123
|
init
|
|
120
124
|
});
|
|
121
125
|
const responseData = yield fetcher(input, init);
|
|
122
|
-
console.log("[mtmfetch response]", responseData);
|
|
123
126
|
return responseData;
|
|
124
127
|
} catch (e) {
|
|
125
128
|
console.error("[mtmfetch error]", {
|
|
@@ -93,7 +93,9 @@ const MtConnectProvider = (props) => {
|
|
|
93
93
|
}),
|
|
94
94
|
jsonOptions: {
|
|
95
95
|
typeRegistry: anypbTypeReg
|
|
96
|
-
}
|
|
96
|
+
},
|
|
97
|
+
useHttpGet: true,
|
|
98
|
+
useBinaryFormat: false
|
|
97
99
|
});
|
|
98
100
|
}, [mtapp.backendUrl, mtapp.cookieStr]);
|
|
99
101
|
return /* @__PURE__ */ jsx(TransportProvider, { transport, children });
|