gomtm 0.0.273 → 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.
- package/dist/esm/components/MtmErrorView.d.ts +2 -1
- package/dist/esm/components/MtmErrorView.js +8 -4
- package/dist/esm/components/SSR.d.ts +7 -0
- package/dist/esm/components/SSR.js +59 -0
- package/dist/esm/curd/ListViewProvider.js +7 -7
- package/dist/esm/mtmFetcher.js +8 -7
- package/dist/esm/providers/GomtmProvider.js +3 -1
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
import { PlainMessage } from "@bufbuild/protobuf";
|
|
3
3
|
import { MtmError } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
4
4
|
export declare const MtmErrorView: (props: {
|
|
5
|
-
|
|
5
|
+
unaryError: PlainMessage<MtmError>;
|
|
6
|
+
retry?: () => void;
|
|
6
7
|
}) => import("react").JSX.Element;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
const MtmErrorView = (props) => {
|
|
4
|
-
const {
|
|
5
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
6
|
-
"
|
|
7
|
-
|
|
4
|
+
const { unaryError, retry } = props;
|
|
5
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-red-400 p-4", children: [
|
|
6
|
+
"code: ",
|
|
7
|
+
unaryError.errCode,
|
|
8
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("pre", { className: "prose dark:prose-invert max-w-96 flex-wrap text-wrap break-words", children: unaryError.errMessage }) }),
|
|
9
|
+
retry && /* @__PURE__ */ jsx("button", { onClick: () => {
|
|
10
|
+
retry();
|
|
11
|
+
}, children: "retry" })
|
|
8
12
|
] });
|
|
9
13
|
};
|
|
10
14
|
export {
|
|
@@ -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
|
+
};
|
|
@@ -47,7 +47,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel
|
|
|
47
47
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
48
48
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
49
49
|
import { Suspense, createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
50
|
-
import {
|
|
50
|
+
import { MtmErrorView } from "../components/MtmErrorView";
|
|
51
51
|
import { useMutation, useSuspenseInfiniteQuery } from "../connectquery";
|
|
52
52
|
import { useMtmApp } from "../providers/GomtmProvider";
|
|
53
53
|
import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton } from "./CurdDetailProvider";
|
|
@@ -91,7 +91,7 @@ function ListViewProvider(props) {
|
|
|
91
91
|
setOpenDebug,
|
|
92
92
|
params,
|
|
93
93
|
setParams
|
|
94
|
-
}, children
|
|
94
|
+
}, children });
|
|
95
95
|
}
|
|
96
96
|
function useListView() {
|
|
97
97
|
const ctx = useContext(commonListViewContext);
|
|
@@ -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) => {
|
|
@@ -132,7 +132,7 @@ function CommonListView() {
|
|
|
132
132
|
children: listQuery.data.pages.map((page, i) => {
|
|
133
133
|
var _a;
|
|
134
134
|
if (page.errCode) {
|
|
135
|
-
return /* @__PURE__ */ jsx(
|
|
135
|
+
return /* @__PURE__ */ jsx(MtmErrorView, { unaryError: page }, i);
|
|
136
136
|
} else {
|
|
137
137
|
return /* @__PURE__ */ jsx(ListLayout, { layout: page.listLayout, children: (_a = page == null ? void 0 : page.items) == null ? void 0 : _a.map((item, j) => /* @__PURE__ */ jsx(ListItemView, { item }, `${i}-${j}`)) }, i);
|
|
138
138
|
}
|
package/dist/esm/mtmFetcher.js
CHANGED
|
@@ -61,16 +61,14 @@ const gomtmApiUrl = () => {
|
|
|
61
61
|
function createMtmServiceClient(service, url) {
|
|
62
62
|
return createPromiseClient(
|
|
63
63
|
service,
|
|
64
|
-
|
|
65
|
-
baseUrl: gomtmApiUrl(),
|
|
66
|
-
fetch: gomtmFetcher()
|
|
67
|
-
})
|
|
64
|
+
createTransport()
|
|
68
65
|
);
|
|
69
66
|
}
|
|
70
67
|
function createTransport() {
|
|
71
68
|
return createConnectTransport({
|
|
72
69
|
baseUrl: gomtmApiUrl(),
|
|
73
|
-
fetch: gomtmFetcher()
|
|
70
|
+
fetch: gomtmFetcher(),
|
|
71
|
+
useHttpGet: true
|
|
74
72
|
});
|
|
75
73
|
}
|
|
76
74
|
function createMtmServiceClientByName(svcName, url) {
|
|
@@ -104,6 +102,10 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
104
102
|
if (!init) {
|
|
105
103
|
init = {};
|
|
106
104
|
}
|
|
105
|
+
if (init.body instanceof Uint8Array) {
|
|
106
|
+
const decoder = new TextDecoder();
|
|
107
|
+
init.body = decoder.decode(init.body);
|
|
108
|
+
}
|
|
107
109
|
init = __spreadValues(__spreadValues({}, init), {
|
|
108
110
|
headers: __spreadValues({
|
|
109
111
|
// ...init.headers,
|
|
@@ -111,7 +113,7 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
111
113
|
}, (initGlobal == null ? void 0 : initGlobal.cookieStr) && { "Cookie": initGlobal == null ? void 0 : initGlobal.cookieStr })
|
|
112
114
|
});
|
|
113
115
|
let fetcher = fetch;
|
|
114
|
-
req.enableCache =
|
|
116
|
+
req.enableCache = true;
|
|
115
117
|
if (req.enableCache) {
|
|
116
118
|
fetcher = fetchMiddleWithCache(fetch);
|
|
117
119
|
}
|
|
@@ -121,7 +123,6 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
121
123
|
init
|
|
122
124
|
});
|
|
123
125
|
const responseData = yield fetcher(input, init);
|
|
124
|
-
console.log("[mtmfetch response]", responseData);
|
|
125
126
|
return responseData;
|
|
126
127
|
} catch (e) {
|
|
127
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 });
|